彩云天气传感器 - Home Assistant 插件

| 分类 代码  | 标签 智能家居 

对标 HA 内置 yr 天气插件的高质量 HA custom_component。

Preview

1. 代码在此:

https://github.com/Yonsm/HAExtra/blob/master/custom_components/sensor/caiyun.py

复制 homeassistant 的配置目录中 custom_components/sensor/ 下,无此目录请创建。

2. 配置方法和 yr 类似,最简单的配置版本如下:

sensor:
  - platform: caiyun

以上默认启用这些传感器20分钟更新一次,自动使用 HA 中配置的地理位置。

下面是完整的配置项,每个传感器均仔细挑选了 mdi 的图标,无需额外配置:

sensor:
  - platform: caiyun
    #name: CaiYun
    #scan_interval: 1200
    #latitude: 30.000
    #longitude: 120.000
    monitored_conditions: # Optional
      - weather
      - temperature
      - humidity
      - cloud_rate
      - pressure
      - wind_direction
      - wind_speed
      - local_precipitation
      - nearest_precipitation
      - precipitation_distance
      - aqi
      - pm25
      - pm10
      - o3
      - co
      - no2
      - so2

3. 【可选】上面配置好了之后就可以了,但默认是英文名称。建议 customize.yaml 中配置中文名称如下:

group.outside:
  friendly_name: 室外
sun.sun:
  friendly_name: 日照

sensor.caiyun_weather:
  friendly_name: 天气
sensor.caiyun_temperature:
  friendly_name: 室外气温
sensor.caiyun_humidity:
  friendly_name: 室外湿度
sensor.caiyun_cloud_rate:
  friendly_name: 云量
sensor.caiyun_pressure:
  friendly_name: 气压
sensor.caiyun_wind_direction:
  friendly_name: 风向
sensor.caiyun_wind_speed:
  friendly_name: 风速
sensor.caiyun_local_precipitation:
  friendly_name: 降水强度
sensor.caiyun_nearest_precipitation:
  friendly_name: 附近降水强度
sensor.caiyun_precipitation_distance:
  friendly_name: 附近降水距离
sensor.caiyun_aqi:
  friendly_name: 空气指数
sensor.caiyun_pm25:
  friendly_name: 室外颗粒物
  homebridge_name: 空气质量
sensor.caiyun_pm10:
  friendly_name: 室外大颗粒物
sensor.caiyun_o3:
  friendly_name: 室外臭氧
sensor.caiyun_co:
  friendly_name: 室外一氧化碳
sensor.caiyun_no2:
  friendly_name: 室外二氧化氮
sensor.caiyun_so2:
  friendly_name: 室外二氧化硫

4. 【可选】建议在 groups.yaml 中添加如下代码进行分组:

outside:
    entities:
      - sun.sun
      - sensor.caiyun_weather
      - sensor.caiyun_temperature
      - sensor.caiyun_humidity
      - sensor.caiyun_cloud_rate
      - sensor.caiyun_pressure
      - sensor.caiyun_wind_direction
      - sensor.caiyun_wind_speed
      - sensor.caiyun_local_precipitation
      - sensor.caiyun_nearest_precipitation
      - sensor.caiyun_precipitation_distance
      - sensor.caiyun_aqi
      - sensor.caiyun_pm25
      - sensor.caiyun_pm10
      - sensor.caiyun_o3
      - sensor.caiyun_co
      - sensor.caiyun_no2
      - sensor.caiyun_so2

原帖发布在:https://bbs.hassbian.com/thread-2697-1-1.html


上一篇     下一篇