Ewelink / Sonoff Binding - New binding without flashing

@delid4ve I appreciate your contributions so no worries. I upgraded to 2.5R7 and it appears that the cloud only connection is working now as well as R1D1 is now being recognized when I scanned. I do have several questions.

  • What upgrade sonoff jar files, is there a best practice on restarting the binding? I replaced the old one with 2.5R7 but although things were showing online, I was getting null values. Values started populating when I rebooting the OS.
  • For R1D1, I noticed a number of anomalies. When the brightness value is changed in OH, the sonoff device turns on but the mobile app does not match the brightness value. Also, the switch thing does not change state when the brightness level is changed within OH. Finally, any changes on the mobile app are not reflected in OH; even after a period of time. The following screenshot shows brightness set to 50% and the switch is off but in the mobile app, the device is on with brightness level of 100%

Try this. The light type devices behave in a strange way, and its different across different types of lights/leds/dimmers.

Hopefully this sorts it but have another handler i can try if not.

You will have to delete the device and readd. also stop/start openhab

2.5R10: https://github.com/delid4ve/openhab-sonoff-compiled/blob/main/org.openhab.binding.sonoff-3.2.0-SNAPSHOT_2.5R10.jar
also has fix for TH10/16 devices not sending switch command in mixed mode

@delid4ve 2.5r10 exhibits the same behavior. I do want to state that I’m doing only cloud-connected in the account thing. The devices are located in another site in different subnet than OH. So I removed and deleted the SONOFF items and then deleted all SONOFF things. I then removed the 2.5r7 jar file and restarted OH3. I then added the 2.5r10 and then manually added the account thing. Once that was online, I then went back add scanned for the items. Interesting thing to note is that I have two homes and it only discovered the devices on the home I set in the mobile app. Anyways, I added items but noticed that items were null so I restarted OH3. The switch setting operates fine but the dimer and RF values do not get populated. Also, changing the dimmer value will turn on the device but the values do not sync.

@delid4ve I replaced the previous JAR with the new one and I tried to scan but after it I do not have any thing added.

Cache does not have any file:

image

I’m using the Docker

I’ve installed a new docker. Created a new account. Added the binding
I’m able to add the account thing but it continues to swap between erorr and connected:

I get his in the log:

After I reset username and password (again) :slight_smile: I got

but still no scan

