Shelly Binding

Just installed M4 but it still does not work, is there something I would have to do?

Sorry, just checked and saw that you fixed it in your branch, but its not merged yet. All good.

so, install the DEV build

  • remove binding from UI
  • run „feature:install openhab-transport-coap“ from OH console
  • copy the M3 jar from my myfiles repo into the addons folder

The PR is created, I expect the fix to go into M5

I did that already as soon as I noticed that your PR was not merged, works. Thanks for your great work and support.

I tested shelly-binding3.4M3 with openhab 3.4M4:
-Shelly 1, Shelly 1 plus, Shelly 2.5:
Switching with commands or button works smooth

-Shelly1: Events pop up in log in <0.5 sec
-Shelly1 plus: Events seem to show up even faster
Till now everything works like a charm.

Please tell me if you need more specific results

I updated the DEV build for OH 3.3 M3/M4 and added support for Shelly1’s/Shelly1PM’s external switch add-on (reed contact). Please verify (I can’t test).

org.openhab.binding.shelly-3.4.0M3-SNAPSHOT.jar

Noob question, but if I remove the Shelly things I have already defined and remove the old and reinstall the new binding, will I lose all the configuration and programming for my existing Shelly things? I’ve got quite a bit of time invested in getting those working with my other devices, and I would hate to have to rebuild all of that from scratch.

Thanks!

My experience: Don’t touch your things, just replace the binding and everything works fine immediately.

Sometimes you have to delete and recreate/discover the Thing in order to activate new channels that have been added.

In that case as long as you create the new Thing with the same Identifier all the existing channels and items should come back.

You need to delete/re-add the things if the thing definition has been changed (e.g. new channel has been added). If you delete the things, OH will restore thing channels and items.

… second attempt …

I can not get my new Shelly PlusHT to work. I got it discovered, the thing got created, an item was added. I only receive very few Status Updates from the device … looks like every 15 minutes there is an attempt to get a status update, but only very few of these attempts are successful.
My setup:

  • OH 3.4.0M4 on a Raspi (no manual addons added)
  • openhab running behind an nginx proxy
  • openhab can be reached via port 80, port 8080 is blocked
  • Shelly plusHT is on version: v0.12.0/20221114-152708

I have the suspicion that there is something wrong with the outbound WebSocket on the device … maybe related to the use of nginx?

I really appreciate your help. thanks.


2022-11-23 11:44:43.530 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 11:44:43.537 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 11:44:43.603 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): WebSocket connected /|oh-server-ip|:35724|-/|shellyplusht-ip|:80, Idle Timeout=2147483647
2022-11-23 11:44:43.609 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Channel sensors#temperature updated with 25.7 °C (type class org.openhab.core.library.types.QuantityType).
2022-11-23 11:44:43.621 [INFO ] [rg.openhab.core.model.script.Heizung] - EG-Temp: 25.7
2022-11-23 11:47:39.762 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket connection closed, status = 1006/Disconnected

2022-11-23 11:59:43.687 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 11:59:43.689 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 11:59:58.720 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Ignore API Timeout, retry later
2022-11-23 11:59:58.721 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket error
2022-11-23 12:14:58.784 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 12:14:58.795 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 12:15:02.012 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Event erzeugt: STATUS_UPDATE
2022-11-23 12:15:02.012 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): WebSocket connected /|oh-server-ip|:35814|-/|shellyplusht-ip|:80, Idle Timeout=2147483647
2022-11-23 12:15:02.019 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Channel sensors#temperature updated with 24.4 °C (type class org.openhab.core.library.types.QuantityType).
2022-11-23 12:15:02.028 [INFO ] [rg.openhab.core.model.script.Heizung] - EG-Temp: 24.4
2022-11-23 12:15:16.330 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket connection closed, status = 1006/Disconnected

2022-11-23 12:30:02.093 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 12:30:02.097 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 12:30:17.136 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Ignore API Timeout, retry later
2022-11-23 12:30:17.142 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket error
2022-11-23 12:41:06.350 [DEBUG] [discovery.ShellyDiscoveryParticipant] - shellydw2-076113: Shelly device discovered: IP-Adress=192.168.20.52, type=shellydw2

2022-11-23 12:45:17.229 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 12:45:17.242 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 12:45:32.270 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Ignore API Timeout, retry later
2022-11-23 12:45:32.271 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket error

2022-11-23 13:00:32.332 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 13:00:32.345 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 13:00:32.404 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): WebSocket connected /|oh-server-ip|:35960|-/|shellyplusht-ip|:80, Idle Timeout=2147483647
2022-11-23 13:00:32.412 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Channel sensors#temperature updated with 24.3 °C (type class org.openhab.core.library.types.QuantityType).
2022-11-23 13:00:32.422 [INFO ] [rg.openhab.core.model.script.Heizung] - EG-Temp: 24.3
2022-11-23 13:00:36.214 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket connection closed, status = 1006/Disconnected

