HASS集成互联网天气

在我们使用Home Assistant的过程中,往往希望获取天气数据,而互联网天气,成为了第一种选择,本文就告诉大家如何集成互联网天气,这次我们使用HeWeather

集成

按照如下命令安装:

cd /etc/hass
cd custom_components
git clone https://github.com/morestart/HeWeather

修改/etc/hass/configuration.yaml:

sensor:
  - platform: HeWeather
    city: "佛山"
    appkey: <appkey>   

    options:
      - fl
      - tmp
      - cond_txt
      - wind_spd
      - hum
      - pcpn
      - pres
      - vis
      - wind_sc
      - aqi
      - main
      - qlty
      - pm10
      - pm25
      - comf
      - cw
      - drsg
      - flu
      - sport
      - trav
      - uv
      - wind_dir
      - tmp_max
      - tmp_min
      - pop

使用以下命令重启hass:

systemctl restart hass

设置仪表盘

通过配置->lovelace仪表盘->添加仪表盘添加天气仪表盘,进入天气选项卡,使用如下仪表盘配置:

background: var(--background-image)
views:
  - title: 天气
    path: weather
    icon: mdi:weather-cloudy
    badges: []
    cards:
      - type: glance
        entities:
          - sensor.zhu_yao_wu_ran_wu
          - sensor.chu_xing_zhi_shu
          - sensor.tian_qi_zhuang_tai
          - sensor.gan_mou_zhi_shu
          - sensor.xi_che_zhi_shu
          - sensor.zi_wai_xian_zhi_shu
          - sensor.chuan_yi_zhi_shu
          - sensor.kong_qi_zhi_liang
          - sensor.shu_gua_du_zhi_shu
      - type: sensor
        entity: sensor.da_qi_ya
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.feng_su
        graph: line
        detail: 2
      - type: gauge
        entity: sensor.jiang_shui_gai_lu
      - type: sensor
        entity: sensor.jiang_shui_liang
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.jin_ri_zui_di_wen_du
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.jin_ri_zui_gao_wen_du
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.kong_qi_zhi_liang_zhi_shu
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.neng_jian_du
        graph: line
        detail: 2
      - type: gauge
        entity: sensor.shi_shi_shi_wai_shi_du
      - type: sensor
        entity: sensor.shi_shi_shi_wai_wen_du
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.shi_shi_ti_gan_wen_du
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.pm10
        graph: line
        detail: 2
      - type: sensor
        entity: sensor.pm2_5
        graph: line
        detail: 2
title: 天气

https://web.res.qhjack.cn/2021/06/25/bf481a50e5f4ae1884aebc588c2b353d

配置NODERED

对于使用了NODE-RED和小爱对接的,可以导入以下仪表盘:

