Shelly Binding

Did you verified the latest build? This should be fixed.

https://github.com/markus7017/myfiles/blob/master/org.openhab.binding.shelly-2.5.0-SNAPSHOT.jar?raw=true

The following changes are made

  • German translation of groups/channels/UI messages (binding config doesn’t work yet)
  • Fix for LOW_BATTERY alarm
  • Fix input channels for Dimmer + RGBW2
  • Fix timing issue for protected devices changing thing type after setting the credentials
  • Change: Full meter for Plug (like Plug-S)
  • New option brightnessAutoOn in thing config to suppress Auto-ON for lights (e.g. dimmer)
  • Enhanced channel cache to keep switch state and value of the brightness channel as separate states to avoid log entries like OFF (state) followed by 0 (value)
  • Update lastUpdate channel only if some other meter/sensor data has changed → reduce logging
  • README updated, READMEbeta included in DEV repo (myfiles)

Please note: This is a DEV release

Hi,
As I’m Italian I have to wait to get up from the table these days :grimacing:
I’ll try it ASAP.

Thanks for you work and merry Christmas!

Merry Xmas all of you :christmas_tree::christmas_tree::christmas_tree:

hi,

I have successfully used the shelly binding with openhab 2.5 (Shelly HT and Shelly4pro). But I have a small problem with the Shelly HT. After I restart openhab, the Shelly HT things remain in the “UNKNOWN” state. Even if the sensor sends an update, the state of the things remains “UNKNOWN” and the sensor values are not displayed/updated. The only way I can fix the problem is to manually activate the Shelly HT and manually “reactivate” the Shelly Things.
Does anyone know if there is another way to fix the problem?

This is not normal. The thing should stay Initializing until the next event is processed and then switch to ONLINE

which build are you using?
what’s shown in the logfile?

  1. binding-shelly - 2.5.0

  2. openhab.log shows the following, although I do not know if they are relevant. Otherwise, events.log and openhab.log show nothing regarding the Shelly HTs:

