Shelly Binding

@markus7017 per your request I have attached my DEBUG/TRACE log for org.openhab.binding.shelly-3.4.0M3-SNAPSHOT.jar. FWIW I am using a Docker running OH3.4M5. I added org.openhab.binding.shelly-3.4.0M3-SNAPSHOT.jar after installing feature:install openhab-transport-coap. I only have 3 Shelly’s, One Shelly 2.5 which works fine and 2 Shelly1’s which will not go ONLINE (COMM ERROR). I have reverted back to OH3.3 as this is my production system for running the house and everything in OH3.3 works for my use case.

shelly_debug_startup_log.txt (272.0 KB)

Hi,
another question on ShellyEM. How often are Power Measurment Updated? I mean when shellyEM detect a power usage variation send data to OpenHab?

Thanks

Haha, nice one. To be honest, that idea never crossed my mind, because the batteries were said to be at 99 to 100% before the problem occured. I installed the sensors a month or two ago, so hopefully they are not drained yet.

The problem seems to be fixed, I’m going to explain my findings as a reply to Markus’ reply.

Hi Markus, thanks for your reply.

I’m using the sensor since a month or two, and they were upgraded to said firmware when they were installed.

I had the debug logs enabled yesterday, but saw nothing special. When I opened or closed a window, absolutely NOTHING happend even with debugs enabled.

Today, I looked into this a little bit further. I even reset one sensor to factory defaults, removed the Thing, added the sensor to my network and re-added the thing. No change. I then deleted the “State” item and re-created it. Still no change.

While looking through the web interface of the sensor, I saw under “Internet & Security > Advanced - Developer Settings”, that the CoIoT peer was set to “mcast”. This is the factory default. I checked against the only working sensor, but it had the same setting.

Then I checked against one Shelly TRV. This had the CoIoT peer set to “openHAB-IP:5683” - I think this was set by the binding when the TRV has been added as a thing.

Just to be sure, I configured the CoIoT peer on the D/W2 to “openHAB-IP:5683”, rebooted the sensor, and… everything worked like there was never a problem! :exploding_head:

I’m not really sure why “mcast” worked for some weeks and suddenly stopped working for 7 sensors out of 8, but I’m happy that it seems to work with the unicast setting. If the binding changes the setting for the TRVs, may be this could be done for D/W2, too?

The D/W2 which was still working is in the same room like my router (Fritz!Box), all other sensors connect through other Fritz! WLAN Mesh repeaters (according to the Fritz!Box GUI). May be this is part of the problem. I didn’t update the Fritz! devices recently.

Anyway, I left the still-working sensor on the “mcast” setting as a reference. If the same problem happens in the near future, it really might be a problem with the sensor’s firmware, but I know now how to solve the problem.

So, the problem seems to be fixed as of now, and my wife is happy again that the radiators are closed when a window is opened :slight_smile: W.A.F. increased :wink:

Markus, thanks for your support and the great binding. I’m waiting for the official release of openHAB 3.4 since I have one Shelly Plus H/T in my bathroom, but I’m too scared to upgrade to the 3.4 Milestones :fearful: :joy:

Hi all,

Just got a new Shelly Motion 2 delivered yesterday and have set up using the binding (in OH 3.3.0) and seems to be working OK except that it seems to be reporting a temperature of zero exactly 5 minutes after it reports an accurate temperature. The blind time for the sensor is set to 1 minute (on the Shelly itself) but I set the Status Interval in the Thing settings to be 300 seconds (i.e. 5 minutes), so think it might be related to that. Chart of data as follows:

The other values I track are lux and motion, both of which look fine.

Looking at the temperature value in the sensor’s own web UI it looks fine but I don’t think it’s possible to check what the value is exactly 5 mins after it reports a valid temperature - for a start I have no idea on what frequency it reports temperature (although it seems to be every 30 mins or so).

Any thoughts? Not sure how to enable debug but if you let me know then I’ll do that and see if it shows anything peculiar.

Thanks,

Ben

I updated from openhab stable 3.3.0 to 3.4.0.M5 and have now many problems with delays. Shelly Button 1 is not working anymore, I get only some updates after new connect. Same with door and windows shelly. And all my other shelly’s (1L) react very fast, when commanding but give status feedback even after many seconds (for example I switch on the light with shelly inputs and status feedback, that shelly switched on come several seconds later).

I think you can

  • create a group
  • add all brightness items to that group
  • create 1 dimmer item
  • create a rule when this item is changed to change the value of the group item
    OH will post the commands to all items in the group