[
    {
        "id": "693cee39.d45af",
        "type": "tab",
        "label": "温度",
        "disabled": false,
        "info": ""
    },
    {
        "id": "f18452d2.92aec",
        "type": "server-state-changed",
        "z": "693cee39.d45af",
        "name": "湿度",
        "server": "3c87f99d.1fa9b6",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.shi_shi_shi_wai_shi_du",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 170,
        "y": 160,
        "wires": [
            [
                "1d1653b7.db4eec"
            ]
        ]
    },
    {
        "id": "8659849e.4aefe",
        "type": "server-state-changed",
        "z": "693cee39.d45af",
        "name": "温度",
        "server": "3c87f99d.1fa9b6",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.shi_shi_shi_wai_wen_du",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 170,
        "y": 240,
        "wires": [
            [
                "1d1653b7.db4eec"
            ]
        ]
    },
    {
        "id": "1d1653b7.db4eec",
        "type": "api-current-state",
        "z": "693cee39.d45af",
        "name": "查询温度",
        "server": "3c87f99d.1fa9b6",
        "version": 2,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.shi_shi_shi_wai_wen_du",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 420,
        "y": 200,
        "wires": [
            [
                "47d64f14.57fbe8"
            ]
        ]
    },
    {
        "id": "47d64f14.57fbe8",
        "type": "change",
        "z": "693cee39.d45af",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "temp",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 650,
        "y": 200,
        "wires": [
            [
                "82e1cc.a13f4638"
            ]
        ]
    },
    {
        "id": "82e1cc.a13f4638",
        "type": "api-current-state",
        "z": "693cee39.d45af",
        "name": "查询湿度",
        "server": "3c87f99d.1fa9b6",
        "version": 2,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.shi_shi_shi_wai_shi_du",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 860,
        "y": 200,
        "wires": [
            [
                "311016f7.c10e4a"
            ]
        ]
    },
    {
        "id": "311016f7.c10e4a",
        "type": "change",
        "z": "693cee39.d45af",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "humidity",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1090,
        "y": 200,
        "wires": [
            [
                "8fbfbf31.dc93d8"
            ]
        ]
    },
    {
        "id": "d49bc6b.0863cb8",
        "type": "template",
        "z": "693cee39.d45af",
        "name": "设置数据格式",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "#{{ temp }}#{{ humidity }}#1#{{ pm2.5 }}#{{ qiya }}#",
        "output": "str",
        "x": 440,
        "y": 460,
        "wires": [
            [
                "57608fc0.8cb2e"
            ]
        ]
    },
    {
        "id": "57608fc0.8cb2e",
        "type": "mqtt out",
        "z": "693cee39.d45af",
        "name": "上传数据",
        "topic": "temp004",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "dd5ff2b3.26398",
        "x": 740,
        "y": 460,
        "wires": []
    },
    {
        "id": "8544faf3.aa2478",
        "type": "server-state-changed",
        "z": "693cee39.d45af",
        "name": "PM2.5",
        "server": "3c87f99d.1fa9b6",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.pm2_5",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 170,
        "y": 340,
        "wires": [
            [
                "1d1653b7.db4eec"
            ]
        ]
    },
    {
        "id": "8fbfbf31.dc93d8",
        "type": "api-current-state",
        "z": "693cee39.d45af",
        "name": "查询PM2.5",
        "server": "3c87f99d.1fa9b6",
        "version": 2,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.pm2_5",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 430,
        "y": 340,
        "wires": [
            [
                "6bff3829.08cf5"
            ]
        ]
    },
    {
        "id": "6bff3829.08cf5",
        "type": "change",
        "z": "693cee39.d45af",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "pm2.5",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 340,
        "wires": [
            [
                "24f97475.de2e9c"
            ]
        ]
    },
    {
        "id": "24f97475.de2e9c",
        "type": "api-current-state",
        "z": "693cee39.d45af",
        "name": "查询气压",
        "server": "3c87f99d.1fa9b6",
        "version": 2,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.da_qi_ya",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 900,
        "y": 340,
        "wires": [
            [
                "be856cb.b3c469"
            ]
        ]
    },
    {
        "id": "be856cb.b3c469",
        "type": "change",
        "z": "693cee39.d45af",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "qiya",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1120,
        "y": 340,
        "wires": [
            [
                "d49bc6b.0863cb8"
            ]
        ]
    },
    {
        "id": "a030aed2.d9ba78",
        "type": "server-state-changed",
        "z": "693cee39.d45af",
        "name": "大气压",
        "server": "3c87f99d.1fa9b6",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.da_qi_ya",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 170,
        "y": 440,
        "wires": [
            [
                "1d1653b7.db4eec"
            ]
        ]
    },
    {
        "id": "3c87f99d.1fa9b6",
        "type": "server",
        "name": "Home Assistant",
        "version": 1,
        "legacy": false,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    },
    {
        "id": "dd5ff2b3.26398",
        "type": "mqtt-broker",
        "name": "Remote MQTT",
        "broker": "bemfa.com",
        "port": "9501",
        "clientid": "7ca62f668da56fafbbafa04dbfe42a5f",
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

流程效果图:
https://web.res.qhjack.cn/2021/06/25/5d227244c6ff23d80189fe1f0091a5fd

https://github.com/morestart/HeWeather 挂了好像

没有挂,一切正常,github如果访问不了,请上代理