|
楼主 |
发表于 2022-11-13 21:09:26
|
显示全部楼层
本帖最后由 geniusliang 于 2022-11-13 21:11 编辑
我已经在UI 直接配置了MQTT 服务器。但是我把TC1的配置文件改成下面的之后就无法在HA开发者工具里面找到TC1的那些开关实体了。改回原来的就能用。请问有哪位高手能告知下我改的哪里有错误么?
mqtt:
# TC1
switch:
- name: 'ztc1_1_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/state'
command_topic: 'device/ztc1/d0bae462f5a6/set'
payload_on: '{"mac":"d0bae462f5a6","plug_0":{"on":1}}'
payload_off: '{"mac":"d0bae462f5a6","plug_0":{"on":0}}'
value_template: '{{ value_json.plug_0.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_2_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/state'
command_topic: 'device/ztc1/d0bae462f5a6/set'
payload_on: '{"mac":"d0bae462f5a6","plug_1":{"on":1}}'
payload_off: '{"mac":"d0bae462f5a6","plug_1":{"on":0}}'
value_template: '{{ value_json.plug_1.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_3_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/state'
command_topic: 'device/ztc1/d0bae462f5a6/set'
payload_on: '{"mac":"d0bae462f5a6","plug_2":{"on":1}}'
payload_off: '{"mac":"d0bae462f5a6","plug_2":{"on":0}}'
value_template: '{{ value_json.plug_2.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_4_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/state'
command_topic: 'device/ztc1/d0bae462f5a6/set'
payload_on: '{"mac":"d0bae462f5a6","plug_3":{"on":1}}'
payload_off: '{"mac":"d0bae462f5a6","plug_3":{"on":0}}'
value_template: '{{ value_json.plug_3.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_5_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/state'
command_topic: 'device/ztc1/d0bae462f5a6/set'
payload_on: '{"mac":"d0bae462f5a6","plug_4":{"on":1}}'
payload_off: '{"mac":"d0bae462f5a6","plug_4":{"on":0}}'
value_template: '{{ value_json.plug_4.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_6_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/state'
command_topic: 'device/ztc1/d0bae462f5a6/set'
payload_on: '{"mac":"d0bae462f5a6","plug_5":{"on":1}}'
payload_off: '{"mac":"d0bae462f5a6","plug_5":{"on":0}}'
value_template: '{{ value_json.plug_5.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_1_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/state'
command_topic: 'device/ztc1/d0bae463658b/set'
payload_on: '{"mac":"d0bae463658b","plug_0":{"on":1}}'
payload_off: '{"mac":"d0bae463658b","plug_0":{"on":0}}'
value_template: '{{ value_json.plug_0.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_2_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/state'
command_topic: 'device/ztc1/d0bae463658b/set'
payload_on: '{"mac":"d0bae463658b","plug_1":{"on":1}}'
payload_off: '{"mac":"d0bae463658b","plug_1":{"on":0}}'
value_template: '{{ value_json.plug_1.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_3_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/state'
command_topic: 'device/ztc1/d0bae463658b/set'
payload_on: '{"mac":"d0bae463658b","plug_2":{"on":1}}'
payload_off: '{"mac":"d0bae463658b","plug_2":{"on":0}}'
value_template: '{{ value_json.plug_2.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_4_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/state'
command_topic: 'device/ztc1/d0bae463658b/set'
payload_on: '{"mac":"d0bae463658b","plug_3":{"on":1}}'
payload_off: '{"mac":"d0bae463658b","plug_3":{"on":0}}'
value_template: '{{ value_json.plug_3.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_5_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/state'
command_topic: 'device/ztc1/d0bae463658b/set'
payload_on: '{"mac":"d0bae463658b","plug_4":{"on":1}}'
payload_off: '{"mac":"d0bae463658b","plug_4":{"on":0}}'
value_template: '{{ value_json.plug_4.on }}'
state_on: '1'
state_off: '0'
- name: 'ztc1_6_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/state'
command_topic: 'device/ztc1/d0bae463658b/set'
payload_on: '{"mac":"d0bae463658b","plug_5":{"on":1}}'
payload_off: '{"mac":"d0bae463658b","plug_5":{"on":0}}'
value_template: '{{ value_json.plug_5.on }}'
state_on: '1'
state_off: '0'
sensor:
- name: 'ztc1_time_d0bae462f5a6'
state_topic: 'device/ztc1/d0bae462f5a6/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 -%}
- name: 'ztc1_power_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/sensor'
unit_of_measurement: 'W'
icon: 'mdi:gauge'
value_template: '{{ value_json.power }}'
- name: 'ztc1_time_d0bae463658b'
state_topic: 'device/ztc1/d0bae463658b/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 -%}
|
|