Shelly Binding

Hi Markus,
thank you so much for your work on this binding. I appreciate it very much.

I gave it a try again with 4.2.0 M3 and a Shelly 1 (Gen1 Device).

When I add the device via “Add a new Thing” from the UI, I get the following from the log, and the Shelly 1 connects successfully.

==> /logs/events.log <==

2024-05-26 22:55:53.519 [INFO ] [openhab.event.InboxRemovedEvent     ] - Discovery Result with UID 'shelly:shelly1:3494546aca8d' has been removed.

2024-05-26 22:55:53.550 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:3494546aca8d' changed from UNINITIALIZED to INITIALIZING

==> /logs/openhab.log <==

2024-05-26 22:55:53.522 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Shelly-1-Boiler: Create new thing of type shelly:shelly1 using ShellyRelayHandler

2024-05-26 22:55:53.547 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Thing handler for uid shelly:shelly1:3494546aca8d added, total things = 1

==> /logs/events.log <==

2024-05-26 22:55:55.559 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:3494546aca8d' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.

2024-05-26 22:55:55.821 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:3494546aca8d' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to ONLINE

==> /logs/openhab.log <==

2024-05-26 22:55:55.554 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Using default userId admin from binding config

2024-05-26 22:55:55.555 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Using default password from bindingConfig (userId=admin)

