Shellies Discovery Script

Now I know that the script is working. Check your MQTT broker with MQTT-Explorer. Do you see there topics from TRV?

This is not a log, this is a small part of the log.

I checked again and nothing regarding trv in shellies in MQTT explorerā€¦ so donā€™t know whatā€™s the real problemā€¦ other shellies do normal popup in logsā€¦ a little frustratingā€¦

Yes, Iā€™ve read it and this is exact the automation I use: Shellies Discovery Script - #1435 by panhans
Before I posted here Iā€™ve checked the latest docs and refreshed the two automations. :wink:

2022-01-12 20:10:27 INFO (SyncWorker_0) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'wohnzimmer_deckenlicht', 'mac': 'XXXXXXXXXXXX', 'fw_ver': '20211109-124958/v1.11.7-g682a0db', 'model': 'SHSW-1'}

As you can see in the info log entry no host is given in the json data. Maybe thats why the script generates that error.

So, Iā€™m stuckā€¦
slika

It seems as that TRV do not send any MQTT notificationā€¦

Maybe should I try somehow to direct communicate to TRV (name: shellytrv-kuhinja)ā€¦
Is that possibleā€¦ Maybe to make sensors manuallyā€¦

Looks like your TRV doesnā€™t communicate with the broker. Maybe wrong login/password?

Latest documentation is on GH GitHub - bieniu/ha-shellies-discovery: Script that adds MQTT discovery support for Shellies devices

Hi Bieniu

Thx for all your effort and work on this great script.

Yesterdays I upgraded to Version 0.43.5. A few minutes later my Energy Dashboard was no longer able to catch the Measure Data of my Shelly 3 EM. The System tells me that the last reset for those 3 sensors is missing. Could this be related to your changes in order to Refactor meter sensor in this Version?

Regards,

Dom

Please update the script.

Iā€™m trying to get this script working. I have one shelly device configured for MQTT (others are still using native integration). The device is discovered, but only has one entity (upgrade button). The logs show this error:

