Open rodneymo opened 6 years ago
So I tried to modify tplink.py to return fake
'{"emeter":{"get_realtime":{"current":%c%,"voltage":%v%,"power":%p%,"total":0,"err_code":0}}}'
Obviously with replaced tokens, but I guess you don't really call tplink.py from your script, but handle everyhting internally or maybe you do call some commands before {"emeter":{"get_realtime":{}}} which I also should fake output ? I'm to lazy to sniff the traffic right now :)
I have been playing with this for a few days and reverse engineering the standard cloud API is a lot of work, especially with the latest versions of the product firmware so now I am going to give Tasmota a try. The other advantage of Tasmota, as I see it, is the fact that the API provide power measurements as well.
Official API http://iotgo.iteadstudio.com/api
Tasmota Web "API" http://192.168.500.400/cm?cmnd=Power%20On returns json
{"POWER":"ON"}
/cm?cmnd=Power%20Off
{"POWER":"OFF"}
/cm?cmnd=Power%20TOGGLE
{"POWER":"OFF"}
{"POWER":"ON"}
that is state after toggle/cm?cmnd=Status%208
{"StatusSNS":{"Time":"2018-07-26T22:34:08","ENERGY":{"Total":0.000,"Yesterday":0.000,"Today":0.000,"Power":10,"Factor":0.52,"Voltage":236,"Current":0.083}}}
10W/cm?cmnd=status
{"Status":{"Module":43,"FriendlyName":["Sonoff"],"Topic":"sonoff","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}
"Power":1=On "Power":0=Offtasmota also supports https://github.com/arendst/Sonoff-Tasmota/wiki/MQTT-Overview, I used it with home assistant with success, but I think web would be easier, as it does not require broker like mqtt, I will try to do .py that woks same as tplink.py if I find time for it. I will try to do it for tasmota, but no guaranties :) - it would be my first python script.