本帖最后由 veryuse 于 2019-9-26 10:44 编辑
已经解决了,需要答案的看12楼
这边用树莓派安装了homeassistant,版本0.99.2
根据zTC1的教程(https://github.com/a2633063/zTC1),已经刷了固件,也使用了激活码,用手机app的udp方式能实现控制。
已经在configuration.yaml文件中增加以下代码:
mqtt:
switch:
- platform: mqtt
name: 'tc1_1'
state_topic: 'homeassistant/switch/MAC/plug_0/state'
command_topic: 'device/ztc1/set'
payload_on: '{"mac":"MAC","plug_0":{"on":1}}'
payload_off: '{"mac":"MAC","plug_0":{"on":0}}'
- platform: mqtt
name: 'tc1_2'
state_topic: 'homeassistant/switch/MAC/plug_1/state'
command_topic: 'device/ztc1/set'
payload_on: '{"mac":"MAC","plug_1":{"on":1}}'
payload_off: '{"mac":"MAC","plug_1":{"on":0}}'
- platform: mqtt
name: 'tc1_3'
state_topic: 'homeassistant/switch/MAC/plug_2/state'
command_topic: 'device/ztc1/set'
payload_on: '{"mac":"MAC","plug_2":{"on":1}}'
payload_off: '{"mac":"MAC","plug_2":{"on":0}}'
- platform: mqtt
name: 'tc1_4'
state_topic: 'homeassistant/switch/MAC/plug_3/state'
command_topic: 'device/ztc1/set'
payload_on: '{"mac":"MAC","plug_3":{"on":1}}'
payload_off: '{"mac":"MAC","plug_3":{"on":0}}'
- platform: mqtt
name: 'tc1_5'
state_topic: 'homeassistant/switch/MAC/plug_4/state'
command_topic: 'device/ztc1/set'
payload_on: '{"mac":"MAC","plug_4":{"on":1}}'
payload_off: '{"mac":"MAC","plug_4":{"on":0}}'
- platform: mqtt
name: 'tc1_6'
state_topic: 'homeassistant/switch/MAC/plug_5/state'
command_topic: 'device/ztc1/set'
payload_on: '{"mac":"MAC","plug_5":{"on":1}}'
payload_off: '{"mac":"MAC","plug_5":{"on":0}}'
sensor:
- platform: mqtt
name: 'tc1_power'
state_topic: 'homeassistant/sensor/MAC/power/state'
unit_of_measurement: 'W'
icon: 'mdi:gauge'
value_template: '{{ value_json.power }}'
homeassistant:
customize:
switch.tc1_1:
friendly_name: TC1插槽1
switch.tc1_2:
friendly_name: TC1插槽2
switch.tc1_3:
friendly_name: TC1插槽3
switch.tc1_4:
friendly_name: TC1插槽4
switch.tc1_5:
friendly_name: TC1插槽5
switch.tc1_6:
friendly_name: TC1插槽6
sensor.tc1_power:
friendly_name: TC1功率
group:
tc1:
name: TC1插座
view: no
entities:
- sensor.tc1_power
- switch.tc1_1
- switch.tc1_2
- switch.tc1_3
- switch.tc1_4
- switch.tc1_5
- switch.tc1_6
现在项接入homeassistant,但是连接不上,没法控制。
请问哪位大佬实现过控制了,告知一下中间缺失了什么环节。。。。
|