2022-01-14 17:06:28 INFO (MainThread) [homeassistant.components.automation.shellies_announce] Shellies Announce: Running automation actions
2022-01-14 17:06:28 INFO (MainThread) [homeassistant.components.automation.shellies_announce] Shellies Announce: Executing step call service
2022-01-14 17:06:28 INFO (MainThread) [homeassistant.components.automation.shellies_discovery] Shellies Discovery: Running automation actions
2022-01-14 17:06:28 INFO (MainThread) [homeassistant.components.automation.shellies_discovery] Shellies Discovery: Executing step call service
2022-01-14 17:06:29 INFO (SyncWorker_5) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-8CAAB555B17F', 'mac': '8CAAB555B17F', 'fw_ver': '20211109-124958/v1.11.7-g682a0db', 'model': 'SHSW-1', 'mode': '', 'host': '172.30.0.198'}
2022-01-14 17:06:29 DEBUG (SyncWorker_5) [homeassistant.components.python_script.shellies_discovery.py] id: shelly1-8CAAB555B17F, mac: 8caab555b17f, fw_ver: 20211109-124958/v1.11.7-g682a0db, model: SHSW-1
2022-01-14 17:06:29 DEBUG (SyncWorker_5) [homeassistant.components.python_script.shellies_discovery.py] {'topic': 'homeassistant/button/shelly1-8CAAB555B17F-update_firmware/config', 'payload': '{"name": "Shelly 1 8CAAB555B17F Update Firmware", "cmd_t": "~command", "payload_press": "update_fw", "en": "true", "uniq_id": "shelly1-8caab555b17f-update_firmware", "qos": 0, "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "dev": {"cns": [["mac", "8c:aa:b5:55:b1:7f"]], "name": "Shelly 1 8CAAB555B17F", "mdl": "Shelly 1", "sw": "20211109-124958/v1.11.7-g682a0db", "mf": "Allterco Robotics", "cu": "http://172.30.0.198/"}, "~": "shellies/shelly1-8CAAB555B17F/", "entity_category": "config", "dev_cla": "update"}', 'retain': True, 'qos': 0}
2022-01-14 17:06:29 DEBUG (SyncWorker_5) [homeassistant.components.python_script.shellies_discovery.py] Sending to MQTT broker: homeassistant/button/shelly1-8CAAB555B17F-update_firmware/config {"name": "Shelly 1 8CAAB555B17F Update Firmware", "cmd_t": "~command", "payload_press": "update_fw", "en": "true", "uniq_id": "shelly1-8caab555b17f-update_firmware", "qos": 0, "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "dev": {"cns": [["mac", "8c:aa:b5:55:b1:7f"]], "name": "Shelly 1 8CAAB555B17F", "mdl": "Shelly 1", "sw": "20211109-124958/v1.11.7-g682a0db", "mf": "Allterco Robotics", "cu": "http://172.30.0.198/"}, "~": "shellies/shelly1-8CAAB555B17F/", "entity_category": "config", "dev_cla": "update"}
2022-01-14 17:06:29 ERROR (SyncWorker_5) [homeassistant.components.python_script.shellies_discovery.py] Error executing script: name 'state_topic' is not defined
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 222, in execute
    exec(compiled.code, restricted_globals)
  File "shellies_discovery.py", line 3051, in <module>
NameError: name 'state_topic' is not defined

Is this a bug or have I done something wrong?

Already fixed, please update the script.

2 Likes

I will try today again from scratchā€¦
Hoping to resolve discovery problemā€¦

Hi,

Thank you so much for all the hard work on the script! I used it to successfully discover a shelly motion, but canā€™t discover my shelly UNI for some reason. I get the following error:

   Error executing script: Firmware dated 20210720 is required, update your device shellyuni-98CDAC24D66E

From the log:

2022-01-14 14:40:43 INFO (MainThread) [homeassistant.components.automation.shellies_discovery] Shellies Discovery: Running automation actions
2022-01-14 14:40:43 INFO (MainThread) [homeassistant.components.automation.shellies_discovery] Shellies Discovery: Executing step call service
2022-01-14 14:40:43 WARNING (MainThread) [homeassistant.helpers.frame] Detected integration that accessed discovery_info['properties'] instead of discovery_info.properties; this will fail in version 2022.6. Please report issue to the custom component author for remote_homeassistant using this method at custom_components/remote_homeassistant/config_flow.py, line 117: properties = info["properties"]
2022-01-14 14:40:43 INFO (SyncWorker_7) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyuni-98CDAC24D66E', 'mac': '98CDAC24D66E', 'fw_ver': '20210105-095645/release-1.9@8517d431+', 'model': 'SHUNI-1', 'mode': '', 'host': '192.168.0.183', 'discovery_prefix': 'homeassistant'}
2022-01-14 14:40:43 ERROR (SyncWorker_7) [homeassistant.components.python_script.shellies_discovery.py] Error executing script: Firmware dated 20210720 is required, update your device shellyuni-98CDAC24D66E
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 222, in execute
    exec(compiled.code, restricted_globals)
  File "shellies_discovery.py", line 1277, in <module>
ValueError: Firmware dated 20210720 is required, update your device shellyuni-98CDAC24D66E

Keep trying to update my firmware but it looks like I am on the latest shelly uni firmware:

FIRMWARE UPDATE
Current version: 20210105-095645/release-1.9@8517d431+
You have latest version on your device!

You can use this site http://archive.shelly-tools.de/ to update the firmware.

Hi Bieniu, thank you for the reply; I unfortunately tried that several times (including downgrading) and it was not working.

I figured out what my problem was - I didnā€™t realize I needed to enable cloud access to update the firmware and then could turn off cloud access after use the MQTT discovery script to keep everything local.

I hope this helps someone else with their troubleshooting. Thanks again!

1 Like

Gen2 devices script preview: GitHub - bieniu/ha-shellies-discovery-gen2

Work in progress so use with caution!

1 Like

Still no luck with TRV discoveryā€¦ the only discovery was the entity of new FW updateā€¦ but thinking that this has no relate to this script but to original shelly discoveryā€¦

Sorry I donā€™t understand. Please post a debug log if you need help.

First release of Shellies Discovery Gen2 is available here GitHub - bieniu/ha-shellies-discovery-gen2

Community thread: Shellies Discovery Gen2 Script

Dear all,

in an effort to improve my home assistant set-up, among other things I renamed all devices. The naming convention contains a dash, which does not work well with Your script.

Is there a way to use the Shelly device name in all length as the entity ID? If so how?

For example: Shelly device name 15-02-Blinds-WindowLeft (set on the device itself) should translate to cover.15_02_blinds_windowleft. And with it all related entities.

Is this something you can help with?