yes, any update to the power meter should result into a CoAP packet, which updates the OH items instantly

mcast means Multicast. If that does not work anymore something happened on the network level blocking multicast to be received by openHAB - router / switch / firewall / host docker network settings. You could use Shelly Manager to verify/chage between Multicast and Peer Mode - or read the documentation :slight_smile: This is independent from the device type (DW2 or TRV), all Gen1 devices have the same mechanism, whereas Gen2 uses WebSocket communication instead of CoAP / CoIOT.

Check what happens when you change the interval.
The binding processes status updates from the device (send via CoAP) and does polling to make sure getting the correct value if the UDP-based CoAP update has been mixed.
Enable DEBUG log and you should see the updates.

The last PR is still review in progress = not part of M5.

Check the latest DEV build
org.openhab.binding.shelly-3.4.0M5-SNAPSHOT.jar

Hello @markus7017

The hint with mcast setting was the right thing. I configured all devices with peer setting and now all works correctly.

Thanks
Dave

Allterco launch the Shelly Plus Aden
https://www.shelly.cloud/en/products/shop/shelly-plus-add-on?utm_source=sendinblue&utm_campaign=New_Shelly_Product__New_Website_Launch!&utm_medium=email

Add-on for Shelly Plus devices

  • Can be used with up to five DS18B20 sensors or one DHT22 sensor
  • Has an analog and a digital input
  • DS18B20 - Temperature sensor (up to 5); please choose the product variant with or without (default variant ships without it)
  • DHT22 sensor- if you want to monitor temperature and humidity

shelly2-roller is not in 3.4.0.M5 too :frowning: will it be added in the future?

Thank you

Hi Markus: I tried the M5 dev-build on openhab 3.4M5.
The following Shellys seem to work finde: Shelly 2.5, Shelly Plus 1
Shelly 1 is not working. Here the log in debug mode when creating the thing.

