Shelly Binding

Providing logs from my productive OH instance seems not sensible as there are over 40 Shelly things configured and I suppose the relevant log lines would be hard to filter out.

Therefore I have put up a temporary OH instance with just one Shelly button thing configured. After configuring a keep alive of 2s for the button, I could reproducably get SHORT_PRESSED events for the third button press - the first two presses are still missing.

After raising the keep alive time, I tried to reproduce the behaviour of my testing instance with my productive OH instance, but there the problem persisted :frowning_face:

As even the testing instance gets the coap messages of all shellies, it logs a lot of sensitive information. I will therefore send you the logs from my testing instance by direct message, @markus7017 . If this still doesn’t help, I can also send you logs from my productive instance.

Hello,
Im currently deploying a new clean OpenHAB setup and im using some Shelly Plus 2 PM for covers.
I started with a clean OpenHAB Setup (3.4.2, via deb, ubuntu 22.04, openjdk11)
The Instance is clean (freshly deployed LXC Container, only the official shelly addon installed).

Now to my issue: having the shelly plus configured in Relay mode, everything is fine.
However as soon as i try to bind one in cover mode, it doesnt work.
It goes into error state every time.
(Both tested from a fresh new template VM).

In the OpenHAB Log, there a NPE

java.lang.NullPointerException: null
        at org.openhab.binding.shelly.internal.api2.Shelly2ApiClient.updateRollerStatus(Shelly2ApiClient.java:363) ~[?:?]
        at org.openhab.binding.shelly.internal.api2.Shelly2ApiClient.fillDeviceStatus(Shelly2ApiClient.java:183) ~[?:?]
        at org.openhab.binding.shelly.internal.api2.Shelly2ApiRpc.getStatus(Shelly2ApiRpc.java:552) ~[?:?]
        at org.openhab.binding.shelly.internal.api2.Shelly2ApiRpc.getDeviceProfile(Shelly2ApiRpc.java:261) ~[?:?]
        at org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.initializeThing(ShellyBaseHandler.java:286) ~[?:?]
        at org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.lambda$0(ShellyBaseHandler.java:188) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]

I didnt find much in currently open issues.

Can someone help me?

It seems like that some objects are missing in cover mode in the Status request

id	0
source	"timeout"
state	"stopped"
apower	0
voltage	229.6
current	0
pf	0
aenergy	
total	4.188
temperature	
tC	49.9
tF	121.9
pos_control	true
current_pos	95

this is my return value of a getStatus on a shelly plus 2pm with newest firmware

        if (cs.aenergy != null) {
            sm.total = emeter.total = cs.aenergy.total;
            sm.counters = cs.aenergy.byMinute;
            sm.timestamp = (long) cs.aenergy.minuteTs;
        }

Thats the code snipped of the Shelly2ApiClient.java where the issue occures
(en detail it occures at the assignment of the Timestamp)

hope this helps in the debugging

Just as Headsup and maybe for the Infopage:
I found the issue.
I blocked NTP in my firewall for the shellys ( or didnt allow it initially)
Without a correct time, the timestamp in the shelly is NULL (when you request it over the system rpc)
and hence the shelly does not send the energy timestamp. (wich breaks things in blinds/cover mode with the binding)
With correctly configured NTP server, everything works with the official repository.

As long term solution, maybe a warning/information should be added in the addon’s documentation.
Or the other way would be to make the binding more fault tolerant, so it doesnt take minuteTS as mandatory ?

Have a nice day :wink:

1 Like

I updated to openHAB 4.0.0 Milestone 1 and since then I cannot access the shelly manager anymore. Is there something which I have overlooked?
image

This has been addressed in the 4.0.0.M1 Thread:

Cheers!

I finally found time to retry again and dependencies are fine. I think the problem was the order of removing the built-in bundle and replacing it with the new one was somewhat not fully correct.
I see the channels and tried this:

Group:Switch:AND(ON,OFF) gShelly3EM_reset "EVU Zähler zurücksetzen" (gShelly3EM) ["Switch"]
Switch shelly_reset_L1 "Zähler L1 zurücksetzen" (gShelly3EM_reset) { channel="shelly:shellyem3:ee412e8d00:meter1#resetTotals" }
Switch shelly_reset_L2 "Zähler L2 zurücksetzen" (gShelly3EM_reset) { channel="shelly:shellyem3:ee412e8d00:meter2#resetTotals" }
Switch shelly_reset_L3 "Zähler L3 zurücksetzen" (gShelly3EM_reset) { channel="shelly:shellyem3:ee412e8d00:meter3#resetTotals" }

But neither switching gShelly3EM_reset nor shelly_reset_L1 did something to the totals.

2023-03-14 18:10:17.814 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'shelly_reset_L1' received command ON
2023-03-14 18:10:17.821 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'shelly_reset_L1' predicted to become ON
2023-03-14 18:10:17.827 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'shelly_reset_L1' changed from OFF to ON
2023-03-14 18:11:51.901 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'shelly_reset_L1' received command OFF
2023-03-14 18:11:51.907 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'shelly_reset_L1' predicted to become OFF
2023-03-14 18:11:51.912 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'shelly_reset_L1' changed from ON to OFF

And counters did not change (neither totalKWH nor returnedKWH.

I guess I need some debugging turned on to see what is happening? What to do?

I added an additional check.

Nevertheless, from experience in the last I could say the Shelly need at least initially a timestamp (after each power cycle). Sometimes I saw strange effects when time was not set (at least with the Gen1 models).

turn on DEBUG mode

  • open OH console
  • “log:set DEBUG org.openhab.binding.shelly”

Works flawlessly with OH 3.4.2 and shelly plus plug s :+1:
Thanks!

One thing: The type of the thing is shellyplusplug, wouldn’t be shellyplusplugs be more fitting since the Device is called Shelly Plus Plug S?

I would be nice, if the binding supports the new color-features of the Shelly Plus Plug S…because then it will be useable as an optical status display

thank you.

I made this, because there is a Plug-S, Plug-IT, Plug-UK and Plug-US. It doesn’t make sense to do copy&paste for those device types if in fact it’s always the same definition.

1 Like

What are you looking specifically for? Usually you set those values once and then the LEDs follow the power/WiFi/switch operation. What do you want to achieve?

You can use the features for signaling different states in your home.
for example i use the color with following meanings:

  • red = Alarm system armed
  • green = Alarm system unarmed (for 10 Seconds)
  • blue = one or more open windows or doors

There are many possible usecases

I updated the DEV build

  • @atetzner First message for Shelly Button is processed after OH restart, in my test setup already the 1st click now triggers the event channel
  • @Wolfgang_Rosenauer Found a bug building the URL to reset the Toal consumption for 3EM
  • @SebastianB Additional check to prevent NPE when device’ time is not set
  • @goligo The binding tries to restore the channel value from cache on exception processing a channel command (e.g. set temp failed)
  • @Oliver2 An additional check to catch the “even thing handler is already disposed”, not sure if this works

3.4.3-DEV Gen1/Plus/Pro | 4.0.0-DEV Gen1/Plus/Pro | README | READMEbeta
Avdanced Users - Shelly Manager - Bugs/Features - API Doc | Firmware Index - Firmware Archive


Note: The DEV build is always newer than the version in the official Distro or Milestone builds

Who still has problems with “flipping roller position” (roller pos is incorrectly reported as 0 / 100) and could provide some logs (@aserraric?)
See also [shelly] Shelly 2.5 Roller Shutter Position Control randomly jumps to 0 / 100 · Issue #14189 · openhab/openhab-addons · GitHub

Where do I find the repository this is built from and the actual changes? I cannot test it as is, due to the other issue with the selectedProfile, but would need to cherry pick the change in order to test it.

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

I thought my question was quite explicit, but I will try again: I cannot use your jar-File, as the selectedProfile is broken since the last release. However I want to test the changes you did for exception handling. Is there a repository, where the actual commit for these changes can be found, so I can have a look and cherry pick them?