AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.58k stars 405 forks source link

LAN control of TH10 #1363

Open jkoornneef opened 3 months ago

jkoornneef commented 3 months ago

Hi, Hoping someone can help. I'm trying to control a TH10 over LAN from a simple app. I can successfully control a Basic (change state and decode updates) and I can see and decode changes FROM a TH10, including temp and humidity. However, I cannot change the relay state using the same (reencrypted) message/code as the Basic. I get 400 errors, so I'm missing or misconfiguring something in the message.

http://192.168.1.xxx:8081/zeroconf/switch

{"sequence":"638465458922","deviceid":"10002xxxxx","selfApikey":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","iv":"xxxxx","encrypt":true,"data":"sXErEgwQxD8n8mZtf3ZqRg=="}

where data is: {"mainSwitch":"on", "switch":"on"} or {"switch":"on"} , although I have also tried 'fan', 'light', and 'switches'

Sending properly encrypted above to the Basic device switched the relay correctly.

I'm sure I have the encryption key correct for the TH10, since I decode updates such as: Received: {"mainSwitch":"on","deviceType":"normal","switch":"on","startup":"off","pulse":"off","pulseWidth":500,"sledOnline":"on","sensorType":"AM2301","currentHumidity":"37","currentTemperature":"21.4","ssid":"xxxxxxx","bssid":"xx:xx:xx:x:xx:xx"}

I'm sure I'm missing something simple here. Thanks