C1只取值不控制就很方便了,直接用Command line就可以做一个package,省去写插件.
之前用rest也可以,但现在好像不行了.
sensor:
#C1传感器
- platform: command_line
name: c1_pm25
command: "curl -d 'userId=自己的userid&token=自己的token&device_id=c1设备值&' 'http://luxcar.com.cn/airx/airx_iot_reportup/web/equipment/loadDeviceData'"
value_template: '{{ value_json["data"]["pm25"] }}'
unit_of_measurement: 'μg/m3'
# 更新时间 /秒
scan_interval: 60
json_attributes:
- data
- success
- platform: template
sensors:
c1_pm1:
friendly_name: "PM1"
unit_of_measurement: 'μg/m3'
value_template: "{{ states.sensor.c1_pm25.attributes.data.pm1 }}"
c1_pm10:
friendly_name: "PM10"
unit_of_measurement: 'μg/m3'
value_template: "{{ states.sensor.c1_pm25.attributes.data.pm10 }}"
c1_pm25_city:
friendly_name: "城市PM2.5"
unit_of_measurement: 'μg/m3'
value_template: "{{ states.sensor.c1_pm25.attributes.data.pm25_city }}"
homeassistant:
# Customze-UI 颜色随值变化,没装可以删掉
customize_glob:
sensor.c1_pm*:
icon: mdi:blur
templates:
hs_color: if (state <= 50 ) return [120, 75.6, 80.4]; if (state > 50 && state <= 100 ) return [51, 100.0, 100.0]; else return [0, 100.0, 100.0];
# 普通命名
customize:
sensor.c1_pm25 :
friendly_name: PM2.5
icon: mdi:blur
sensor.c1_pm1 :
icon: mdi:blur
sensor.c1_pm10 :
icon: mdi:blur
sensor.c1_pm25_city :
icon: mdi:blur
group:
airx_c1:
name: C1检测仪
view: no
control: hidden
entities:
- sensor.c1_pm25
- sensor.c1_pm1
- sensor.c1_pm10
- sensor.c1_pm25_city
|