Log
2022-12-03 16:41:41.139 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Shelly1-Toroeffner: Create new thing of type shelly:shelly1 using ShellyRelayHandler
2022-12-03 16:41:41.203 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Thing handler for uid shelly:shelly1:Shelly1-Toroeffner added, total things = 5
2022-12-03 16:41:41.207 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:Shelly1-Toroeffner' changed from UNINITIALIZED to INITIALIZING
2022-12-03 16:41:43.218 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Thing name derived from UID shelly:shelly1:Shelly1-Toroeffner
2022-12-03 16:41:43.220 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Using userId admin from bindingConfig
2022-12-03 16:41:43.221 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Device config: IP address=192.168.1.85, HTTP user/password=admin/***, update interval=60
2022-12-03 16:41:43.223 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Configured Events: Button: false, Switch (on/off): false, Push: false, Roller: true, Sensor: true, CoIoT: true, Enable AutoCoIoT: true
2022-12-03 16:41:43.225 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Start initializing for thing Shelly1-Toroeffner, type shelly1, IP address 192.168.1.85, Gen2: false, CoIoT: true
2022-12-03 16:41:43.478 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Unable to initialize: API Timeout for , retrying later
2022-12-03 16:41:43.226 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:Shelly1-Toroeffner' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.
2022-12-03 16:41:43.479 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:Shelly1-Toroeffner' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to OFFLINE (COMMUNICATION_ERROR): Unerwarteter Fehler - API Timeout for

I did feature:install openhab-transport-coap (in case that’s necessary). If you need more information please let me know.
I double checked again with the dev M3 binding. Here all my shellys are identified correctly.

Ok, so I changed the status interval to 600 and nothing seemed to change. I enabled debug and found that roughly every 30 minutes there’s a CoIoT message reporting the temperature (along with a couple of other items in the log), then a few minutes later there’s a single entry in the log where the temperature value of zero is recorded (log entries relating to the thing only below):

2022-12-03 21:03:00.692 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Message from /192.168.1.87:5683 (MID=353): {"G":[[0,3101,11.3],[0,3102,52.3],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]}
2022-12-03 21:03:00.692 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Sensor data {"G":[[0,3101,11.3],[0,3102,52.3],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]} (serial=353)
2022-12-03 21:03:00.692 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 9 CoAP sensor updates received
2022-12-03 21:03:00.694 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 11.3 °C (type class org.openhab.core.library.types.QuantityType).
2022-12-03 21:03:00.694 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 2 channels updated from CoIoT status, serial=353

2022-12-03 21:05:35.559 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 0 °C (type class org.openhab.core.library.types.QuantityType).

2022-12-03 21:33:01.717 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Message from /192.168.1.87:5683 (MID=354): {"G":[[0,3101,11.1],[0,3102,52.0],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]}
2022-12-03 21:33:01.717 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Sensor data {"G":[[0,3101,11.1],[0,3102,52.0],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]} (serial=354)
2022-12-03 21:33:01.718 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 9 CoAP sensor updates received
2022-12-03 21:33:01.719 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 11.1 °C (type class org.openhab.core.library.types.QuantityType).
2022-12-03 21:33:01.720 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 3 channels updated from CoIoT status, serial=354

2022-12-03 21:35:38.924 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 0 °C (type class org.openhab.core.library.types.QuantityType).

2022-12-03 22:04:00.717 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Message from /192.168.1.87:5683 (MID=355): {"G":[[0,3101,11.1],[0,3102,51.9],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]}
2022-12-03 22:04:00.718 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Sensor data {"G":[[0,3101,11.1],[0,3102,51.9],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]} (serial=355)
2022-12-03 22:04:00.718 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 9 CoAP sensor updates received
2022-12-03 22:04:00.719 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 11.1 °C (type class org.openhab.core.library.types.QuantityType).
2022-12-03 22:04:00.719 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 2 channels updated from CoIoT status, serial=355

2022-12-03 22:05:42.036 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 0 °C (type class org.openhab.core.library.types.QuantityType).

2022-12-03 22:34:01.705 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Message from /192.168.1.87:5683 (MID=356): {"G":[[0,3101,11.1],[0,3102,52.0],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]}
2022-12-03 22:34:01.705 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: CoIoT Sensor data {"G":[[0,3101,11.1],[0,3102,52.0],[0,6107,0],[0,3119,1670094796],[0,3120,1],[0,6110,0],[0,3106,0],[0,3111,100],[0,9103,5]]} (serial=356)
2022-12-03 22:34:01.706 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 9 CoAP sensor updates received
2022-12-03 22:34:01.707 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 11.1 °C (type class org.openhab.core.library.types.QuantityType).
2022-12-03 22:34:01.707 [DEBUG] [elly.internal.coap.ShellyCoapHandler] - shellymotion2-8cf681107741: 2 channels updated from CoIoT status, serial=356

2022-12-03 22:35:45.379 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellymotion2-8cf681107741: Channel sensors#temperature updated with 0 °C (type class org.openhab.core.library.types.QuantityType).

Any thoughts?

turn on TRACE log, I see only a timeout ehrn trying to connect to the device

please provide a DEUG log

Here the log in trace-mode. I filtered the messages of the corresponding Shelly-device. If you need other log entries please let me know.

log
2022-12-04 10:15:13.982 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Shelly1-Toroeffner: Create new thing of type shelly:shelly1 using ShellyRelayHandler
2022-12-04 10:15:14.038 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Thing handler for uid shelly:shelly1:Shelly1-Toroeffner added, total things = 5
2022-12-04 10:15:14.044 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:Shelly1-Toroeffner' changed from UNINITIALIZED to INITIALIZING
2022-12-04 10:15:16.057 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Thing name derived from UID shelly:shelly1:Shelly1-Toroeffner
2022-12-04 10:15:16.058 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Using userId admin from bindingConfig
2022-12-04 10:15:16.059 [TRACE] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: updateInterval = 60s -> skipCount = 20
2022-12-04 10:15:16.059 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Device config: IP address=192.168.1.85, HTTP user/password=..., update interval=60
2022-12-04 10:15:16.060 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Configured Events: Button: false, Switch (on/off): false, Push: false, Roller: true, Sensor: true, CoIoT: true, Enable AutoCoIoT: true
2022-12-04 10:15:16.061 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Start initializing for thing Shelly1-Toroeffner, type shelly1, IP address 192.168.1.85, Gen2: false, CoIoT: true
2022-12-04 10:15:16.063 [TRACE] [.shelly.internal.api1.Shelly1HttpApi] - Shelly1-Toroeffner: HTTP GET for http://192.168.1.85/shelly
2022-12-04 10:15:16.154 [TRACE] [.shelly.internal.api1.Shelly1HttpApi] - Shelly1-Toroeffner: HTTP Response 200: {"type":"SHSW-1","mac":"40F5201CD281","auth":false,"fw":"20221027-091427/v1.12.1-ga9117d3","discoverable":false,"longid":1,"num_outputs":1}
2022-12-04 10:15:16.156 [TRACE] [shelly.internal.api.ShellyHttpClient] - shelly1-shelly1-toroeffner: HTTP GET for http://192.168.1.85/settings
2022-12-04 10:15:16.231 [TRACE] [shelly.internal.api.ShellyHttpClient] - shelly1-shelly1-toroeffner: HTTP Response 200: {"device":{"type":"SHSW-1","mac":"40F5201CD281","hostname":"shelly1-40F5201CD281","num_outputs":1},"wifi_ap":{"enabled":false,"ssid":"shelly1-40F5201CD281","key":""},"wifi_sta":{"enabled":true,"ssid":"...","ipv4_method":"dhcp","ip":null,"gw":null,"mask":null,"dns":null},"wifi_sta1":{"enabled":false,"ssid":null,"ipv4_method":"dhcp","ip":null,"gw":null,"mask":null,"dns":null},"ap_roaming":{"enabled":false,"threshold":-70},"mqtt": {"enable":false,"server":"192.168.33.3:1883","user":"...","id":"shelly1-40F5201CD281","reconnect_timeout_max":60.000000,"reconnect_timeout_min":2.000000,"clean_session":true,"keep_alive":60,"max_qos":0,"retain":false,"update_period":30},"coiot": {"enabled":true,"update_period":15,"peer":""},"sntp":{"server":"192.168.1.1","enabled":true},"login":{"enabled":false,"unprotected":false,"username":"admin"},"pin_code":"","name":"Shelly1_gate","fw":"20221027-091427/v1.12.1-ga9117d3","factory_reset_from_switch":true,"discoverable":false,"build_info":{"build_id":"20221027-091427/v1.12.1-ga9117d3","build_timestamp":"2022-10-27T09:14:27Z","build_version":"1.0"},"cloud":{"enabled":false,"connected":false},"timezone":"Europe/Berlin","..."tzautodetect":true,"tz_utc_offset":3600,"tz_dst":false,"tz_dst_auto":true,"time":"10:15","unixtime":1670145317,"debug_enable":false,"allow_cross_origin":false,"ext_switch_enable":false,"ext_switch_reverse":false,"ext_switch":{"0":{"relay_num":-1}},"actions":{"active":false,"names":["btn_on_url","btn_off_url","longpush_url","shortpush_url","out_on_url","out_off_url","lp_on_url","lp_off_url","report_url","report_url","report_url","ext_temp_over_url","ext_temp_under_url","ext_temp_over_url","ext_temp_under_url","ext_temp_over_url","ext_temp_under_url","ext_hum_over_url","ext_hum_under_url"]},"hwinfo":{"hw_revision":"prod-191217", "batch_id":1},"mode" :"relay","longpush_time":3000,"relays":[{"name":null,"appliance_type":"General","ison":false,"has_timer":false,"default_state":"off","btn_type":"momentary","btn_reverse":0,"auto_on":0.00,"auto_off":1.00,"power":0.00,"schedule":false,"schedule_rules":[]}],"ext_sensors":null,"ext_temperature":null,"ext_humidity":{},"eco_mode_enabled":false}
2022-12-04 10:15:16.239 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-shelly1-toroeffner: Unable to initialize: API Timeout for , retrying later
2022-12-04 10:15:16.062 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:Shelly1-Toroeffner' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.
2022-12-04 10:15:16.240 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:Shelly1-Toroeffner' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to OFFLINE (COMMUNICATION_ERROR): Unerwarteter Fehler - API Timeout for
2022-12-04 10:15:19.196 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-shelly1-toroeffner: CoIoT Message from /192.168.1.85:5683 (MID=32224): {"G":[[0,9103,21],[0,1101,0],[0,2101,0],[0,2102,""],[0,2103,61]]}

found the problem, please try update M5 build

Is there a working dev build for OH 3.2 / 3.3?

@markus - I just wanted to thank you for your diligence in tracking down the Shelly1 bug. I just installed your latest M5 binding and I’m happy to say it works with my Shelly 1’s and Shelly 2,.5. I upgraded my docker OH3.3 to 3.4M5, installed the latest Shelly binding in my addon directory and rebooted 2-3 times as is normal for me with an OH upgrade/fresh install. I also ran feature:install openhab-transport-coap. Everything seems to be working fine, so thanks again for your efforts.