2019-12-25 17:35:17.389 [WARN ] [org.eclipse.jetty.server.HttpChannel] - /rest/events
javax.servlet.ServletException: javax.servlet.ServletException: A MultiException has 1 exceptions. They are:

  1. java.lang.IllegalStateException: ServiceLocatorImpl(__HK2_Generated_2,3,19320965) has been shut down

     at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:88) ~[bundleFile:?]
     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135) ~[bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
     at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
     at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
    

Caused by: javax.servlet.ServletException: A MultiException has 1 exceptions. They are:

For testing I have created a new Shelly HT Thing. The status goes instantly to “UNKNOWN”. I can’t see anything in the log. When removing it there is the following message:

2019-12-25 19:20:49.809 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:d73573b0’ changed from UNKNOWN to REMOVING
2019-12-25 19:20:49.818 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:d73573b0’ changed from REMOVING to REMOVED
2019-12-25 19:20:49.859 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:d73573b0’ changed from REMOVED to UNINITIALIZED
2019-12-25 19:20:49.899 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:d73573b0’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

try this build:
https://github.com/markus7017/myfiles/blob/master/org.openhab.binding.shelly-2.5.0-SNAPSHOT.jar?raw=true

It shows the same behaviour. But I found log entries now (they appeared earlier too). Interesting is that the status of Shelly4Pro also shows “UNKNOWN” first, but then goes to the status “ONLINE”:

2019-12-25 21:36:31.278 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:97247717’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.312 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:97247717’ changed from INITIALIZING to UNKNOWN
2019-12-25 21:36:31.321 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:b4fa05dd’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.338 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:b4fa05dd’ changed from INITIALIZING to UNKNOWN
2019-12-25 21:36:31.346 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:8f096f99’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.368 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:8f096f99’ changed from INITIALIZING to UNKNOWN
2019-12-25 21:36:31.377 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:6d9f9601’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.396 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:6d9f9601’ changed from INITIALIZING to UNKNOWN
2019-12-25 21:36:31.431 [hingStatusInfoChangedEvent] - ‘shelly:shelly4pro:1128feb0’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.454 [hingStatusInfoChangedEvent] - ‘shelly:shelly4pro:1128feb0’ changed from INITIALIZING to UNKNOWN
2019-12-25 21:36:31.467 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:af54f3ba’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.489 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:af54f3ba’ changed from INITIALIZING to UNKNOWN
2019-12-25 21:36:31.506 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:4906561d’ changed from UNINITIALIZED to INITIALIZING
2019-12-25 21:36:31.528 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:4906561d’ changed from INITIALIZING to UNKNOWN

2019-12-25 21:36:34.781 [hingStatusInfoChangedEvent] - ‘shelly:shelly4pro:1128feb0’ changed from UNKNOWN to ONLINE

I completely removed setting status to UNKNOWN
Are you sure you are using the correct jar?

How do you install the binding - you can’t do this with PaperUI when using a DEV release, see above.

Did you deleted the things & cleaned the cache before copying this build to the addons folder?

I try it now on a new openhab2 installation. No bindings activated. I have the following error log entries:

2019-12-25 22:45:53.541 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.shelly-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.shelly [203]
Unresolved requirement: Import-Package: org.eclipse.californium.core; version="[2.0.0,3.0.0)"

    at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

you need to follow the instructions:

Installed the latest dev build, no error so far, and the LOW_BATTERY alarm bug has gone :+1:

For others who want to install manually the latest build, to install californium libs you need to issue this command inside karaf console:

feature:install openhab-transport-coap
1 Like

Hi,
I have quite a few shelly devices and the binding works perfectly.
I have one suggestion, is it possible to reduce the number of updates by defining a minimum value change ?
right now my log is full with item state change messages like this one :

Shelly1PMBedroom_Meter_Watt changed from 1.9 to 1.93

but in reality there is no real change in the value.

thanks,

This is your event.log file and an absolut normal behavior. Why is there a need for reducing the entries, as this file is not to be looked at regulary?

Since there is no real data in these messages, I’m just trying to reduce the log size and number of writes to the flash memory.

Just increase status update interval in Thing configuration. Default is 60 seconds.

1 Like

The same behavior with the SNAPSHOT release. The THINGS remain now in status INITIALIZING. Here the logs:

2019-12-26 10:51:24.823 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:f03474d3’ changed from INITIALIZING to REMOVING
2019-12-26 10:51:24.831 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:f03474d3’ changed from REMOVING to REMOVED
2019-12-26 10:51:24.864 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:f03474d3’ changed from REMOVED to UNINITIALIZED
2019-12-26 10:51:24.886 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:f03474d3’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2019-12-26 10:51:28.878 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:fa03d2f3’ changed from ONLINE to UNINITIALIZED
2019-12-26 10:51:28.902 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:fa03d2f3’ changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2019-12-26 10:51:30.336 [hingStatusInfoChangedEvent] - ‘shelly:shellyht:fa03d2f3’ changed from UNINITIALIZED (DISABLED) to INITIALIZING

2019-12-27 12:02:46.194 [DEBUG] [elly.internal.api.ShellyEventServlet] - CallbackServlet: HTTP/1.1 Request from 192.168.199.55:39356/shelly/event/shellyht-58ea93/sensordata?{hum=[44],temp=[20.12]}
2019-12-27 12:02:46.197 [TRACE] [elly.internal.api.ShellyEventServlet] - Process event of type type=sensordata for device shellyht-58ea93, index=
2019-12-27 12:02:46.198 [TRACE] [shelly.internal.ShellyHandlerFactory] - Dispatch event to device handler shellyht-58ea93

What are you trying? / What is the issue?

I was able to reproduce the problem you reported and fixed it.
Expected behaviour:

  • HT has been discovered and was added as a thing then OH was restarted
  • Binding tries to initialize the thing, which fails, because the device is in suspend mode
  • The things stays in state INITIALIZING
  • waking up the device will trigger a sensor event
  • which is processed by the binding and triggers thing initialization
  • the binding initializes the thing, updates values and thing goes ONLINE
    verified that with a HT.

When I see " changed from INITIALIZING to REMOVING" in you log it indicates that you deleted the thing, which is a different use case.

To make the recovery working you need to successfully discover add the thing at least once so the binding was able to set the callback URLs / Coap destination being able to received an event on the next wakeup.

Please provide a TRACE log if you still have issues

  • open OH console, run “log:set TRACE org.openhab.binding.shelly”
  • wake-up device, discovery thing, add thing, wait until ONLINE
  • wait until device goes to sleep mode
  • restart OH, wait until initialized
  • wakeup device (should trigger an event)
  • thing should go ONLINE after some seconds

i have a question about the button events.
i have connected a motion detector and activated the events in the thing definition.

Thing shelly:shelly25-relay:xxxxxx "EgHaustuer" [deviceIp="1xx.xxx.xxx.xxx", userId="", password="", eventsButton=true, eventsPush=true, eventsSwitch=true]

the motion detector reports a long impulse. this is always transmitted after approx. 3s as event “LONG_PRESSED”. however, i would like to switch on the light immediately after switching the motion detector. how can this be implemented so that “LONG_PRESSED” is not waited for, but the triggering of the motion detector is immediately detected?