BrettSheleski / SmartThingsPublic

36 stars 23 forks source link

Sonoff S31 with Tasmota 5.14.0 crash with SmartThings handler refresh action #15

Open n17ikh opened 6 years ago

n17ikh commented 6 years ago

Hi, I have a couple Sonoff S31 modules with Tasmota 5.14.0. With the Tasmota smartthings handler pointed at the device, it seems like the Sonoff module reboots every time the device is queried by SmartThings, either by clicking on the link to the device on the web or opening it on the Android SmartThings application. The module reboots, with restart reason "Software Watchdog", and the Tasmota-Power handler doesn't auto-populate the way it should.

I figured this would be closely related enough to the S20 that it should Just Work. I've uploaded a couple screenshots. Any thoughts?

tasmota_setup tasmota_information_page

BrettSheleski commented 6 years ago

Strange. The device handler isn't doing anything than just using the http command interface.

Try going to http://10.1.2.83/cm?cmnd=status in a web browser and see what happens.

There's only a handful of commands the device handler uses, it should be pretty easy to find the culprit.

n17ikh commented 6 years ago

Well, I'm not sure what changed between today and yesterday, but the Sonoff devices no longer crash when probed by the SmartThings handler. Running /cm?cmnd=status returns a username/password reminder. With the appropriate user and password parameters passed, it returns the following json: {"Status":{"Module":41,"FriendlyName":["UpstairsWindowAC"],"Topic":"sonoff","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}

Running a packet capture on the traffic between the SmartThings hub and the Sonoff, it looks like the SmartThings handler is running HTTP GETs for /cm?Status%200, /cm?cmnd=module, and /cm/cmnd=gpio. Status 0 returns what looks to be full status information about the module. cmnd=module returns: {"Module":"41 (Sonoff S31)"} cmnd=gpio returns: {"GPIO":"Not supported"}. The power handler still isn't auto-populating the way it should.

BrettSheleski commented 6 years ago

Well your observations are good. It does indeed do a module command and a gpios command to determine the module type and and possible gpio configuration.

I'm not sure why it's not working for you. I don't see why it wouldn't. Are you sure you have the Tasmota-Power device handler also added and published?

Try removing and re-adding the device in SmartThings, it should spawn the child device

n17ikh commented 6 years ago

I do have both the Tasmota and Tasmota-Power device handlers published. Tried removing and re-adding both my Sonoff S31s. The "current states" section in SmartThings is enumerating now, but still no dice on the power handler.

BrettSheleski commented 6 years ago

After rereading your previous commend I see that the GPIO command is returning {"GPIO":"Not supported"}. I suspect this is causing the method that parses that response to fail and thus not populating anything. For other module types, the gpios command returns a JSON object. I'll have to update the handler to account for this.

BrettSheleski commented 6 years ago

I also see that FriendlyName now returns an array of values instead of just one (from the status command). I'll have to update account for this as well.