mdopp / simple-sonoff-server

Emulates the original sonoff-cloud-servers within your local network.
BSD 2-Clause "Simplified" License
144 stars 47 forks source link

Support Sonoff TH10 Wi-Fi Smart Switch #29

Open castoutside opened 6 years ago

castoutside commented 6 years ago

I have TH10 with temperature and humidity (in my case - both disconnected). Simple sonoff server fails to get the state of device after the device reports its temp & humidity params.

  1. When the device was just registered: http://192.168.188.220:10000/devices/ [{"id":"10002218af","state":"off","model":"PSA-BHA-GL","version":"2.0.4","isConnected":true,"isAlive":true,"rawMessageRegister":{"userAgent":"device","apikey":"9a2b320e-5d9b-4683-8ac1-2af022e26b6d","deviceid":"10002218af","action":"register","version":2,"romVersion":"2.0.4","model":"PSA-BHA-GL","ts":182,"timestamp":1525123819451},"rawMessageLastUpdate":{"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"10002218af","action":"update","params":{"switch":"off","fwVersion":"2.0.4","rssi":-59,"staMac":"DC:4F:22:0D:E8:CA","startup":"off"},"timestamp":1525123819484}}]
  2. When the device was just registered: http://192.168.188.220:10000/devices/10002218af/status 0
  3. When the device reports it's state params: http://192.168.188.220:10000/devices/ [{"id":"10002218af","model":"PSA-BHA-GL","version":"2.0.4","isConnected":true,"isAlive":true,"rawMessageRegister":{"userAgent":"device","apikey":"9a2b320e-5d9b-4683-8ac1-2af022e26b6d","deviceid":"10002218af","action":"register","version":2,"romVersion":"2.0.4","model":"PSA-BHA-GL","ts":182,"timestamp":1525123819451},"rawMessageLastUpdate":{"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"10002218af","action":"update","params":{"currentTemperature":"unavailable","currentHumidity":"unavailable","sensorType":"ERROR_TYPE"},"timestamp":1525123827421}}]
  4. When the device reports it's state params: http://192.168.188.220:10000/devices/10002218af/status Sonoff device 10002218af not found
  5. Here is the output of the simple-sonoff-server.js (I have marked my requests): pi@raspberrypi:~/sonoff $ node sonoff.server.js SONOFF Server Started On Port 10001 API Server Started On Port 10000 REQ | POST | /dispatch/device REQ | {"accept":"ws;2","version":2,"ts":381,"deviceid":"10002218af","apikey":"9a2b320e-5d9b-4683-8ac1-2af022e26b6d","model":"PSA-BHA-GL","romVersion":"2.0.4"} WS | Server is up 192.168.188.220:10002 to ::ffff:192.168.188.172:19407 REQ | WS | DEV | {"userAgent":"device","apikey":"9a2b320e-5d9b-4683-8ac1-2af022e26b6d","deviceid":"10002218af","action":"register","version":2,"romVersion":"2.0.4","model":"PSA-BHA-GL","ts":182} INFO | WS | Device 10002218af registered RES | WS | DEV | {"error":0,"deviceid":"10002218af","apikey":"111111111-1111-1111-1111-111111111111"} REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"10002218af","action":"date"} RES | WS | DEV | {"error":0,"deviceid":"10002218af","apikey":"111111111-1111-1111-1111-111111111111","date":"2018-04-30T21:30:19.470Z"} REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"10002218af","action":"update","params":{"switch":"off","fwVersion":"2.0.4","rssi":-59,"staMac":"DC:4F:22:0D:E8:CA","startup":"off"}} RES | WS | DEV | {"error":0,"deviceid":"10002218af","apikey":"111111111-1111-1111-1111-111111111111"} REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"10002218af","action":"query","params":["timers","targets","mainSwitch","deviceType"]} RES | WS | DEV | {"error":0,"deviceid":"10002218af","apikey":"111111111-1111-1111-1111-111111111111","params":{}} GET | GET | /devices/ GET | GET | /devices/10002218af/status REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"10002218af","action":"update","params":{"currentTemperature":"unavailable","currentHumidity":"unavailable","sensorType":"ERROR_TYPE"}} RES | WS | DEV | {"error":0,"deviceid":"10002218af","apikey":"111111111-1111-1111-1111-111111111111"} GET | GET | /devices/ GET | GET | /devices/10002218af/status