You are writing:
The DW2 is cloud only Iâm afraid so unfortunately has to go through the ewelink servers
But what does this mean, is this only initially or is this permanently connected to the chinese servers?
What is required from these chinese servers, is these only login data or what else are you grabbing for OH to work?
The binding logs in to the Api and then the Websocket on startup. (credentials sent via https and wss so both are secure)
This is repeated every 12 hours (at present but I am testing longer intervals) to refresh the access tokens or when the connection drops out (lose internet, open ewelink app etc)
The websocket is a permanent open secure connection in order to receive instant updates. Since the DW2 doesnt have LAN functionality this is the only way to get the data (no different to the app on your phone)
This is amazing!
Thank you delid4ve.
I have followed your instructions. I am on Openhab 2.5.x
Have a Sonoff TH16.
I am able to read the temperature correctly.
Works like a charm
Hi again,
I have an observation with regards to the TH16 behavior to confirm that it is working as intended.
When I added the TH as an thing, i got a proper temperature reading. Having checked after, the temperature did not change. When I logged in to the Ewelink app and refreshed, the temp reading got updated (I see the logic in this case that it is connected to the cloud, though it would defeat the purpose that I have to open the Ewelink app for it to refresh rendering it unusable).
I tried setting in the the Sonoff thing to work only in LAN mode, the TH16 went offline (that is seems to only communicate via cloud).
Question this is how it is meant to be?
I mean the TH16 only works online and will refresh only when refreshing from the app.
@espresso can you enable debug logging for me and send me the logs over a period of time. Also check if you have any websocket errors in your current logs.
The thing status has some bugs atm which iâm in the process of sorting out but the status should update regardless.
Iâm not sure what the change difference has to be for the web socket to get an update on the TH16 either as i dont own, it may be 1 degree, it may be 0.1 degree. it should still get updated every 60 seconds regardless though when the api is called.
@delid4ve
I Updated the binding as suggested, the temperature reading go reflected immediate in the Sonoff TH16 Thing.
I then changed âSonoff Account Thingâ 's âAccess Modeâ to âLocal onlyâ, the Sonoff TH16 thing went âOFFLINEâ.
In this mode the temperature (in the background) changed from 59.3 C to 58.7 C but did not update the TH16 openhab temp reading.
âCloud connectedâ value was showing as âDisconnectedâ
Waited 15 minutes but the temperature did not update. I can say âLocal onlyâ mode does not seem to work.
I then changed Sonoff Account Thing âAccess Modeâ to âCloud and Localâ, the Sonoff TH16 Thing went immediately online, after around 30 seconds the Temperature got update to 58.7 C, and âCloud connectedâ after a refresh showed âConnectedâ
I think it is a better behavior than before, the temperature reading is updating more frequently, I will monitor tomorrow and drop an update.
Is the device on a network subnet that openhab also has access to? Either on the same subnet or a subnet that is also defined on another nic that openhab is running on. Local uses multicast so if the above is true also check that multicast is enabled in your router.
Itâs not getting an ipaddress come back from multicast (hence offline)
The cloud connection will go online for the device but then streaming data will take up to 60 seconds before it becomes active for the first time
Really need the debug logs to see whatâs going on with the local connection, without them Iâm not going to be able to help further.
@delid4ve
logs below, it is not an issue of multicast from the routerâs side (checked the settings)
2021-03-31 10:10:17.874 [DEBUG] [nternal.handler.SonoffAccountHandler] - Initialising Sonoff Account: sonoff:account:xxxxxx
2021-03-31 10:10:17.877 [DEBUG] [nternal.handler.SonoffAccountHandler] - Setting credentials
2021-03-31 10:10:17.879 [DEBUG] [nternal.handler.SonoffAccountHandler] - Clearing current message queue
2021-03-31 10:10:17.881 [DEBUG] [nternal.handler.SonoffAccountHandler] - Loading Device States
2021-03-31 10:10:18.077 [DEBUG] [internal.states.SonoffStateUtilities] - Added new state for device 1000aece9e
2021-03-31 10:10:18.081 [DEBUG] [nternal.handler.SonoffAccountHandler] - Starting the message Queue
2021-03-31 10:10:18.085 [DEBUG] [nternal.handler.SonoffAccountHandler] - Setting Mode Change Listeners
2021-03-31 10:10:18.087 [ERROR] [.connections.SonoffConnectionManager] - connection Manager mode changed to : local
2021-03-31 10:10:18.094 [DEBUG] [.connections.SonoffConnectionManager] - Connection Check Running for local mode
2021-03-31 10:10:18.155 [DEBUG] [rnal.connections.SonoffLanConnection] - mDNS service has been started on IP 127.0.0.1
2021-03-31 10:10:18.230 [DEBUG] [rnal.connections.SonoffLanConnection] - mDNS service has been started on IP xxx.xxx.xx.xx
2021-03-31 10:10:18.232 [DEBUG] [.connections.SonoffConnectionManager] - Local Mode connected
2021-03-31 10:10:18.236 [DEBUG] [nternal.handler.SonoffAccountHandler] - Creating scheduled taks to run the queue
2021-03-31 10:10:18.241 [DEBUG] [ernal.messaging.SonoffCommandManager] - Message queue running
2021-03-31 10:10:18.255 [DEBUG] [nternal.handler.SonoffAccountHandler] - Creating refresh tasks
2021-03-31 10:10:18.299 [DEBUG] [nternal.handler.SonoffAccountHandler] - Setting an initial status
2021-03-31 10:10:18.630 [DEBUG] [ernal.messaging.SonoffCommandManager] - Lan event received from xxx.xxx.xx.xx -- note it found the correct IP of the TH16
2021-03-31 10:10:18.786 [ERROR] [ernal.messaging.SonoffCommandManager] - Cannot forward state for 1000aece9e, listener not present
2021-03-31 10:10:18.867 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'sonoff:15:da2f3c07:1000aece9e': org.openhab.binding.sonoff.internal.handler.SonoffAccountHandler cannot be cast to org.openhab.binding.sonoff.internal.handlers.HandlerAccount
java.lang.ClassCastException: org.openhab.binding.sonoff.internal.handler.SonoffAccountHandler cannot be cast to org.openhab.binding.sonoff.internal.handlers.HandlerAccount
at org.openhab.binding.sonoff.internal.handlers.lansupported.HandlerBaseDual.getAccountHandler(HandlerBaseDual.java:114) ~[?:?]
at org.openhab.binding.sonoff.internal.handlers.lansupported.HandlerBaseDual.initialize(HandlerBaseDual.java:59) ~[?:?]
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_275]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
2021-03-31 10:10:20.163 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.sonoff.internal.handlers.lansupported.Handler15@3f5b7125': org.openhab.binding.sonoff.internal.handler.SonoffAccountHandler cannot be cast to org.openhab.binding.sonoff.internal.handlers.HandlerAccount
java.lang.ClassCastException: org.openhab.binding.sonoff.internal.handler.SonoffAccountHandler cannot be cast to org.openhab.binding.sonoff.internal.handlers.HandlerAccount
at org.openhab.binding.sonoff.internal.handlers.lansupported.HandlerBaseDual.getAccountHandler(HandlerBaseDual.java:114) ~[?:?]
at org.openhab.binding.sonoff.internal.handlers.lansupported.HandlerBaseDual.initialize(HandlerBaseDual.java:59) ~[?:?]
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_275]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
2021-03-31 10:10:20.358 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'sonoff:15:da2f3c07:1000aece9e': org.openhab.binding.sonoff.internal.handler.SonoffAccountHandler cannot be cast to org.openhab.binding.sonoff.internal.handlers.HandlerAccount
java.lang.ClassCastException: org.openhab.binding.sonoff.internal.handler.SonoffAccountHandler cannot be cast to org.openhab.binding.sonoff.internal.handlers.HandlerAccount
at org.openhab.binding.sonoff.internal.handlers.lansupported.HandlerBaseDual.getAccountHandler(HandlerBaseDual.java:114) ~[?:?]
at org.openhab.binding.sonoff.internal.handlers.lansupported.HandlerBaseDual.initialize(HandlerBaseDual.java:59) ~[?:?]
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_275]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]
2021-03-31 10:10:20.528 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = 'p'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2691) ~[?:1.8.0_275]
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720) ~[?:1.8.0_275]
at java.util.Formatter.parse(Formatter.java:2560) ~[?:1.8.0_275]
at java.util.Formatter.format(Formatter.java:2501) ~[?:1.8.0_275]
at java.util.Formatter.format(Formatter.java:2455) ~[?:1.8.0_275]
at java.lang.String.format(String.java:2961) ~[?:1.8.0_275]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:168) ~[?:?]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) ~[bundleFile:?]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]
2021-03-31 10:10:21.539 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = 'p'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2691) ~[?:1.8.0_275]
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720) ~[?:1.8.0_275]
at java.util.Formatter.parse(Formatter.java:2560) ~[?:1.8.0_275]
at java.util.Formatter.format(Formatter.java:2501) ~[?:1.8.0_275]
at java.util.Formatter.format(Formatter.java:2455) ~[?:1.8.0_275]
at java.lang.String.format(String.java:2961) ~[?:1.8.0_275]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:168) ~[?:?]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) ~[bundleFile:?]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]
2021-03-31 10:10:22.550 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = 'p'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2691) ~[?:1.8.0_275]
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720) ~[?:1.8.0_275]
at java.util.Formatter.parse(Formatter.java:2560) ~[?:1.8.0_275]
at java.util.Formatter.format(Formatter.java:2501) ~[?:1.8.0_275]
at java.util.Formatter.format(Formatter.java:2455) ~[?:1.8.0_275]
at java.lang.String.format(String.java:2961) ~[?:1.8.0_275]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:168) ~[?:?]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) ~[bundleFile:?]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]
the last few error lines not sure if they are related or not to your binding. Let me know if you need more info
Thank you
@delid4ve
Did as instructed, too time for openhab to start and rebuild the screen but still same result
on Local mode Th16 thing still showing offline.
Any other suggestions?
I had checked before in the ewelink app and couldnât find the setting for LAN control noting before there was an option. I believe in the recent updates of the app they have removed it.
I had checked online and it seems this has been removed but enabled in the back ground by default this way if a user does not choose LAN control and internet goes down, the user would still be able to use the app.
Screen shots for the TH16 settings below.