Will revisit tomorrow guys as ill have some time again.
@tdlr can you send me the cache file for the device if its not on here already (userdata/sonoff
@msavazzi have you tried clearing the openhab cache (remove things/items first), then restarting a couple of times (to be sure)
@fisker - did it work ok in the end?

@delid4ve Hi, yes everything is working fine after your fixes. Thanks a lot.

@delid4ve, I have OH3 running in a debian OS so are the cache files located at /var/lib/openhab/sonoff? Also, do you want me to upload the text file here?

I’ve tried even destroying the container and starting from scratch.
not working :frowning:
Question: my openhab is not in the same net of the devices.
Openhab is on a 10.xx and the devices are 198.xx
The networks do have visibility but could this be a problem?

Discovery (scan) will not work over different ip subnets.

Great binding - thanks @delid4ve. I’m using with OH3.1 to connect to the Sonoff Bridge. Just started with a Temperature/humidity sensor to start with, but that was just an inexpensive start to check things worked out. Looks great - thanks again.

BTW I may have been a bit slow, but it took a while before I realised where to find your pre-compiled jars. Now I know where they are, but maybe a link from the Setup section in the main GitHub page Readme (https://github.com/delid4ve/openhab-3.x-sonoff#readme) to https://github.com/delid4ve/openhab-sonoff-compiled would have saved me trawling through the main repo searching for them!

Also, I know many references are included amongst the 600+ posts to the need to add Things through the Things tab and not Settings > Addons > Bindings might be worth adding to the Readme. Sorry if I’ve missed it.

Thanks again.

Hi @delid4ve, thanks for making this binding great.

I have noticed this behavior. Sometimes all my sonoff items are not responding from openhab. I tried from ewelink app they work correct. Also my other things in openhab that are not sononff they work correct
Can you check please log below

After i change account thing from local to cloud and local or vise versa everything comes back to normal.

P.S i will send full log in DM. You will see details

23:14:11.345 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'LightSWLivingroom_Switch0' received command ON
23:14:11.347 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'LightSWLivingroom_Switch0' predicted to become ON
23:14:11.350 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LightSWLivingroom_Switch0' changed from OFF to ON
23:14:11.360 [DEBUG] [ernal.handler.SonoffBaseDeviceHandler] - Sonoff - Command Payload:org.openhab.binding.sonoff.internal.dto.commands.MultiSwitch@69e22c1
23:14:11.361 [DEBUG] [munication.SonoffCommunicationManager] - Added a message to the queue
23:14:11.361 [DEBUG] [munication.SonoffCommunicationManager] - Sending message via LAN
23:14:11.362 [DEBUG] [ternal.connection.SonoffLanConnection] - Sending LAN Update to http://192.168.0.8:8081/zeroconf/switches
23:14:11.445 [DEBUG] [ternal.connection.SonoffLanConnection] - Lan response received: {"sequence":"1635110051361","seq":3,"error":400,"encrypt":true}
23:14:11.546 [DEBUG] [munication.SonoffCommunicationManager] - Message queue is running
23:14:14.635 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'LightSW2Livingroom_Switch1' received command ON
23:14:14.637 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'LightSW2Livingroom_Switch1' predicted to become ON
23:14:14.640 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'LightSW2Livingroom_Switch1' changed from OFF to ON
23:14:14.648 [DEBUG] [ernal.handler.SonoffBaseDeviceHandler] - Sonoff - Command Payload:org.openhab.binding.sonoff.internal.dto.commands.MultiSwitch@42bd03a8
23:14:14.649 [DEBUG] [munication.SonoffCommunicationManager] - Added a message to the queue
23:14:14.649 [DEBUG] [munication.SonoffCommunicationManager] - Sending message via LAN
23:14:14.650 [DEBUG] [ternal.connection.SonoffLanConnection] - Sending LAN Update to http://192.168.0.5:8081/zeroconf/switches
23:14:15.651 [WARN ] [munication.SonoffCommunicationManager] - Ok message not received for transaction: 1635110054649, command was switches, retrying again. Retry count 2
23:14:15.752 [DEBUG] [munication.SonoffCommunicationManager] - Message queue is running
23:14:15.753 [DEBUG] [munication.SonoffCommunicationManager] - Sending message via LAN
23:14:15.754 [DEBUG] [ternal.connection.SonoffLanConnection] - Sending LAN Update to http://192.168.0.5:8081/zeroconf/switches

@delid4ve sorry to bother but I feel very depressed.
I was able to move the virtual machine on the correct lan.
Reinstalled everything
Sonoff is visible
I add credentials and it does log on

but when I scan nothing happens, nothing appears

here


I have this isn the log


2021-10-30 13:43:46.519 [INFO ] [e.automation.internal.RuleEngineImpl] - Rule engine started.
2021-10-30 13:57:42.019 [INFO ] [nternal.handler.SonoffAccountHandler] - Sonoff Access Mode set to: mixed
2021-10-30 14:00:33.104 [ERROR] [unication.SonoffCommunicationManager] - The device 1001045469 doesnt exist, unable to set state
2021-10-30 14:00:33.813 [ERROR] [unication.SonoffCommunicationManager] - The device 1001045469 doesnt exist, unable to set state
2021-10-30 14:00:34.055 [ERROR] [unication.SonoffCommunicationManager] - The device 1001045469 doesnt exist, unable to set state
2021-10-30 14:00:34.087 [ERROR] [unication.SonoffCommunicationManager] - The device 1001045469 doesnt exist, unable to set state

What am still doing wrong?
How can I debug it? it remains Online stable now but no scan.

  • Platform information:
    • Hardware: Raspberry Pi 4 Model B Rev 1.2, 4GB RAM,
    • OS: Linux 5.4.51-v7l+
    • Java Runtime Environment:
      • openjdk version “1.8.0_265”
      • OpenJDK Runtime Environment (Zulu 8.48.3.246-CA-linux_aarch32hf) (build 1.8.0_265-b11)
      • OpenJDK Client VM (Zulu 8.48.3.246-CA-linux_aarch32hf) (build 25.265-b11, mixed mode)
    • openHAB version: openHAB 2.5.8-1
  • Issue of the topic: I executed following steps:
  1. Copy the file from github to /usr/share/openhab2/addons
  2. renamed the file to org.openhab.binding.sonoff.jar
  3. In the console

sudo chown openhab org.openhab.binding.sonoff.jar
sudo chgrp openhab org.openhab.binding.sonoff.jar

  1. crated a bridge/things file

Bridge sonoff:account:uniqueName “Sonoff Account” @ “other”
[ email=“myEmail”, password=“myPassword”,accessmode=“cloud”]

I have a Sonoff model 4CHPROR3, but nothing appear in the inbox and I am not able to force a new discovery.

I did tried to change the contents of the .things file by adding code found everywhere, but nothing works.
Let me report the logs here:

2021-10-31 21:26:48.294 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sonoff.things'

2021-10-31 21:26:48.344 [DEBUG] [nternal.handler.SonoffAccountHandler] - Initialising Sonoff Account: sonoff:account:uniqueName

2021-10-31 21:26:48.347 [INFO ] [nternal.handler.SonoffAccountHandler] - Sonoff Access Mode set to: cloud

2021-10-31 21:26:48.351 [DEBUG] [unication.SonoffCommunicationManager] - Message queue is running

2021-10-31 21:26:48.352 [DEBUG] [ernal.connection.SonoffApiConnection] - Api Login Request:{"email":"myEmail","password":"myPassword","countryCode":"+1"}

2021-10-31 21:26:48.324 [hingStatusInfoChangedEvent] - 'sonoff:account:uniqueName' changed from UNINITIALIZED to INITIALIZING

2021-10-31 21:26:50.034 [DEBUG] [ernal.connection.SonoffApiConnection] - Api Login Response:{"error":10004,"msg":"request redirection","data":{"region":"eu"}}

2021-10-31 21:26:50.037 [DEBUG] [ernal.connection.SonoffApiConnection] - Api Login Request:{"email":"myEmail","password":"myPassword","countryCode":"+1"}

2021-10-31 21:26:51.194 [DEBUG] [ernal.connection.SonoffApiConnection] - Api Login Response:{"error":0,"msg":"","data":{"user":{"accountLevel":10,"countryCode":"+41","email":"myEmail","apikey":"7b1e30f3-452a-4fd3-aa52-b20f32d4336b","accountConsult":false,"appVersion":"4.16.1","denyRecharge":false,"ipCountry":"CH"},"at":"1e05db3f1b6dcfc710754b85d407c3bde52b0eda","rt":"243c8309661ae3fecf7990516d0231755ca0ed19","region":"eu"}}

2021-10-31 21:26:51.197 [DEBUG] [l.connection.SonoffConnectionManager] - Api connected

2021-10-31 21:26:51.200 [DEBUG] [ernal.connection.SonoffApiConnection] - Attempt to get websocket server

2021-10-31 21:26:51.205 [DEBUG] [ernal.connection.SonoffApiConnection] - Websocket URL Request:{"appid":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"AE6iK9LN","ts":1635712011204,"version":8,"accept":"ws"}

2021-10-31 21:26:51.258 [DEBUG] [ernal.connection.SonoffApiConnection] - Websocket URL Response:{"port":8080,"IP":"3.120.166.65","reason":"ok","domain":"eu-pconnect7.coolkit.cc","error":0}

2021-10-31 21:26:51.814 [DEBUG] [connection.SonoffWebSocketConnection] - WebSocket Socket successfully connected to eu-pconnect7.coolkit.cc/3.120.166.65

2021-10-31 21:26:51.817 [DEBUG] [l.connection.SonoffConnectionManager] - Websocket connected

2021-10-31 21:26:51.823 [DEBUG] [connection.SonoffWebSocketConnection] - Websocket Sending Message:{"action":"userOnline","at":"1e05db3f1b6dcfc710754b85d407c3bde52b0eda","apikey":"7b1e30f3-452a-4fd3-aa52-b20f32d4336b","appid":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"Xwx183G3","ts":1635712011,"userAgent":"app","sequence":1635712011821,"version":8}

2021-10-31 21:26:51.894 [DEBUG] [connection.SonoffWebSocketConnection] - Login Response Received: {"error":0,"apikey":"7b1e30f3-452a-4fd3-aa52-b20f32d4336b","config":{"hb":1,"hbInterval":145},"sequence":"1635712011821"}

2021-10-31 21:26:52.279 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'sonoff.things'

2021-10-31 21:26:51.904 [hingStatusInfoChangedEvent] - 'sonoff:account:uniqueName' changed from INITIALIZING to ONLINE

2021-10-31 21:27:11.264 [DEBUG] [nternal.handler.SonoffAccountHandler] - Running Activation task

2021-10-31 21:27:11.266 [DEBUG] [connection.SonoffWebSocketConnection] - Websocket Sending Message:ping

2021-10-31 21:27:11.810 [DEBUG] [connection.SonoffWebSocketConnection] - Pong Response received

It seems to work, but I do not see the device which is connected, the 4CHPROR3.

I did tried to act on a local network by using the following .things file:

Bridge sonoff:account:uniqueName "Sonoff Account" @ "other" 
[accessmode="local"] {
}

In such a case, the outcome in the log is

2021-10-31 22:47:10.447 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sonoff.things'

2021-10-31 22:47:10.499 [DEBUG] [nternal.handler.SonoffAccountHandler] - Initialising Sonoff Account: sonoff:account:uniqueName

2021-10-31 22:47:10.502 [INFO ] [nternal.handler.SonoffAccountHandler] - Sonoff Access Mode set to: local

2021-10-31 22:47:10.505 [DEBUG] [unication.SonoffCommunicationManager] - Message queue is running

2021-10-31 22:47:10.513 [DEBUG] [ernal.connection.SonoffLanConnection] - mDNS service has been started on IP 127.0.0.1

2021-10-31 22:47:10.518 [DEBUG] [ernal.connection.SonoffLanConnection] - mDNS service has been started on IP 192.168.1.100

2021-10-31 22:47:10.527 [DEBUG] [l.connection.SonoffConnectionManager] - Lan connected

2021-10-31 22:47:10.481 [hingStatusInfoChangedEvent] - 'sonoff:account:uniqueName' changed from UNINITIALIZED to INITIALIZING

2021-10-31 22:47:10.539 [hingStatusInfoChangedEvent] - 'sonoff:account:uniqueName' changed from INITIALIZING to ONLINE


2021-10-31 22:47:10.852 [ERROR] [unication.SonoffCommunicationManager] - The device 100114c555 doesnt exist, unable to set state

2021-10-31 22:47:10.855 [DEBUG] [nternal.handler.SonoffAccountHandler] - Added IP Address 100114c555 for device 192.168.1.109

2021-10-31 22:47:11.556 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'sonoff.things'

2021-10-31 22:47:30.537 [DEBUG] [nternal.handler.SonoffAccountHandler] - Running Activation task

In addition, when a device’s button is press, the following debug message appears:

2021-10-31 22:50:26.407 [ERROR] [unication.SonoffCommunicationManager] - The device 100114c555 doesnt exist, unable to set state

2021-10-31 22:50:26.411 [DEBUG] [nternal.handler.SonoffAccountHandler] - Added IP Address 100114c555 for device 192.168.1.109

So the device is somehow connected, but I do not control it.
Do you have any advices on what it is happening and why the device is not visible or controllable?

I just realiazed that the binding was not showing up in Openhab. I did check all the docs and information around
 and in the end I realized that I downloaded the wrong binding (3.X instead 2.5.x). With the correct binding I am able to follow the procedure described above. I do not need to create the file .things anymore.

Hi,

First of all, let me thank you (and the all who contribute for this project) for your exelent work.
I tried on my home and it works with most of my sensors / actuators.

I have a Sonoff ZB bridge to capture door sensors, switches and PIR sensors and I created some rules to test automation. I start to notice that, from time to time (intervals of 2h) I receive a point from a ZB switch which triggers the automation rule on OH.
Some, do you have some refresh period on the binding code to send periodically the data or is it data sent from ewelink acount?

Thanks, in advance, for your time.

JoĂŁo Sousa

Guys can you help me please?
Why is that binding not showing up in OH2.5, do I need to update somehow?

Thanks

What do you mean with not showing up ?
Did you download and install the correct jar file ?

Download the jar file?
DonÂŽt know how to proceed with such a jar file.
Will there be no “official” binding via PaperUI?

No, there will be none. openHAB 2.5 is on feature freeze since last year

You need to download the jar file and copy it into your addons folder.

sorry to ask, but couldn®t find that s
 folder :slight_smile:
Can you help me? And when it is there, will it automatically be activated with next boot, or what?

Thanks