Shellies Discovery Script

Hi. Thanks for sharing your script.

I just installed it and I can see the announce and discovry scripts being executed. However, my shellies aren’t visible in HASS. I can see each Shelly repsond to the announce request using mosquitto_sub.

I’m using hass 0.9.4

Do You have MQTT Discovery enabled and the same discovery_prefix in MQTT configuration and script?

I left the scripts in tact and added the following to my config:

mqtt:
  broker: 192.168.0.4
  discovery: true
  discovery_prefix: homeassistant

I am using the mosquitto broker add-on

Any errors in log?

I reinstalled the broker add-on and now it works right away! I probably didn’t enable discovery when I first installed it. Sorry for wasting your time. But thanks anyway.

MQTT documentation is confusing AF to a beginner like me :confused:

New version: 0.9.3

Changelog:

  • fix overtemperature topic for Shelly2.5 and Shelly 1PM
  • change manufacturer to Allterco Robotics

@Bieniu

I’ve tried to run your script but unfortunately it did not work. I’m new to home assistant any python script so I must have made an error somewhere.

I’ve put your script without changing any variable here: /config/python_scripts/shellies_discovery.py

the 2 automations I’ve copy pasted here: /config/automations.yaml

and in /config/configuration.yaml I’ve added: python_script:

but under config --> integration --> mqtt it still tells me that there are no mqtt devices. Using MQTT Explorer app, the shelly mqtt stream is showing up

Thanks!

Did you add MQTT configuration to HA with enabled discovery option?

When I added MQTT to integration I’ve checked the “discovery checkbox”. I have now also added this to configuration.yaml:
mqtt:
discovery: true
discovery_prefix: homeassistant

but it did not make any difference. Do I have to add the “homeassistant” prefix somewhere to the shelly config? or do I have to make any changes to the python script?

MQTT configuration in configuration.yaml isn’t needed if you added MQTT via integration.
Do you have service mqtt/publish in HA?

Do you have any errors related to MQTT in HA log?
Please show me your Shellies Discovery configuration.

yes service mqtt/publish is showing up the same as on your screenshot.

I’m getting this error several times:
2019-06-14 13:02:16 WARNING (Thread-2) [homeassistant.components.mqtt] Disconnected from MQTT (1). Trying to reconnect in 300 s

Where can I find the Shelly Discovery configuration?

Thank you!

This error means that HA is disconnected from MQTT broker. You have to fix that.
Configuration of the script should be in automation.yaml.

thank you, I’ll look into getting rid of the error.

I’ve now started from scratch, deleted everything and made a new hassio installation with your script and everything is showing up correctly as it should! Thanks

Another question: I have a shelly 2.5 but each relay is controlling a different room. When going into configuration, integration and mqtt, I can only select an area for the whole shelly 2.5 but I would like to select an area for each relay. How can I do this? Thanks

You can only change area for devices, not for entities. It’s HA limitation.

1 Like

Hi all

I’m having issue with this script from yesterday.

It seems that it’s not working, while my shellies are. I’ve defined my roller shutter in the cover.yaml file manually and they are available and working.

Previously I had all the shelly discovered as shelly_shsw_...

In the MQTT Integrations I see twice the same shelly

one as “da Shelly” the other “da Alterco Robotics”

Previously I had a sensor for the rssi and as attribute also the IP address, now I don’t see them anymore.

I have the MQTT definition in the configuration.yaml

I’ve downloaded again the python script, just to be sure to have the latest version.

I’m on Hassio 0.94.3

11

What can I check more?

Thanks

I had this issue once. It occurs when the discovery script is not run for a long period of time and the Shelly software is updated. For some reason HA creates a new device after the update. So far, I don’t know how to eliminate this issue. The solution is to manually remove the device from the device registry with HA stopped (file /config/.storage/core.device_registry).

Thanks @Bieniu

I have HA always on, just in these 2-3 days I had some issue with electricity, but the NUC is under UPS, so I’ve always (I hope) shutdown it properly and was off for some hours, but never more than 10hrs, not days.

It seems an aggressive method, but if this is the only way I will try to understand it better tomorrow.

When you say HA has to be stopped, you mean to stop via cli like **

hassio ha stop

**

HA is installed in Docker.

Thanks

PS:

You mean to remove all the entries of any shellies like this?

    {
        "area_id": null,
        "config_entries": [
            "xxxxxxx"
        ],
        "connections": [],
        "hub_device_id": null,
        "id": "xxxxxxx",
        "identifiers": [
            [
                "mqtt",
                "xxxxxxxxx"
            ]
        ],
        "manufacturer": "Shelly",
        "model": "Shelly1",
        "name": "Shelly1 xxxxxx",
        "name_by_user": null,
        "sw_version": "20190311-121907/v1.4.8@e44d9e2c"
    },

really strage that this entry has the memory of a shelly with fw 1.4.8 an now I have all of them at 1.5.0

PS PS:

I see that the word Shelly is also in the file core.entity_registry and in the file core.restore_state

Yes, you have to use hassio ha stop command and remove this device. Shelly2 is on your screenshot but Shelly1 is in JSON. Remove correct device.
After remove the device check the file via https://jsonlint.com and of course before that make a snapshot!!!
You should ignore core.restore_state file.

Magically, but strangely, this morning everything returned to work without doing anything.

Really odd!