openLuup: Shelly Bridge plugin
-
Shelly firmware has changed considerably since the early versions. I should probably revisit the Gen 1 handling and make it more generic.
"not to change the default device MQTT prefix". I always leave things at default if possible. This was just for test purposes. Below is the resulting log of the device being created with a few edits. Note that "shellypro3em" was temporarily replaced with "shellypluspro3em" in order to get some action:
2024-03-28 13:09:35.516 openLuup.io.server:: MQTT:1883 connection closed tcp{client}: 0x558f264ee8 2024-03-28 13:09:35.546 openLuup.mqtt:: shellypluspro3em-MAC_address_redacted UNSUBSCRIBE from ALL tcp{client}: 0x558f264ee8 2024-03-28 13:09:38.357 openLuup.io.server:: MQTT:1883 connection from Shelly_IP_redacted tcp{client}: 0x5590804a28 2024-03-28 13:09:38.392 openLuup.mqtt:: shellypro3em-MAC_address_redacted SUBSCRIBE to shellypluspro3em-MAC_address_redacted/rpc tcp{client}: 0x5590804a28 2024-03-28 13:09:38.410 openLuup.mqtt:: shellypro3em-MAC_address_redacted SUBSCRIBE to shellypluspro3em-MAC_address_redacted/command/sys tcp{client}: 0x5590804a28 2024-03-28 13:09:38.413 openLuup.mqtt:: shellypro3em-MAC_address_redacted SUBSCRIBE to shellypluspro3em-MAC_address_redacted/command tcp{client}: 0x5590804a28 2024-03-28 13:09:38.425 openLuup.mqtt:: shellypro3em-MAC_address_redacted SUBSCRIBE to shellies/command tcp{client}: 0x5590804a28 2024-03-28 13:09:38.427 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/online true 2024-03-28 13:09:38.427 luup.register_handler:: global_function_name=Shelly_Plus_Handler, request=mqtt:shellypluspro3em-MAC_address_redacted/# 2024-03-28 13:09:38.429 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/rpc { "id":"0x55902bb480", "method":"Shelly.GetConfig", "src":"shelly-gen2-cmd" } 2024-03-28 13:09:38.432 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/ble {} 2024-03-28 13:09:38.460 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/cloud {"connected":false} 2024-03-28 13:09:38.463 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/em:0 { "id": 0, "a_current": 0.115, "a_voltage": 0, "a_act_power": 0, "a_aprt_power": 0, "a_pf": 0, "a_freq": 0, "b_current": 0.109, "b_voltage": 0, "b_act_power": 0, "b_aprt_power": 0, "b_pf": 0, "b_freq": 0, "c_current": 0.104, "c_voltage": 239.7, "c_act_power": 0, "c_aprt_power": 25.2, "c_pf": 0, "c_freq": 50, "n_current": null, "total_current": 0.328, "total_act_power": 0, "total_aprt_power": 25.234, "user_calibrated_phase": [] } 2024-03-28 13:09:38.466 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/emdata:0 { "id": 0, "a_total_act_energy": 0.04, "a_total_act_ret_energy": 0, "b_total_act_energy": 0.05, "b_total_act_ret_energy": 0, "c_total_act_energy": 0.07, "c_total_act_ret_energy": 0.2, "total_act": 0.16, "total_act_ret": 0.2 } 2024-03-28 13:09:38.468 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/eth {"ip":null} 2024-03-28 13:09:38.470 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/modbus {} 2024-03-28 13:09:38.475 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/mqtt {"connected":true} 2024-03-28 13:09:38.477 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/sys { "mac": "MAC_address_redacted", "restart_required": false, "time": "13:09", "unixtime": 1711591778, "uptime": 1, "ram_size": 240520, "ram_free": 121936, "fs_size": 524288, "fs_free": 192512, "cfg_rev": 11, "kvs_rev": 0, "schedule_rev": 0, "webhook_rev": 0, "available_updates": {}, "reset_reason": 3 } 2024-03-28 13:09:38.479 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/temperature:0 { "id": 0, "tC": 47.7, "tF": 117.8 } 2024-03-28 13:09:38.482 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/wifi {"sta_ip":"Shelly_IP_redacted","status":"got ip","ssid":"SID_redacted","rssi":-62} 2024-03-28 13:09:38.484 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/ws {"connected":false} 2024-03-28 13:09:38.487 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/status/mqtt {"connected":true} 2024-03-28 13:09:38.490 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/events/rpc { "src": "shellypro3em-MAC_address_redacted", "dst": "shellypluspro3em-MAC_address_redacted/events", "method": "NotifyFullStatus", "params": { "ts": 1711591778.07, "ble": {}, "cloud": { "connected": false }, "em:0": { "id": 0, "a_current": 0.115, "a_voltage": 0, "a_act_power": 0, "a_aprt_power": 0, "a_pf": 0, "a_freq": 0, "b_current": 0.109, "b_voltage": 0, "b_act_power": 0, "b_aprt_power": 0, "b_pf": 0, "b_freq": 0, "c_current": 0.104, "c_voltage": 239.7, "c_act_power": 0, "c_aprt_power": 25.2, "c_pf": 0, "c_freq": 50, "n_current": null, "total_current": 0.328, "total_act_power": 0, "total_aprt_power": 25.234, "user_calibrated_phase": [] }, "emdata:0": { "id": 0, "a_total_act_energy": 0.04, "a_total_act_ret_energy": 0, "b_total_act_energy": 0.05, "b_total_act_ret_energy": 0, "c_total_act_energy": 0.07, "c_total_act_ret_energy": 0.2, "total_act": 0.16, "total_act_ret": 0.2 }, "eth": { "ip": null }, "modbus": {}, "mqtt": { "connected": true }, "sys": { "mac": "MAC_address_redacted", "restart_required": false, "time": "13:09", "unixtime": 1711591778, "uptime": 1, "ram_size": 240596, "ram_free": 123484, "fs_size": 524288, "fs_free": 192512, "cfg_rev": 11, "kvs_rev": 0, "schedule_rev": 0, "webhook_rev": 0, "available_updates": {}, "reset_reason": 3 }, "temperature:0": { "id": 0, "tC": 47.7, "tF": 117.8 }, "wifi": { "sta_ip": "Shelly_IP_redacted", "status": "got ip", "ssid": "SID_redacted", "rssi": -62 }, "ws": { "connected": false } } } 2024-03-28 13:09:38.493 luup.shelly:207: ShellyPlus: shellypluspro3em-MAC_address_redacted/events/rpc { "src": "shellypro3em-MAC_address_redacted", "dst": "shellypluspro3em-MAC_address_redacted/events", "method": "NotifyStatus", "params": { "ts": 1711591778.07, "mqtt": { "connected": true } } } 2024-03-28 13:09:38.539 luup.shelly:207: ShellyGen2: shelly-gen2-cmd/rpc { "id": "0x55902bb480", "src": "shellypro3em-MAC_address_redacted", "dst": "shelly-gen2-cmd", "result": { "ble": { "enable": false, "rpc": { "enable": false }, "observer": { "enable": false } }, "cloud": { "enable": false, "server": "iot.shelly.cloud:6012/jrpc" }, "em:0": { "id": 0, "name": null, "blink_mode_selector": "active_energy", "phase_selector": "all", "monitor_phase_sequence": false, "reverse": {} }, "emdata:0": {}, "eth": { "enable": true, "ipv4mode": "dhcp", "ip": null, "netmask": null, "gw": null, "nameserver": null }, "modbus": { "enable": false }, "mqtt": { "enable": true, "server": "server_IP_address_redacted:1883", "client_id": "shellypro3em-MAC_address_redacted", "user": null, "ssl_ca": null, "topic_prefix": "shellypluspro3em-MAC_address_redacted", "rpc_ntf": true, "status_ntf": true, "use_client_cert": false, "enable_rpc": true, "enable_control": true }, "sys": { "device": { "name": null, "mac": "MAC_address_redacted", "fw_id": "20240223-141900/1.2.2-g7c39781", "discoverable": true, "eco_mode": false, "profile": "triphase", "addon_type": null }, "location": { "tz": "redacted", "lat": redacted, "lon": redacted }, "debug": { "level": 2, "file_level": null, "mqtt": { "enable": false }, "websocket": { "enable": false }, "udp": { "addr": null } }, "ui_data": {}, "rpc_udp": { "dst_addr": null, "listen_port": null }, "sntp": { "server": "time.google.com" }, "cfg_rev": 11 }, "temperature:0": { "id": 0, "name": null, "report_thr_C": 5, "offset_C": 0 }, "wifi": { "ap": { "ssid": "ShellyPro3EM-MAC_address_redacted", "is_open": true, "enable": false, "range_extender": { "enable": false } }, "sta": { "ssid": "SID_redacted", "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 } }, "ws": { "enable": false, "server": null, "ssl_ca": "ca.pem" } } } 2024-03-28 13:09:38.540 luup.shelly:207: New Shelly announced: shellypro3em-MAC_address_redacted 2024-03-28 13:09:38.542 luup.create_device:: [30004] D_GenericShellyDevice.xml / / D_GenericShellyDevice.json (GenericShellyDevice) 2024-03-28 13:09:38.542 luup.attr_set:: 30004.ip = 2024-03-28 13:09:38.542 luup.attr_set:: 30004.mac = Shelly_IP_redacted <-- loaded with correct value 2024-03-28 13:09:38.542 luup.attr_set:: 30004.model = shellypro3em 2024-03-28 13:09:38.542 luup.attr_set:: 30004.firmware = 20240223-141900/1.2.2-g7c39781 2024-03-28 13:09:38.956 openLuup.server:: request completed (6784 bytes, 1 chunks, 11054 ms) tcp{client}: 0x558fe2b248
A few notes.
- You have to enable "Generic status update over MQTT" in the device's web page to get things to work. Same as for the H&T device. It defaults to disabled from the factory.
- Subscribing to "ShellyPlus: shellypluspro3em-MAC_address_redacted/events/rpc" and looking for "method": "NotifyFullStatus" results in pretty much all the information needed. Same as for the H&T device.
- It would be nice if the log pretty printed big json blocks. Could possibly just pretty print if the json string was say greater than 40 characters?
Here is the "method": "NotifyFullStatus" for the H&T device:
{ "src": "shellyplusht-MAC_address_redacted", "dst": "shellyplusht-MAC_address_redacted/events", "method": "NotifyFullStatus", "params": { "ts": 1.47, "ble": {}, "cloud": { "connected": false }, "devicepower:0": { "id": 0, "battery": { "V": 0.43, "percent": 0 }, "external": { "present": true } }, "ht_ui": {}, "humidity:0": { "id": 0, "rh": 50.9 }, "mqtt": { "connected": true }, "sys": { "mac": "MAC_address_redacted", "restart_required": false, "time": null, "unixtime": null, "uptime": 1, "ram_size": 246472, "ram_free": 167120, "fs_size": 458752, "fs_free": 192512, "cfg_rev": 15, "kvs_rev": 0, "webhook_rev": 0, "available_updates": {}, "wakeup_reason": { "boot": "deepsleep_wake", "cause": "status_update" }, "wakeup_period": 600, "reset_reason": 8 }, "temperature:0": { "id": 0, "tC": 24, "tF": 75.2 }, "wifi": { "sta_ip": "Shelly_IP_redacted", "status": "got ip", "ssid": "SID_redacted", "rssi": -68 }, "ws": { "connected": false } } }
Immediately above is the "method": "NotifyFullStatus" for the H&T device.
-
Could you give the latest development version a go?
It should work without your above edits, but I haven’t customised the device yet.
What variables does that give you?Using the default prefix "shellypro3em" I now get these variables. Previously there were none. See below. For the attributes I get firmware version, model number, MAC address but no IP address.
em/0/a_act_power 0 em/0/a_aprt_power 0 em/0/a_current 0.028 em/0/a_freq 0 em/0/a_pf 0 em/0/a_voltage 0 em/0/b_act_power 0 em/0/b_aprt_power 0 em/0/b_current 0.027 em/0/b_freq 0 em/0/b_pf 0 em/0/b_voltage 0 em/0/c_act_power 0 em/0/c_aprt_power 6.4 em/0/c_current 0.027 em/0/c_freq 50 em/0/c_pf 0 em/0/c_voltage 236.6 em/0/id 0 em/0/total_act_power 0 em/0/total_aprt_power 6.409 em/0/total_current 0.082 em/0/user_calibrated_phase [] emdata/0/a_total_act_energy 0.06 emdata/0/a_total_act_ret_energy 0 emdata/0/b_total_act_energy 0.06 emdata/0/b_total_act_ret_energy 0 emdata/0/c_total_act_energy 0.12 emdata/0/c_total_act_ret_energy 0.38 emdata/0/id 0 emdata/0/total_act 0.24 emdata/0/total_act_ret 0.38 temperature/0/id 0 temperature/0/tC 46.7 temperature/0/tF 116
Note the device does not have the current clamps connected around anything. ie it's just powered up.
-
My strong recommendation is not to change the default device MQTT prefix. It would just make setting up each device a total hassle. I've gone with defaults wherever possible, the only mandatory chamge being the IP address of openLuup's MQTT server.
I hadn't appreciated that the Pro devices don't identify as "shellyplus" and I can fix that.
@akbooer said in openLuup: Shelly Bridge plugin:
My strong recommendation is not to change the default device MQTT prefix. It would just make setting up each device a total hassle. I've gone with defaults wherever possible, the only mandatory chamge being the IP address of openLuup's MQTT server.
I hadn't appreciated that the Pro devices don't identify as "shellyplus" and I can fix that.
I usually modify them in order to better track/debug them. No need to include shelly in the device name, when you already have to base topic.
-
Using them as RGBW at the moment. But I can see them also being used just as white strips. Whether that would be four strips - don't think so. One strip would be enough at each location for my needs.
It's surprising how much current they can run through the device given its size.
-
Using them as RGBW at the moment. But I can see them also being used just as white strips. Whether that would be four strips - don't think so. One strip would be enough at each location for my needs.
It's surprising how much current they can run through the device given its size.
Just to complicate things: in addition to the 3em pro - I've got a shelly pro em 50 turning up in the mail.
-
I tried out the new update: "Development Branch: 2024 Release 4.5". Nothing too badly broken so that's good. I notice the H&T devices now have new variable names ie humidity/0/rh and temperature/0/tC, etc. These no longer show up in AltUI or console at Home-->Devices. Likewise with the 3em pro: em/0/a_voltage, etc
No doubt a work in progress but the forward slashes are a bit problematic eg they can't be part of a whisper filename.
-
Delimiters are always a problem. I tried initially with ‘:’, but UPnP already took that. However, it’s not intended that you use these directly; they are simply transcriptions from the MQTT topics. As with other Shellies, the key variables get copied to the MiOS equivalents, possibly in child devices, so that everything works.
I am making progress with the RGBW, and remember just how much I hate the way MiOS tries to handle them… and on top of that, AltUI has its own quirks.
-
Yes, thanks.
BTW, "Generic status update over MQTT" should not need to be ticked, now.
You will also have seen that you can use luup.openLuup.pretty() directly.
-
-
Had a look at the latest development code. Got this:
2024-04-20 18:51:28.519 openLuup.userdata:: [9111] LuaView (GitHub.master) 2024-04-20 18:51:28.519 openLuup.userdata:: [9281] Virtual HTTP Devices (GitHub.master) 2024-04-20 18:51:28.519 openLuup.userdata:: [4226] Sonos (GitHub.v2.0) 2024-04-20 18:51:28.519 openLuup.userdata:: ...user_data loading completed 2024-04-20 18:51:28.519 openLuup.init:: running _openLuup_STARTUP_ 2024-04-20 18:51:28.525 scheduler.context_switch:: ERROR: [dev #0] ./openLuup/luup.lua:1103: attempt to index field '?' (a nil value) 2024-04-20 18:51:28.525 openLuup.init:: ERROR: ./openLuup/luup.lua:1103: attempt to index field '?' (a nil value) 2024-04-20 18:51:28.525 openLuup.init:: init phase completed
Had to get the house back up and running, so we could watch the TVeee.
Commented out some code:
local function log (msg, level) local dno = scheduler.current_device() -- local mute = devices[dno].attributes.log_level -- 2024.04.12 add "log_level" device attribute local mute = "something" if mute ~= "off" then logs.send (msg, level, dno) end end
Could look further but had to get the house back up and running, so we could watch the TVeee. So best I can do currently!