2022-11-23 13:15:32.485 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 13:15:32.489 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 13:15:47.516 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Ignore API Timeout, retry later
2022-11-23 13:15:47.522 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket error

2022-11-23 13:30:47.579 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: Connect Rpc Socket (discovery = false)
2022-11-23 13:30:47.591 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - SH021 HT Wohnzimmer DG (shellyplusht-|shellyplusht-UID|@|shellyplusht-ip|): Connect WebSocket, URI=ws://|shellyplusht-ip|/rpc
2022-11-23 13:31:02.619 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-|shellyplusht-UID|: Ignore API Timeout, retry later
2022-11-23 13:31:02.620 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-|shellyplusht-UID|: WebSocket error

OH tries from time to time to reach the HT, which fails, because the device is in sleep mode. That‘s ok

I see an inbound status update, which gets processed.

What do you expect in between? The device reports updates only if the configured threshold is exceeded. Check device UI for details

The temperature changed significantly multiple times in between, so I would expect the device to issue a status update via the outbound websocket. Am I correct in that assumption?
The inbound status update occured only once, temperature changed afterwards again multiple times … forced by me.
Could nginx play a role in preventing the HT to connect back to the server via websockets? How can I get to the root cause of the problem. Any suggestions?

I activated the websocket debug-log on the device and here is what I got:

{
“ts”: 1669229860.472,
“data”: “Connected.”
},
{
“ts”: 1669229861.185,
“level”: 0,
“data”: “mgos_rpc_channel_ws:211 0x3ffdad18 TCP connect failed: -13\n”
},
{
“ts”: 1669229866.187,
“level”: 2,
“data”: “mgos_rpc_channel_ws:269 0x3ffdad18 Connecting to ws://172.17.0.1:8080/shelly/wsevent, SSL? 0\n”
},
{
“ts”: 1669229884.172,
“level”: 0,
“data”: “mgos_rpc_channel_ws:211 0x3ffdad18 TCP connect failed: -13\n”
}
]

I did another test and changed the destination IP for the outbound websocket on the device to ‘oh-server-ip’:80 and now get the following error in the device debug log

mgos_rpc_channel_ws:269 0x3ffdad1c Connecting to ws://192.168.x.xxx:80/shelly/wsevent, SSL? 0

20:20:33

mgos_rpc_channel_ws.:54 0x3ffdad1c WS handshake resp 403

403 is access denied
remove the reverse proxy to simplify the setup for testing
switch debug level to TRACE
run tcpdump/wireshark to see the network level

I removed the reverse proxy and now it works fine. I had to change the outbound websocket ip to the ip of the openhab server though.

Next problem: One of my openhab instances runs in docker. When I try to connect the plusht to a docker openhab system, the outbound web socket does no longer work.

Does anybody have a solution for the plusht in a docker environment?

where do you changes it?
Go to the device UI, clear the outbound webbsocket setting and re-initialize the thing. The binding will setup the outbound websocket device config automatically.

Hi guys,

can anyone confirm general issues with OH 3.3. (release) and the official binding?

I have issues since a couple of days (and may be since OH 3.3 upgrade). After less than 24 hours after a reboot, shelly interactions to turn on or off lights are either delayed for many minutes or just aren’t executed.

Other bindings work fine.

Looking at the events log, triggers of a switch ARE recognized and openhab tries to send a command to shelly (to switch the light).
The issue is somewhere in the direction OH → shelly.

No warnings etc. within the logs.

I already tried some new milestone builds of the binding but didn’t suceed yet because of issues/warnings related to californium core.

Nevertheless, if someone could either confirm issues or give me some hints what to try next, that would be great.

thanks!

turn on TRACE mode for the binding, you‘ll see the http request/response, check timestamps of the flow

fyi: Shelly on sale with up to 45% discount

Shelly Shop Europe.

This Black Friday is the last chance to buy Shelly 1 & Shelly 2.5! The first Shelly devices are discontinued and their last quantities are on sale, so hurry up and grab yours while they are still available!

1 Like

Hi,
quick couple of questions on ShellyEM:

  1. I need also to measure ampere, but are not listed in the channel. I could be a new feature? Meanwhile I can calulate them from power and voltage

  2. I need to detect also power outage with this shelly. In case of power outage, this shelly will turn off, is there a way to detect it and update an item? obviously OpenHab, router, switch and wifi are powered by an UPS, so it will stay on in case of power outage.

Thanks

Do you (as you got much more knowledge about the internals of a Shelly than me) see significant advantages compared to the new plus versions? I thought the design of the plus versions is cleaner and safer and planned to replace my old shellys…