2024-05-26 22:55:55.556 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Config: Device address=192.168.2.48, HTTP user/password=admin/***, update interval=60

Events: Button: false, Switch (on/off): false, Push: false, Roller: trueSensor: true, CoIoT: true

Blu Gateway=false, Range Extender: true

2024-05-26 22:55:55.557 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Start initializing for thing Shelly-1-Boiler, type shelly1, IP address 192.168.2.48, Gen2: false, CoIoT: true

2024-05-26 22:55:55.735 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Auto-CoIoT is enabled, disabling action urls

2024-05-26 22:55:55.736 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Starting CoIoT (autoCoIoT=true/true)

2024-05-26 22:55:55.737 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d: Starting CoAP Listener

2024-05-26 22:55:55.738 [DEBUG] [elly.internal.api1.Shelly1CoapServer] - Initializing CoIoT listener (local IP=192.168.2.9:5683)

2024-05-26 22:55:55.774 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d: Using CoAP device description from successful HTTP /cit/d

2024-05-26 22:55:55.775 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d: CoIoT Device Description for shelly1-3494546aca8d: {"blk":[{"I":1,"D":"relay_0"},{"I":2,"D":"sensor_0"},{"I":3,"D":"sensor_1"},{"I":4,"D":"sensor_2"},{"I":5,"D":"device"}],"sen":[{"I":9103,"T":"EVC","D":"cfgChanged","R":"U16","L":5},{"I":1101,"T":"S","D":"output","R":"0/1","L":1},{"I":2101,"T":"S","D":"input","R":"0/1","L":1},{"I":2102,"T":"EV","D":"inputEvent","R":["S/L",""],"L":1},{"I":2103,"T":"EVC","D":"inputEventCnt","R":"U16","L":1},{"I":3101,"T":"T","D":"extTemp","U":"C","R":["-55/125","999"],"L":2},{"I":3102,"T":"T","D":"extTemp","U":"F","R":["-67/257","999"],"L":2},{"I":3201,"T":"T","D":"extTemp","U":"C","R":["-55/125","999"],"L":3},{"I":3202,"T":"T","D":"extTemp","U":"F","R":["-67/257","999"],"L":3},{"I":3301,"T":"T","D":"extTemp","U":"C","R":["-55/125","999"],"L":4},{"I":3302,"T":"T","D":"extTemp","U":"F","R":["-67/257","999"],"L":4},{"I":3103,"T":"H","D":"humidity","R":["0/100","999"],"L":2},{"I":3117,"T":"S","D":"extInput","R":"0/1","L":2}]}

2024-05-26 22:55:55.777 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id=1: relay_0

2024-05-26 22:55:55.778 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id=2: sensor_0

2024-05-26 22:55:55.779 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id=3: sensor_1

2024-05-26 22:55:55.780 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id=4: sensor_2

2024-05-26 22:55:55.781 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id=5: device

2024-05-26 22:55:55.785 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d: Adding 13 sensor definitions

2024-05-26 22:55:55.786 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 9103: cfgChanged, Type=EVC, Range=U16, Links=5

2024-05-26 22:55:55.787 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 1101: output, Type=S, Range=0/1, Links=1

2024-05-26 22:55:55.788 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 2101: input, Type=S, Range=0/1, Links=1

2024-05-26 22:55:55.789 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 2102: inputEvent, Type=EV, Range=S/L;, Links=1

2024-05-26 22:55:55.790 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 2103: inputEventCnt, Type=EVC, Range=U16, Links=1

2024-05-26 22:55:55.791 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3101: extTemp, Type=T, Range=-55/125;999, Links=2

2024-05-26 22:55:55.792 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3102: extTemp, Type=T, Range=-67/257;999, Links=2

2024-05-26 22:55:55.793 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3201: extTemp, Type=T, Range=-55/125;999, Links=3

2024-05-26 22:55:55.794 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3202: extTemp, Type=T, Range=-67/257;999, Links=3

2024-05-26 22:55:55.795 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3301: extTemp, Type=T, Range=-55/125;999, Links=4

2024-05-26 22:55:55.796 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3302: extTemp, Type=T, Range=-67/257;999, Links=4

2024-05-26 22:55:55.797 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3103: humidity, Type=H, Range=0/100;999, Links=2

2024-05-26 22:55:55.798 [DEBUG] [lly.internal.api1.Shelly1CoapHandler] - shelly1-3494546aca8d:    id 3117: extInput, Type=S, Range=0/1, Links=2

2024-05-26 22:55:55.800 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Updating channel definitions, 4 channels

2024-05-26 22:55:55.801 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Adding channel device#deviceName

2024-05-26 22:55:55.802 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Adding channel device#uptime

2024-05-26 22:55:55.803 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Adding channel device#updateAvailable

2024-05-26 22:55:55.804 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Adding channel device#heartBeat

2024-05-26 22:55:55.809 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Channel definitions updated

2024-05-26 22:55:55.811 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Initializing device shelly-6ACA8, type SHSW-1, Hardware: Rev: prod-191217, batch 1; Firmware: 1.14.0- / 20230913

2024-05-26 22:55:55.811 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Shelly settings info for shelly-6ACA8: {"device":{"type":"SHSW-1","mac":"3494546ACA8D","hostname":"shelly1-3494546ACA8D","num_outputs":1},"wifi_ap":{"enabled":false,"ssid":"shelly1-3494546ACA8D","key":""},"wifi_sta":{"enabled":true,"ssid":"Nuechtere","ipv4_method":"static","ip":"192.168.2.48","gw":"192.168.2.1","mask":"255.255.255.0","dns":"192.168.2.1"},"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-3494546ACA8D","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":"192.168.2.9:5683"},"sntp":{"server":"time.google.com","enabled":true},"login":{"enabled":false,"unprotected":false,"username":"admin"},"pin_code":"","name":"Shelly-1-Boiler","fw":"20230913-112003/v1.14.0-gcb84623","factory_reset_from_switch":true,"pon_wifi_reset":false,"discoverable":true,"build_info":{"build_id":"20230913-112003/v1.14.0-gcb84623","build_timestamp":"2023-09-13T11:20:03Z","build_version":"1.0"},"cloud":{"enabled":false,"connected":false},"timezone":"Europe/Zurich","lat":47.161400,"lng":7.280100,"tzautodetect":true,"tz_utc_offset":7200,"tz_dst":false,"tz_dst_auto":true,"time":"22:55","unixtime":1716756957,"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":800,"relays":[{"name":null,"appliance_type":"General","ison":false,"has_timer":false,"default_state":"switch","btn_type":"toggle","btn_reverse":0,"auto_on":0.00,"auto_off":0.00,"power":0.00,"schedule":false,"schedule_rules":[]}],"ext_sensors":{"temperature_unit":"C"},"ext_temperature":{"1":{"overtemp_threshold_tC":0.0,"overtemp_threshold_tF":32.0,"undertemp_threshold_tC":0.0,"undertemp_threshold_tF":32.0,"overtemp_act":"disabled","undertemp_act":"disabled","offset_tC":0.0,"offset_tF":0.0},"0":{"overtemp_threshold_tC":40.0,"overtemp_threshold_tF":104.0,"undertemp_threshold_tC":33.0,"undertemp_threshold_tF":91.4,"overtemp_act":"relay_on","undertemp_act":"relay_off","offset_tC":0.0,"offset_tF":0.0},"2":{"overtemp_threshold_tC":40.0,"overtemp_threshold_tF":104.0,"undertemp_threshold_tC":33.0,"undertemp_threshold_tF":91.4,"overtemp_act":"relay_on","undertemp_act":"disabled","offset_tC":0.0,"offset_tF":0.0}},"ext_humidity":{},"eco_mode_enabled":true}

2024-05-26 22:55:55.813 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Device hasRelays:true (numRelays=1),isRoller:false (numRoller=0),isDimmer:false,numMeter=0,isEMeter:false), ext. Switch Add-On: installed,isSensor:false,isDS:false,hasBattery:false,isSense:false,isMotion:false,isLight:false,isBulb:false,isDuo:false,isRGBW2:false,inColor:false, BLU Gateway support: true,alwaysOn:70, updatePeriod:falsesec

2024-05-26 22:55:55.813 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Shelly Add-On detected with at least 1 external sensor

2024-05-26 22:55:55.814 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Thing successfully initialized.

But when I try to add the device via .things file

Thing shelly:shelly1:boiler "Shelly 1 Boiler" [deviceIp="192.168.2.48", userId="yx", password="xy", updateInterval=15, eventsCoIoT=false, eventsButton=false, eventsPush=false, eventsSwitch=false]

I get the following log and the WebSocket error.

==> /logs/events.log <==

2024-05-26 22:46:39.093 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:boiler' changed from UNINITIALIZED to INITIALIZING

==> /logs/openhab.log <==

2024-05-26 22:46:38.732 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'shelly.things'

2024-05-26 22:46:39.065 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Shelly 1 Boiler: Create new thing of type shelly:shelly1 using ShellyRelayHandler

2024-05-26 22:46:39.090 [DEBUG] [shelly.internal.ShellyHandlerFactory] - Thing handler for uid shelly:shelly1:boiler added, total things = 1

==> /logs/events.log <==

2024-05-26 22:46:41.130 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:boiler' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.

2024-05-26 22:46:41.228 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shelly1:boiler' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to OFFLINE (COMMUNICATION_ERROR): Unerwarteter Fehler - WebSocket error

==> /logs/openhab.log <==

2024-05-26 22:46:41.127 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-boiler: Config: Device address=192.168.2.48, HTTP user/password=xy/***, update interval=15

Events: Button: false, Switch (on/off): false, Push: false, Roller: trueSensor: true, CoIoT: false

Blu Gateway=false, Range Extender: true

2024-05-26 22:46:41.128 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-boiler: Start initializing for thing Shelly 1 Boiler, type shelly1, IP address 192.168.2.48, Gen2: true, CoIoT: false

2024-05-26 22:46:41.196 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shelly1-boiler: Connect Rpc Socket (discovery = false)

2024-05-26 22:46:41.198 [DEBUG] [helly.internal.api2.Shelly2RpcSocket] - Shelly 1 Boiler: Connect WebSocket, URI=ws://192.168.2.48/rpc

2024-05-26 22:46:41.225 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shelly1-boiler: WebSocket error: HttpConnectionOverHTTP@7f6e14f7::SocketChannelEndPoint@71a9e56a{l=/192.168.2.9:36314,r=/192.168.2.48:80,ISHUT,fill=-,flush=-,to=10/0}{io=0/0,kio=0,kro=1}->HttpConnectionOverHTTP@7f6e14f7(l:/192.168.2.9:36314 <-> r:/192.168.2.48:80,closed=false)=>HttpChannelOverHTTP@75967f87(exchange=HttpExchange@3094ef51{req=WebSocketUpgradeRequest[GET /rpc HTTP/1.1]@3f529c18[TERMINATED/null] res=HttpResponse[null 0 null]@16ebc2d[PENDING/null]})[send=HttpSenderOverHTTP@474291c0(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@50bb101e{s=START}],recv=HttpReceiverOverHTTP@7b22f44d(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]

2024-05-26 22:46:41.228 [DEBUG] [g.shelly.internal.api2.Shelly2ApiRpc] - shelly1-boiler: Closing Rpc API (socket is disconnected, discovery=false)

2024-05-26 22:46:41.258 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-boiler: Unexpected API result: 404/Not Found

org.openhab.binding.shelly.internal.api.ShellyApiException: 

	at org.openhab.binding.shelly.internal.api.ShellyHttpClient.innerRequest(ShellyHttpClient.java:213) ~[?:?]

	at org.openhab.binding.shelly.internal.api.ShellyHttpClient.httpPost(ShellyHttpClient.java:152) ~[?:?]

	at org.openhab.binding.shelly.internal.api2.Shelly2ApiRpc.rpcPost(Shelly2ApiRpc.java:1227) ~[?:?]

	at org.openhab.binding.shelly.internal.api2.Shelly2ApiRpc.apiRequest(Shelly2ApiRpc.java:1171) ~[?:?]

	at org.openhab.binding.shelly.internal.api2.Shelly2ApiRpc.getDeviceProfile(Shelly2ApiRpc.java:172) ~[?:?]

	at org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.initializeThing(ShellyBaseHandler.java:323) ~[?:?]

	at org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.lambda$0(ShellyBaseHandler.java:187) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]

	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:1136) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]

	at java.lang.Thread.run(Thread.java:840) [?:?]

As far as I can see, one difference is, that with the GUI configuration, the log says “Gen2: false”

2024-05-26 22:55:55.557 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-3494546aca8d: Start initializing for thing Shelly-1-Boiler, type shelly1, IP address 192.168.2.48, Gen2: false, CoIoT: true

And with the .things file configuration I get “Gen2: true”

2024-05-26 22:46:41.128 [DEBUG] [y.internal.handler.ShellyBaseHandler] - shelly1-boiler: Start initializing for thing Shelly 1 Boiler, type shelly1, IP address 192.168.2.48, Gen2: true, CoIoT: false

Why thinks the binding, the shelly 1 is a gen2 device when I try to add the device via .things file?
Is that the reason for the WebSocket error?
Do I have to configure something additional in the .things file?

1 Like