Ewelink / Sonoff Binding - New binding without flashing

Where are you trying to transform it?
In the UI , where I link item to channel see below image

Well that’s why as it’s r18 that has the fix in above

I’m on 2.5.13 r18, the account thing is online but during discovery nothing is found.
this is the log:

2021-03-20 17:09:55.644 [INFO ] [inding.sonoff.internal.MainDiscovery] - Discovered device 10002a293f
2021-03-20 17:09:55.647 [ERROR] [inding.sonoff.internal.MainDiscovery] - Unable to add 10002a293f as its not supported, please forward the cache file to the developer
2021-03-20 17:10:19.889 [ERROR] [f.internal.messaging.MessageProvider] - Error Running queue:null
2021-03-20 17:11:09.972 [ERROR] [f.internal.messaging.MessageProvider] - The device 10002a293f doesnt exist, unable to set state
2021-03-20 17:11:23.401 [INFO ] [inding.sonoff.internal.MainDiscovery] - Discovered device 10002a293f
2021-03-20 17:11:23.403 [ERROR] [inding.sonoff.internal.MainDiscovery] - Unable to add 10002a293f as its not supported, please forward the cache file to the developer

Send me the file under userdata/sonoff

Dave hi
Upgraded to r18 , there is progress. As you see in the picture it shows voltage 2.800 V

Now the problem is shifted in the log , where battery voltage in the past appeared with 3 decimals i.e. 2.813, now appears truncated 2.8 as you can see in the log below and it only adds two zeros in UI formatting. We are getting there , Thanks , Dimitri.


That’s correct.
The current value is 2.8 in the log (that’s the data straight from the device unchanged) so the .3 decimal places adds 2 zeros
If it were 2.813 then it would show 2.813

Thanks Dave I will monitor. Sorry to have bothered you soooo much.

That’s cool, need to sort the bugs out :+1:
Are temp and humidity all good now?
And switches working?

The thing status is still a bit buggy (need to look at), as there is quite a bit going on -
account: online/offline
Device: lan/api/websocket online/offline
But it works alright for now.

Switches are working fine. I will test other channels too.

Is there any difference between mainSwitch and switch? Pointless having both it they do the same.
See something in your previous post regarding the gpio but not sure as I don’t have to test

Dave you are probably referring to another post. I do not use GPIO

It was in the link you put up when reading through it. Something to do with the led on the device and one of the two channels keeping it sync as the other didn’t affect the gpio output to the led (think the switch status led)

Hmm… come to think may have been @Emre7

Something to do with the led on the device

…I do not use led s , I only have Sonoff DW2 wifi .DoorTrap…
The person involved will definitely get back to you

I’ve sent a PM with a TXT, please let me know if it’s the right file thanks

@enrico.mcc yep got it. Might be able to get it added tonight for you, only a simple 1 channel relay :+1:

What is it branded as / model? So I can update the docs (the api doesn’t give me retail type names)

Awesome thank you!! :metal:
on the box it’s called “Sonoff Basic”
It’s quite old, probably I bought it 3 years ago and left into a drawer… until I saw your binding :grin:

@enrico.mcc SonoffJars/org.openhab.binding.sonoff-2.5.13-SNAPSHOT_v2.1r19.jar at main · delid4ve/SonoffJars · GitHub

Local and cloud mode supported on that device.
Can add it manually now (file already created) or run discovery again.

Hi @delid4ve , no change in R18, I still can’t control the switch on TH16R2.
For temperature, it seems fixed, but now it shows temperature in Kelvins, like 27.1 K, instead of degrees centigrade. Humidity also missed the % at the end of number.

10:31:24.269 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'KidsSensor_Temperature' changed from 27.1 K to 27.3 K
10:31:24.270 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'KidsSensor_Humidity' changed from 56 to 5

Using R18, here are the logs:
When I trun the switch on:

10:26:48.297 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'KidsSensor_Switch' received command ON
10:26:48.299 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'KidsSensor_Switch' predicted to become ON
10:26:48.303 [DEBUG] [noff.internal.handler.HandlerBaseDual] - Sonoff - Command Payload:{"switch":"on"}
10:26:48.304 [DEBUG] [ff.internal.messaging.MessageProvider] - Message Type added: 1616308008304 - switch
10:26:48.306 [DEBUG] [onoff.internal.handler.HandlerAccount] - Sending message via LAN
10:26:48.307 [DEBUG] [nding.sonoff.internal.connections.Lan] - Send LAN Update to with unencrypted payload:{"switch":"on"}
10:26:48.316 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'KidsSensor_Switch' changed from OFF to ON
10:26:48.495 [DEBUG] [nding.sonoff.internal.connections.Lan] - Lan response received: {"seq":1475,"sequence":"1616308008304","error":422}

