Last active
July 22, 2023 02:58
-
-
Save xiangsanliu/b85be38aab75bac9bece59c0616da54d to your computer and use it in GitHub Desktop.
home-assistant-config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mqtt: | |
switch: | |
- name: 'ztc1_1_d0bae46394a4' | |
unique_id: ztc1_1_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/state' | |
command_topic: 'device/ztc1/d0bae46394a4/set' | |
payload_on: '{"mac":"d0bae46394a4","plug_0":{"on":1}}' | |
payload_off: '{"mac":"d0bae46394a4","plug_0":{"on":0}}' | |
value_template: '{{ value_json.plug_0.on }}' | |
state_on: '1' | |
state_off: '0' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- name: 'ztc1_2_d0bae46394a4' | |
unique_id: ztc1_2_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/state' | |
command_topic: 'device/ztc1/d0bae46394a4/set' | |
payload_on: '{"mac":"d0bae46394a4","plug_1":{"on":1}}' | |
payload_off: '{"mac":"d0bae46394a4","plug_1":{"on":0}}' | |
value_template: '{{ value_json.plug_1.on }}' | |
state_on: '1' | |
state_off: '0' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- name: 'ztc1_3_d0bae46394a4' | |
unique_id: ztc1_3_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/state' | |
command_topic: 'device/ztc1/d0bae46394a4/set' | |
payload_on: '{"mac":"d0bae46394a4","plug_2":{"on":1}}' | |
payload_off: '{"mac":"d0bae46394a4","plug_2":{"on":0}}' | |
value_template: '{{ value_json.plug_2.on }}' | |
state_on: '1' | |
state_off: '0' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- name: 'ztc1_4_d0bae46394a4' | |
unique_id: ztc1_4_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/state' | |
command_topic: 'device/ztc1/d0bae46394a4/set' | |
payload_on: '{"mac":"d0bae46394a4","plug_3":{"on":1}}' | |
payload_off: '{"mac":"d0bae46394a4","plug_3":{"on":0}}' | |
value_template: '{{ value_json.plug_3.on }}' | |
state_on: '1' | |
state_off: '0' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- name: 'ztc1_5_d0bae46394a4' | |
unique_id: ztc1_5_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/state' | |
command_topic: 'device/ztc1/d0bae46394a4/set' | |
payload_on: '{"mac":"d0bae46394a4","plug_4":{"on":1}}' | |
payload_off: '{"mac":"d0bae46394a4","plug_4":{"on":0}}' | |
value_template: '{{ value_json.plug_4.on }}' | |
state_on: '1' | |
state_off: '0' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- name: 'ztc1_6_d0bae46394a4' | |
unique_id: ztc1_6_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/state' | |
command_topic: 'device/ztc1/d0bae46394a4/set' | |
payload_on: '{"mac":"d0bae46394a4","plug_5":{"on":1}}' | |
payload_off: '{"mac":"d0bae46394a4","plug_5":{"on":0}}' | |
value_template: '{{ value_json.plug_5.on }}' | |
state_on: '1' | |
state_off: '0' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
sensor: | |
- name: 'ztc1_power_d0bae46394a4' | |
unique_id: ztc1_power_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/sensor' | |
unit_of_measurement: 'W' | |
icon: 'mdi:gauge' | |
value_template: '{{ value_json.power }}' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- name: 'ztc1_time_d0bae46394a4' | |
unique_id: ztc1_time_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/sensor' | |
#unit_of_measurement: '秒' | |
icon: 'mdi:gauge' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
#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 -%} | |
sensor: | |
- platform: mqtt | |
name: 'ztc1_power_d0bae46394a4' | |
unique_id: ztc1_power_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/sensor' | |
unit_of_measurement: 'W' | |
icon: 'mdi:gauge' | |
value_template: '{{ value_json.power }}' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
- platform: mqtt | |
name: 'ztc1_time_d0bae46394a4' | |
unique_id: ztc1_time_d0bae46394a4 | |
state_topic: 'device/ztc1/d0bae46394a4/sensor' | |
#unit_of_measurement: '秒' | |
icon: 'mdi:gauge' | |
availability_topic: "device/ztc1/d0bae46394a4/availability" | |
payload_available: 1 | |
payload_not_available: 0 | |
#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_d0bae46394a4: | |
friendly_name: zTC1插槽1 | |
switch.ztc1_2_d0bae46394a4: | |
friendly_name: zTC1插槽2 | |
switch.ztc1_3_d0bae46394a4: | |
friendly_name: zTC1插槽3 | |
switch.ztc1_4_d0bae46394a4: | |
friendly_name: zTC1插槽4 | |
switch.ztc1_5_d0bae46394a4: | |
friendly_name: zTC1插槽5 | |
switch.ztc1_6_d0bae46394a4: | |
friendly_name: zTC1插槽6 | |
sensor.ztc1_power_d0bae46394a4: | |
friendly_name: zTC1功率 | |
sensor.ztc1_time_d0bae46394a4: | |
friendly_name: zTC1运行时间 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment