- 积分
- 702
- 金钱
- 672
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 702
- 金钱
- 672
- HASS币
- 0
|
本帖最后由 hbzjhg 于 2023-4-4 12:02 编辑
mqtt:
switch:
- name: 'ztc1_1_d0bae464159a'
unique_id: ztc1_1_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/state'
command_topic: 'device/ztc1/d0bae464159a/set'
payload_on: '{"mac":"d0bae464159a","plug_0":{"on":1}}'
payload_off: '{"mac":"d0bae464159a","plug_0":{"on":0}}'
value_template: '{{ value_json.plug_0.on }}'
state_on: '1'
state_off: '0'
switch:
- name: 'ztc1_2_d0bae464159a'
unique_id: ztc1_2_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/state'
command_topic: 'device/ztc1/d0bae464159a/set'
payload_on: '{"mac":"d0bae464159a","plug_1":{"on":1}}'
payload_off: '{"mac":"d0bae464159a","plug_1":{"on":0}}'
value_template: '{{ value_json.plug_1.on }}'
state_on: '1'
state_off: '0'
switch:
- name: 'ztc1_3_d0bae464159a'
unique_id: ztc1_3_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/state'
command_topic: 'device/ztc1/d0bae464159a/set'
payload_on: '{"mac":"d0bae464159a","plug_2":{"on":1}}'
payload_off: '{"mac":"d0bae464159a","plug_2":{"on":0}}'
value_template: '{{ value_json.plug_2.on }}'
state_on: '1'
state_off: '0'
switch:
- name: 'ztc1_4_d0bae464159a'
unique_id: ztc1_4_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/state'
command_topic: 'device/ztc1/d0bae464159a/set'
payload_on: '{"mac":"d0bae464159a","plug_3":{"on":1}}'
payload_off: '{"mac":"d0bae464159a","plug_3":{"on":0}}'
value_template: '{{ value_json.plug_3.on }}'
state_on: '1'
state_off: '0'
switch:
- name: 'ztc1_5_d0bae464159a'
unique_id: ztc1_5_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/state'
command_topic: 'device/ztc1/d0bae464159a/set'
payload_on: '{"mac":"d0bae464159a","plug_4":{"on":1}}'
payload_off: '{"mac":"d0bae464159a","plug_4":{"on":0}}'
value_template: '{{ value_json.plug_4.on }}'
state_on: '1'
state_off: '0'
switch:
- name: 'ztc1_6_d0bae464159a'
unique_id: ztc1_6_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/state'
command_topic: 'device/ztc1/d0bae464159a/set'
payload_on: '{"mac":"d0bae464159a","plug_5":{"on":1}}'
payload_off: '{"mac":"d0bae464159a","plug_5":{"on":0}}'
value_template: '{{ value_json.plug_5.on }}'
state_on: '1'
state_off: '0'
sensor:
- name: 'ztc1_power_d0bae464159a'
unique_id: ztc1_power_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/sensor'
#unit_of_measurement: 'W'
icon: 'mdi:gauge'
value_template: '{{ value_json.power }}'
sensor:
- name: 'ztc1_time_d0bae464159a'
unique_id: ztc1_time_d0bae464159a
state_topic: 'device/ztc1/d0bae464159a/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 -%}
homeassistant:
customize:
switch.ztc1_1_d0bae464159a:
friendly_name: 客厅1
switch.ztc1_2_d0bae464159a:
friendly_name: 打印机
switch.ztc1_3_d0bae464159a:
friendly_name: 显示器
switch.ztc1_4_d0bae464159a:
friendly_name: 电脑主机
switch.ztc1_5_d0bae464159a:
friendly_name: 客厅2
switch.ztc1_6_d0bae464159a:
friendly_name: 苹果
sensor.ztc1_power_d0bae464159a:
friendly_name: zTC1功率
sensor.ztc1_time_d0bae464159a:
friendly_name: zTC1运行时间
请哪位大神帮忙看看,为什么按照以上格式,最后只能显示第六个插槽苹果和运行时间两个实体,而且苹果插槽还可以正常控制,运行时间可以正常显示时间。
同样格式再接入一个ztc2,同样只能显示第六个插槽和运行时间,但插槽无法控制,运行时间没有显示时间。
|
|