|
本帖最后由 sfjnjau 于 2019-5-7 22:04 编辑
手头有个reco4life的插座,可以通过UDP广播地址批量识别,通过TCP协议控制开关、读取信息……但是作为小白,实在没能力写插件,参照switch.command_line和sensor.tcp 摸索了一阵,command_on和command_off 用不了,点击开关没反应(直接在PUTTY里输命令行是可以开关插座的),sensor.tcp 可以读取信息,但不知是端口占用还是设备拒绝,信息读取不稳定。求大佬指点指点,或者帮忙搞个插件哈
switch:
platform: command_line
switches:
recoplug:
command_on: " echo AT+YZSWITCH=1,ON,20190505 >/dev/tcp/192.168.50.69/8899"
command_off: " echo AT+YZSWITCH=1,OFF,20190505 >/dev/tcp/192.168.50.69/8899"
# command_state: "cat <echo AT+YZOUT >/dev/tcp/192.168.50.69/8899"
# value_template: '{{ value == "1" }}'
friendly_name: test
sensor:
- platform: tcp
name: recoplug-I
host: 192.168.50.69
port: 8899
payload: "AT+YZOUT"
value_template: "{{ (value.split(',')[0]).split('=')[1] | multiply(0.01) | round(2) }}"
unit_of_measurement: A
- platform: tcp
name: recoplug-U
host: 192.168.50.69
port: 8899
payload: "AT+YZOUT"
value_template: "{{ value.split(',')[1] | multiply(0.01) | round(2) }}"
unit_of_measurement: V
- platform: tcp
name: recoplug-F
host: 192.168.50.69
port: 8899
payload: "AT+YZOUT"
value_template: "{{ value.split(',')[2] | multiply(0.01) | round(2) }}"
unit_of_measurement: Hz
- platform: tcp
name: recoplug-P
host: 192.168.50.69
port: 8899
payload: "AT+YZOUT"
value_template: "{{ value.split(',')[3] | multiply(0.1) | round(2) }}"
unit_of_measurement: W
- platform: tcp
name: recoplug-E
host: 192.168.50.69
port: 8899
payload: "AT+YZOUT"
value_template: "{{ value.split(',')[5] | round(2) }}"
unit_of_measurement: WH
以下是在GITHUB上搜到的用这款插座的项目,看看能不能参考……
https://github.com/legendmohe/LE ... per/SwitchHelper.py
|
|