Shelly Binding

if you do it right, it works :slight_smile:

1 Like

Thnx,I got it working yesterday,I found instructions at marketplace binding…thank you.

Hello,
I have 4 Shelly H&T

  • 2 are powered through USB-C and are working fine in OpenHAB
  • 2 are running with batteries and are never sending any data to OpenHAB

They are all configured in the exact same way in .things and .items files.
And are all working fine in Shelly app of course.

So : is it possible to have these “battery powered devices” working in openhab ? What is the principle, is openhab constantly trying to reach them (so they have to be connected / sending something, in order for the openhab > shelly devices connection to be possible ? (hence why it’s not working : mismatch of polling / availability between the two))

Yes, having 5 of them runninge over here.

No, battery operated devices have to push their state updates to openHAB. Polling updates does not really work, as those devices are in sleep mode most of the time. They just wake up when values have changed.
If you power them via USB, openHAB is also using the backup polling task.

What is the state reported in shelly manger ? When was the last update seen?
Did you configure Coap/CoIoT correct ?

In shellymanager, right now i see only 3 out of 4

No i don’t know about Coap/CoIoT, never configured that, i’ll check that point, it’s probably what is missing right now, thanks.

I updated the DEV build

  • Pro 3EM: total_xxx values are taking from device (e.g. channel totalKWH) rather than aggregated from single phaases.
  • EM/3EM: totalReturned reported kw instead of kw/h, I added a “/ 60” to make it kw/h

4.0 beta users might need to upgrade to the latest 4.0.0-SNAPSHOT, the team updated some of the core components


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

Hi,

EM/3EM: totalReturned reported kw instead of kw/h, I added a “/ 60” to make it kw/h

a generic question. Where can I find commits in github (if at all)?
Because the above comment leaves a few question marks for me.

  1. -I didn’t know there is a totalReturned and I assume it’s quite recent and has been added after my last addition/discovery of the Thing. I also assume it’s a binding internal calculation since I haven’t seen it in the API? → sorry, found the accumulated channels now so can remove my calculation rules :wink:
  2. As I’m currently not sure where to find the code I need to nit on your comment above. neither kw nor kw/h is the correct unit for power consumption/energy. It actually is kWh which is slightly different and dividing a value by 60 sounds fishy :wink: But again it depends on the actual calculation and where the numbers in the calculation come from. - I know where to find the original openhab-addon code but missed to find the recent dev build changes

UPDATE:
I still haven’t found the code belonging to the the comment “EM/3EM: totalReturned reported kw instead of kw/h, I added a “/ 60” to make it kw/h” but the code I found is here:

and it looks totally fine to me because the Shelly API returns Wh which is converted into kWh by /1000 by the binding.

@Wolfgang_Rosenauer I updated the DEV builds and committed the latest code, please check
Tge regular meter is returning Watts/Min, so I do / 60 / 1000 to convert to kw/h
whereas the EM, 2EM and Pro 3EM returns Watt/h so I just do a / 1000 to covert to kw/h

@markus7017 ok, that sounds about correct. I only have one 3EM right now and it just needs the / 1000 conversion. emeters from other devices like the plug - according to documentation - return Wmin so / 60 / 1000 is correct as well. Sorry for the confusion but was puzzled by the change notice.

Hi Markus,
did you have a chance to look into this?It is about the missing device temperature of dimmers.

Hi @markus7017,

I updated to the latest dev build. Now, shelly:shellypro3em:xxx:device#accumulatedWTotal does not get updated anymore at all.

Just to understand correctly. The idea of the accumulated total power channel is to have one parameter that incrementally accumulates the power consumption in kWh. If yesterday, I consumed 10 kWh and today 15 kWh, the channel will report 25 kWh. Is this assumption correct?

Thanks,
Florian

Hi @markus7017 ,

with Shelly bundle 3.4.3.202304072127 I see SHORT_PRESSED events for my buttons with the first press :sparkler:

This is awesome! Thank you very much for your work and help, very appreciate that :+1:

Do you have firmware 0.14? With this version the device computes the total values

welcome, it always help to do co-working :slight_smile:

1 Like

