本帖最后由 comeon_000 于 2020-2-20 23:43 编辑
配置文件检查是OK的,重启HA后,开发者工具里的状态栏,实体里找不到新配置的zTC1传感器
我理解这个配置如果引用的东西不对,只要语法正确,都应该在HA中展示出来,最多就是状态不正确
奇怪的是一个配置文件里,以前配置的zM1没问题,看代码貌似也没啥错误,求大神指导~
# zM1
- platform: mqtt
name: 'zm1_b0f893226fed_temperature'
# friendly_name: 温度
state_topic: 'device/zm1/b0f893226fed/sensor'
unit_of_measurement: '°C'
icon: 'mdi:thermometer'
value_template: '{{ value_json.temperature }}'
- platform: mqtt
name: 'zm1_b0f893226fed_humidity'
# friendly_name: 湿度
state_topic: 'device/zm1/b0f893226fed/sensor'
unit_of_measurement: '%RH'
icon: mdi:water-percent
value_template: '{{ value_json.humidity }}'
- platform: mqtt
name: 'zm1_b0f893226fed_pm25'
# friendly_name: PM25
state_topic: 'device/zm1/b0f893226fed/sensor'
unit_of_measurement: 'μg/m³'
icon: mdi:blur
value_template: '{{ value_json.PM25 }}'
- platform: mqtt
name: 'zm1_b0f893226fed_hcho'
# friendly_name: 甲醛
state_topic: 'device/zm1/b0f893226fed/sensor'
unit_of_measurement: 'mg/m³'
icon: mdi:chemical-weapon
value_template: '{{ value_json.formaldehyde }}'
# zTC1
- platform: mqtt
name: 'ztc1_power_d0bae4635dde'
state_topic: 'device/ztc1/d0bae4635dde/sensor'
unit_of_measurement: 'W'
icon: mdi:gauge
value_template: '{{ value_json.power }}'
- platform: mqtt
name: 'ztc1_time_d0bae4635dde'
state_topic: 'device/ztc1/d0bae4635dde/sensor'
#unit_of_measurement: '秒'
icon: mdi:gauge
#value_template: '{{ value_json.total_time }}'
value_template: >-
{% set time = value_json.total_time %}
{% set minutes = ((time % 3600) / 60) | int %}
{% set hours = ((time % 86400) / 3600) | int %}
{% set days = (time / 86400) | int %}
{%- if time < 60 -%}
<1分钟
{%- else -%}
{%- if days > 0 -%}
{{ days }}天
{%- endif -%}
{%- if hours > 0 -%}
{{ hours }}小时
{%- endif -%}
{%- if minutes > 0 -%}
{{ minutes }}分钟
{%- endif -%}
{%- endif -%}
|