When I change Account Thing to Cloud and then try to turn on the switch:

10:29:42.645 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'sonoff:15:cb2dcbbe6e:1000aed035' changed from ONLINE: Cloud Only to ONLINE
10:29:53.674 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'KidsSensor_Switch' received command ON                                                 
10:29:53.676 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'KidsSensor_Switch' predicted to become ON                                              
10:29:53.678 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'KidsSensor_Switch' changed from OFF to ON                                              
10:29:53.679 [DEBUG] [noff.internal.handler.HandlerBaseDual] - Sonoff - Command Payload:{"switch":"on"}
10:29:53.682 [DEBUG] [ff.internal.messaging.MessageProvider] - Message Type added: 1616308193682 - switch
10:29:53.683 [DEBUG] [onoff.internal.handler.HandlerAccount] - Sending message via Cloud
10:29:53.684 [DEBUG] [sonoff.internal.connections.Websocket] - Websocket Sending Message:{"action":"update","apikey":"ac1d2c64-7e8f-41d6-b857-d51133d1c4e4","userAgent":"app","sequence":1616308193682,"params":{"switch":"on"},"deviceid":"1000aed035","tempRec":""}
10:29:53.902 [DEBUG] [ff.internal.messaging.MessageProvider] - Websocket received message: {"error":0,"deviceid":"1000aed035","apikey":"ac1d2c64-7e8f-41d6-b857-d51133d1c4e4","sequence":"1616308193682"}
10:29:53.905 [DEBUG] [ff.internal.messaging.MessageProvider] - Websocket response is not handled for type: switch, message: {"error":0,"deviceid":"1000aed035","apikey":"ac1d2c64-7e8f-41d6-b857-d51133d1c4e4","sequence":"1616308193682"}
10:29:53.907 [ERROR] [ff.internal.messaging.MessageProvider] - Websocket message didnt have any content
10:30:37.059 [DEBUG] [sonoff.internal.connections.Websocket] - Websocket Sending Message:ping
10:30:37.060 [DEBUG] [onoff.internal.handler.HandlerAccount] - Sonoff Connection Check Running
10:30:37.144 [DEBUG] [sonoff.internal.connections.Websocket] - Pong Response received

Correcting myself, in cloud mode, despite the websocket error message that a response is not handled, and that websocket message did not have any content, the response does not have any error code as I see, it does work as ewelink shows the switched state. So it’s now working in cloud mode.

But if I switch to “Cloud/Local” mode, it does not work again as it insists to try LAN:

10:53:23.111 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'KidsSensor_Switch' received command ON                                                 
10:53:23.112 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'KidsSensor_Switch' predicted to become ON                                              
10:53:23.115 [DEBUG] [noff.internal.handler.HandlerBaseDual] - Sonoff - Command Payload:{"switch":"on"}
10:53:23.116 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'KidsSensor_Switch' changed from OFF to ON
10:53:23.117 [DEBUG] [ff.internal.messaging.MessageProvider] - Message Type added: 1616309603117 - switch
10:53:23.118 [DEBUG] [onoff.internal.handler.HandlerAccount] - Sending message via LAN
10:53:23.119 [DEBUG] [nding.sonoff.internal.connections.Lan] - Send LAN Update to with unencrypted payload:{"switch":"on"}
10:53:23.141 [DEBUG] [nding.sonoff.internal.connections.Lan] - Lan response received: {"seq":1484,"sequence":"1616309603117","error":422}

I also tried mainSwitch and it is not doing anything, so I think it’s better if we remove the “mainSwitch” function from it and consider it a hardware button representation or LED state.

Cool I’ll remove this. I believe it must be there for the inner workings of the device (does it turn on in openhab if you turn the switch channel on?)

This is there just for me to see what other messages come back on the websocket (in case there’s anything I need for other devices) but I’ll make it a bit more intuitive

Yeah sorry forgot to change this to Celsius, will fix

There’s no preset unit for humidity afaik so I’ll add.

It shouldn’t be doing this now, I’ll have a look as I may have missed a line of code somewhere