Shellies Discovery Script

I think perhaps you misunderstood my point: The script currently requires a FW that is not available on all devices, which means it doesn’t work on those devices at all. The availability of a reboot-button is secondary, imho.

Also, when I press the reboot button in HA on my 1.11.7 SHDM-1 devices, they immediately reboot. The Restart button does nothing except where I have 1.11.8, but what’s the difference? It appears I have two buttons to update firmware and two to restart.
image

Edit: I have downgraded the discovery script to 0.45.8. Will upgrade once 1.11.8 is available for all my devices, and will in the future be extra wary about upgrades when breaking changes are not mentioned explicitly. I hate having errors in my logs.

This script from the beginning requires the newest Shelly firmware. It is written in restricted python and this causes some limitations. If there is no current firmware available for your device you should ask Shelly support about this.
I’m currently on vacation, when I come back I’ll try to reduce minimum firmware version for SHDM-1.

Aha, I was not aware that the script has always required the latest FW. Can’t remember having this kind of issue before, but perhaps I haven’t been paying enough attention. Anyway, as long as it is clear from the release notes which version is a requirement, I don’t think there is any need to take special considerations.

I would suggest to include the phrase “Requires FW x.xx.x” at the top of the release notes to make it clear that it is an absolute requirement. Otherwise it can easily be interpreted that the release simply adds support for the new FW. Or alternatively use the same version number as the FW it is based upon, e.g. 1.11.7-0.42.7, 1.11.8-0.43.8 etc.

Cheers, and have a nice vacation!

Information about the required version of the firmware can be found in the changelog. I admit, this time I forgot about it :wink:

Updated:

Thanks!

Hello, hope you had/are having a great vacation @Bieniu. I’m not sure what I’m missing, but I can’t get them to be discovered. I’ve updated the firmware on all devices to 20220209-092750/v1.11.8-g8c7bb8d. I have read through all the docs and this forum for answers, but I keep getting the same illegal discovery warning in the logs. I’m running HA Core in Docker, updated to 2022.2.9 as well.

Logger: homeassistant.components.mqtt.discovery
Source: components/mqtt/discovery.py:104
Integration: MQTT (documentation, issues)
First occurred: 8:09:23 PM (514 occurrences)
Last logged: 8:21:29 PM

Received message on illegal discovery topic 'homeassistant/sensor/Back Porch Light-ext-temperature-1/config'
Received message on illegal discovery topic 'homeassistant/sensor/Back Porch Light-ext-temperature-2/config'
Received message on illegal discovery topic 'homeassistant/sensor/Back Porch Light-ext-humidity-0/config'
Received message on illegal discovery topic 'homeassistant/binary_sensor/Back Porch Light-firmware-update/config'
Received message on illegal discovery topic 'homeassistant/binary_sensor/Back Porch Light-ext_switch/config'

Any help would be appreciated!

I think spaces are not allowed in config topics. You have to replace spaces with _ or - in the custom MQTT prefix.

Yep! That worked for the one I changed the name of. Thanks for the suggestion

hi, is it possible to have Shelly1 integrated as light instead of switch? I already changed the appliance type to “light” like written here Shelly - Home Assistant (home-assistant.io) but I think in this Automation that doesn’t work like that.

Yes, please read the documentation.

1 Like

Currently, four (4) switches are created for the Shelly Button 1: Shortpush, Double Shortpush, Triple Shortpush, and Longpush.

Is it possible for the script to create a single entity for the Shelly Button 1 with the payload (output?) being the state?
For example:

shelly_button_1.state = {single | double | triple | long}

…similar to the Shelly integration “click types” listed here: Shelly - Home Assistant.

@Rickerdo Core Shelly integration doesn’t create sensor entity with state single|double|triple|long.

I recommend to use device automation instead of binary sensor states.

I was using the Shelly integration as an example to make a point, so the semantics are irrelevant.

I’m just looking for a simple way to trigger on a Shelly Button 1 click based on what type of click was received - be it a single, double, triple, or long without so many new entities being required. Is it possible to do this?

Yes, you have to use device automation.

I have added a Shelly 3EM using the script. Some entities have appeared. How long should it take until the device shows up under “Energy”?

I’m an idiot, they don’t show up automatically. The ones that are there I added myself under Configuration > Dashboards > Energy.

I am having issues running this script to discover a Shelly 1 on my network. I can subscribe to the events in the MQTT broker and see all the events its sending so its definitely not an issue with the broker or the shelly. I have updated everything in Home Assistant to the latest version and this is the error i get when i go to run the script:

Logger: homeassistant.components.python_script.shellies_discovery.py
Source: components/python_script/__init__.py:224
Integration: Python Scripts ([documentation](https://www.home-assistant.io/integrations/python_script), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+python_script%22))
First occurred: 11:22:38 AM (2 occurrences)
Last logged: 11:31:19 AM

Error executing script: host value None is not valid, update shellies_discovery automation

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute exec(compiled.code, restricted_globals) File "shellies_discovery.py", line 1598, in <module> ValueError: host value None is not valid, update shellies_discovery automation

Please read this error once again:
host value None is not valid, update shellies_discovery automation.

I have updated the script to the latest version available on Github manually. Do i need to input information about the Shelly device i am trying to discover into the script so it can be located?

Please update shellies_discovery automation, not the script.

I figured out where i was confused. I got the automation configured in the .yaml file and it found the Shelly after a restart and running both the automations. Thank you for the assistance!

1 Like