itead / Sonoff_Devices_DIY_Tools

BSD 3-Clause "New" or "Revised" License
558 stars 166 forks source link

Postman failing to connect to device in DIY mode #132

Open DeanRos opened 1 year ago

DeanRos commented 1 year ago

Hi

I have setup my minir3 in DIY mode, it is running firmware version 1.4.0. I am trying to send it a command using postman but get an "Error: socket hang up" Please take a look at my code below and see if I am doing something incorrect.

image

POST http://192.168.0.188:8081/zeroconf/signal_strength Error: socket hang up Network Request Headers Content-Type: application/json User-Agent: PostmanRuntime/7.32.2 Accept: */* Cache-Control: no-cache Postman-Token: 7e0530ae-63f2-4e4c-9327-48dcbeb71f14 Host: 192.168.0.188:8081 Accept-Encoding: gzip, deflate, br Connection: keep-alive Request Body { "deviceid": "100174292d", "data": { } }

IBims1NicerTobi commented 1 year ago

Try removing the device id and send only {"data":{}}. That fixed it for me at least but it's not documented anywhere so far

kszili commented 1 year ago

Try removing the device id and send only {"data":{}}. That fixed it for me at least but it's not documented anywhere so far

Wow. I spent hours today to figure out why I'm not able to communicate with my devices. Just found your answer, tried it and voila, it works.

So yes, removing the deviceid tag from the request solves the communication problems. While earlier they simply ignored the deviceid tag (so you could send anything there), now, in the latest firmware (3.7.6 for a Basic R3) they implemented a check on this tag. If deviceid is missing, it works. If deviceid contains the proper deviceid (which I can query first with a POST /zeroconf/info, but without the deviceid), it works. If deviceid contains an inproper deviceid, it does not respond. Which is a poor design.

krumok commented 11 months ago

Try removing the device id and send only {"data":{}}. That fixed it for me at least but it's not documented anywhere so far

Wow. I spent hours today to figure out why I'm not able to communicate with my devices. Just found your answer, tried it and voila, it works.

So yes, removing the deviceid tag from the request solves the communication problems. While earlier they simply ignored the deviceid tag (so you could send anything there), now, in the latest firmware (3.7.6 for a Basic R3) they implemented a check on this tag. If deviceid is missing, it works. If deviceid contains the proper deviceid (which I can query first with a POST /zeroconf/info, but without the deviceid), it works. If deviceid contains an inproper deviceid, it does not respond. Which is a poor design.

Great, you save me! Same behaviour with sonogg mini r2 firmware 3.7.6 It works, just removing "deviceid":"" Thank you

kszili commented 11 months ago

Yes, it is the same with Sonoff Mini R3 running 3.7.6. So it is probably the recent firmware bringing in this new functionality.