check the updated DEV build

i have openhab 4.0 with DEV build.
i have gen1 devices shelly2.5 PM
and gen2 devices shelly plus 1 PM
trying to change in gen1 device shelly:shelly25-relay:SW_3DPRINTER:relay1#autoOff
and in gen 2 device shelly:shellyplus1pm:SC_BAGNO:relay#autoOn
this is result:
set 10 in the shelly app shelly gen1 show 10 shelly gen2 show 10
set 10.1. in the shelly app shelly gen1 show 10.1 shelly gen2 show 10.1
set 10 from a rule openhab correctly show 10 but value in shelly gen1 e gen2 doesn’t change.
set 10.1 from a rule openhab correctly show 10.1 but value in shelly gen1 e gen2 doesn’t change.
no warining in openhab logs

Please provide a TRACE log, this shows the http requests to the device

1 Like

I just got a bunch of new shellys and run into some troubles adding some devices.

openhab> bundle:list | grep -i Shelly
274 x Active x  80 x 3.4.3                  x openHAB Add-ons :: Bundles :: Shelly Binding Gen1+2
  1. Shellyplus Smoke:
    Scanning for devices did never bring up the smoke sensor, so I manually added it by IP address. unfortunately it stays in “configuration pending” mode, even if I wake it up.
    when disabling/enabling the Thing, I see a new thing poping up in the log, but it is a “shellyunknown” device. if adding this one I do not see any channels…
2023-04-14 10:21:59.693 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to UNINITIALIZED
2023-04-14 10:21:59.704 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2023-04-14 10:22:01.808 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from UNINITIALIZED (DISABLED) to INITIALIZING
2023-04-14 10:22:03.821 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.
==> /var/log/openhab/openhab.log <==
2023-04-14 10:22:13.287 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'shelly:shellyunknown:80646fd06ecc' to inbox.
==> /var/log/openhab/events.log <==
2023-04-14 10:22:13.287 [INFO ] [openhab.event.InboxAddedEvent       ] - Discovery Result with UID 'shelly:shellyunknown:80646fd06ecc' has been added.
  1. Shelly Plus H&T:
    is detected fine, but never leaves the “config pending” state. wakeup does not help. I’m also unable to add the Alarm Channel. there is no profile available… what does that mean?

    TRACE log from the H&T after disable/enable Thing:
2023-04-14 18:04:35.797 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Stopping Thing

2023-04-14 18:04:35.799 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Shutting down

2023-04-14 18:04:35.802 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Shelly statusJob stopped

2023-04-14 18:04:35.804 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-08b61fcc2bd4: Closing Rpc API (socket is connected, discovery=false)

2023-04-14 18:04:35.805 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - shellyplusht-08b61fcc2bd4: Disconnecting WebSocket (/192.168.10.10:47276 -> /192.168.10.111:80)

2023-04-14 18:04:35.807 [TRACE] [helly.internal.api2.Shelly2RpcSocket] - shellyplusht-08b61fcc2bd4: Rpc connection closed: 1006 - Disconnected

2023-04-14 18:04:35.814 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-08b61fcc2bd4: WebSocket connection closed, status = 1006/Disconnected

2023-04-14 18:04:37.817 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Using userId admin from bindingConfig

2023-04-14 18:04:37.818 [TRACE] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: updateInterval = 900s -> skipCount = 300

