Open MaggieWong27 opened 5 years ago
You are right. The documentation is wrong. The DIY tool not only fills the "data" field as a string, the string has is content escaped ( \" instead of only " ). https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/a337e85aeda254e64018a60ce1dd439e75db2a0b/code/lan_ewlink_api.py#L226
Also sends one undocumented field: "selfApikey": "123" It can be any number or empty but the field has to be included. Otherwise the device doesn't respond.
This works in postman / curl : {"sequence": "1563473445", "deviceid": "100000140e", "encrypt": false, "selfApikey": "", "data": "{\"switch\": \"on\"}"}
I hope this helps
Sorry, github has interpreted my escaped quotes.. :)
This is the working json:
{"sequence": "1563473445", "deviceid": "100000140e", "encrypt": false, "selfApikey": "", "data": "{\"switch\": \"on\"}"}
I'm struggling to pass the values using HTTP POST in NodeRED (javascript) I have tried a couple of version of the payload but I'm missing something obvious (tool is working ok)
I tried the formatting the message your way and dropping the "/" to pass it as JSON object too without luck.
I get message
Error: read ECONNRESET
or
Error: read ECONNRESET : http://192.168.1.28:8081/zeroconf/switch
Any suggestions?
I use NodeRED too. My function node is as simple as:
msg.payload = { "sequence": "1563473445", "deviceid": "100000140e", "encrypt": false, "selfApikey": "", "data": "{\"switch\": \"on\"}" } return msg;
It has to be formatted as the DIY tool does, not like the documentation says.
After the update only device ID and the data has to be submitted. Finally works
On Fri, 2 Aug 2019, 08:14 cpuga, notifications@github.com wrote:
I use NodeRED too. My function node is as simple as:
msg.payload = { "sequence": "1563473445", "deviceid": "100000140e", "encrypt": false, "selfApikey": "", "data": "{\"switch\": \"on\"}" } return msg;
It has to be formatted as the DIY tool does, not like the documentation says.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/itead/Sonoff_Devices_DIY_Tools/issues/13?email_source=notifications&email_token=AKDRL27SSYG56RUX5DVD5ITQCPNFBA5CNFSM4H7KTUTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3M3U7Y#issuecomment-517585535, or mute the thread https://github.com/notifications/unsubscribe-auth/AKDRL22WNBS52JXAJIYA36LQCPNFBANCNFSM4H7KTUTA .
Your DIY tool fills the "data" field as a string, which contradicts your protocol documentation.