2023-04-14 18:04:37.819 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Device config: IP address=192.168.10.111, HTTP user/password=admin/***, update interval=900

2023-04-14 18:04:37.819 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Configured Events: Button: false, Switch (on/off): true, Push: true, Roller: true, Sensor: true, CoIoT: false, Enable AutoCoIoT: true

2023-04-14 18:04:37.821 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Start initializing for thing shellyplusht-08b61fcc2bd4 - 192.168.10.111, type shellyplusht, IP address 192.168.10.111, Gen2: true, CoIoT: false

2023-04-14 18:04:37.825 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP GET for http://192.168.10.111/shelly 

2023-04-14 18:04:37.846 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP Response 200: {"name":null,"id":"shellyplusht-08b61fcc2bd4","mac":"08B61FCC2BD4","model":"SNSN-0013A","gen":2,"fw_id":"20220608-072353/plushtprod2-g4f32651","ver":"plushtprod2","app":"PlusHT","auth_en":false,"auth_domain":null}

2023-04-14 18:04:37.847 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-08b61fcc2bd4: Connect Rpc Socket (discovery = false)

2023-04-14 18:04:37.849 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - shellyplusht-08b61fcc2bd4: Connect WebSocket, URI=ws://192.168.10.111/rpc

2023-04-14 18:04:37.859 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP POST for http://192.168.10.111/rpc {"id":1919625966,"src":"shellyplusht-08b61fcc2bd4","method":"Shelly.GetConfig"}

2023-04-14 18:04:37.908 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - shellyplusht-08b61fcc2bd4: WebSocket connected /192.168.10.10:47100<-/192.168.10.111:80, Idle Timeout=2147483647

2023-04-14 18:04:37.911 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP Response 200: {"id":1919625966,"src":"shellyplusht-08b61fcc2bd4","dst":"shellyplusht-08b61fcc2bd4","result":{"ble":{"enable":false},"cloud":{"enable":true,"server":"shelly-5-eu.shelly.cloud:6022/jrpc"},"devicepower:0":null,"ht_ui":{"temperature_unit":"C"},"humidity:0":{"id":0, "name":null, "report_thr":5},"mqtt":{"enable":false,"server":null,"client_id":"shellyplusht-08b61fcc2bd4","user":null,"topic_prefix":"shellyplusht-08b61fcc2bd4","rpc_ntf":true,"status_ntf":false},"sys":{"device":{"name":null,"mac":"08B61FCC2BD4","fw_id":"20220608-072353/plushtprod2-g4f32651","discoverable":true},"location":{"tz":"Europe/Vienna","lat":48.181140,"lon":16.390870},"debug":{"mqtt":{"enable":false},"websocket":{"enable":false},"udp":{"addr":null}},"ui_data":null,"rpc_udp":{"dst_addr":null,"listen_port":null},"sntp":{"server":"time.google.com"},"sleep":{"wakeup_period":43200},"cfg_rev":8},"temperature:0":{"id":0, "name":null, "report_thr_C": 0.5},"wifi":{"ap":{"ssid":"ShellyPlusHT-08B61FCC2BD4","is_open":true, "enable":false},"sta":{"ssid":"WatchDog_202208","is_open":false, "enable":true, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"sta1":{"ssid":null,"is_open":true, "enable":false, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"roam":{"rssi_thr":-80,"interval":60}}}}

2023-04-14 18:04:37.914 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP GET for http://192.168.10.111/shelly 

2023-04-14 18:04:37.935 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP Response 200: {"name":null,"id":"shellyplusht-08b61fcc2bd4","mac":"08B61FCC2BD4","model":"SNSN-0013A","gen":2,"fw_id":"20220608-072353/plushtprod2-g4f32651","ver":"plushtprod2","app":"PlusHT","auth_en":false,"auth_domain":null}

2023-04-14 18:04:37.937 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP POST for http://192.168.10.111/rpc {"id":503178496,"src":"shellyplusht-08b61fcc2bd4","method":"WS.GetConfig"}

2023-04-14 18:04:37.963 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellyplusht-08b61fcc2bd4: HTTP Response 200: {"id":503178496,"src":"shellyplusht-08b61fcc2bd4","dst":"shellyplusht-08b61fcc2bd4","error":{"code":404,"message":"No handler for WS.GetConfig"}}

2023-04-14 18:04:37.965 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Unable to initialize: POST http://192.168.10.111/rpc > No handler for WS.GetConfig, retrying later

2023-04-14 18:04:37.966 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellyplusht-08b61fcc2bd4: Update status job started, interval=300*3=900sec.

2023-04-14 18:05:11.784 [TRACE] [helly.internal.api2.Shelly2RpcSocket] - shellyplusht-08b61fcc2bd4: Rpc connection closed: 1006 - Disconnected

2023-04-14 18:05:11.803 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shellyplusht-08b61fcc2bd4: WebSocket connection closed, status = 1006/Disconnected

2023-04-14 18:07:15.505 [DEBUG] [discovery.ShellyDiscoveryParticipant] - ServiceInfo [ServiceInfoImpl@23905182 name: 'ShellyPlusHT-08B61FCC2BD4._http._tcp.local.' address: '(null):80' status: 'DNS: 192-168-10-10.local. [192.168.10.10/192.168.10.10] state: probing 1 task: null', has NO data, empty]

It seems that the firmware is too old, go to the device UI and update to the latest version

there was a beta version available, I updated to that one but it didn’t change the situation.

in the trace I see a request for IP_Adress/settings. I tried this on a browser and it returns “Not Found”. I then tried a second Smoke detector, same situation.
other shelly devices (shelly motion2) return json results for IP_Adress/settings, but not the Smoke detectors…
I had a look into the Shelly Plus Smoke API and if asking for

http://192.168.xx.xx/rpc/Sys.GetConfig

I do get a successful reply…

this is the trace when I disable the Thing, wake up the device, enable the Thing:

2023-04-15 12:26:50.978 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Stopping Thing

2023-04-15 12:26:50.979 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Shutting down

2023-04-15 12:26:50.979 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Shelly statusJob stopped

==> /var/log/openhab/events.log <==

2023-04-15 12:26:50.972 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to UNINITIALIZED

2023-04-15 12:26:50.984 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)

==> /var/log/openhab/openhab.log <==

2023-04-15 12:27:02.547 [DEBUG] [shelly.internal.ShellyHandlerFactory] - shellysmoke_01: Create new thing of type shelly:shellysmoke using ShellyRelayHandler

2023-04-15 12:27:02.574 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Thing handler for uid shelly:shellysmoke:shellysmoke_01 added, total things = 14

==> /var/log/openhab/events.log <==

2023-04-15 12:27:02.578 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from UNINITIALIZED (DISABLED) to INITIALIZING

==> /var/log/openhab/openhab.log <==

2023-04-15 12:27:04.584 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Thing name derived from UID shelly:shellysmoke:shellysmoke_01

2023-04-15 12:27:04.585 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Using userId admin from bindingConfig

2023-04-15 12:27:04.586 [TRACE] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: updateInterval = 900s -> skipCount = 300

2023-04-15 12:27:04.587 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Device config: IP address=192.168.10.109, HTTP user/password=admin/***, update interval=900

2023-04-15 12:27:04.587 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Configured Events: Button: false, Switch (on/off): true, Push: true, Roller: true, Sensor: false, CoIoT: true, Enable AutoCoIoT: true

2023-04-15 12:27:04.588 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Start initializing for thing shellysmoke_01, type shellysmoke, IP address 192.168.10.109, Gen2: false, CoIoT: true

2023-04-15 12:27:04.590 [TRACE] [.shelly.internal.api1.Shelly1HttpApi] - shellysmoke_01: HTTP GET for http://192.168.10.109/shelly

2023-04-15 12:27:04.618 [TRACE] [.shelly.internal.api1.Shelly1HttpApi] - shellysmoke_01: HTTP Response 200: {"name":null,"id":"shellyplussmoke-80646fd06ecc","mac":"80646FD06ECC","model":"SNSN-0031Z","gen":2,"fw_id":"20230411-075318/0.14.3-beta1-gb85d9fa","ver":"0.14.3-beta1","app":"PlusSmoke","auth_en":false,"auth_domain":null}

2023-04-15 12:27:04.620 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellysmoke-shellysmoke_01: HTTP GET for http://192.168.10.109/settings 

2023-04-15 12:27:04.643 [TRACE] [shelly.internal.api.ShellyHttpClient] - shellysmoke-shellysmoke_01: HTTP Response 404: Not Found

2023-04-15 12:27:04.644 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Unable to initialize: GET http://192.168.10.109/settings > Not Found, retrying later

2023-04-15 12:27:04.645 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shellysmoke-shellysmoke_01: Update status job started, interval=300*3=900sec.

==> /var/log/openhab/events.log <==

2023-04-15 12:27:04.591 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellysmoke:shellysmoke_01' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.