Shellies Discovery Script

@bachoo786 You have to add to your automations.yaml file exactly automations like in OP. You don’t have to know MAC and ID of your Shelly.

I have done that and I get my shelly all integrated in mqtt but if I restart my HA, it says unavailable if I restart it HA again it becomes available. It’s very flaky I am not sure why

It’s completely normal. When the Shellies Announce automation is started for the first time, the device is integrated with the HA, at the second start of automation device is checked for availability. This happens only after installing the script.

I am afraid mine doesn’t work the way you described

How does it work in your case?

So if I reboot my HA it would appear as it’s working with all the entities appearing correctly. However if I was to reboot my HA again it would say unavailable just like now see below:

I am running HA in docker as well as my mqtt. I have done a chmod -R 777 to your python script as well.

I think I know the problem

The automation needs to contain initial_state: 'on' so that everytime it HA restarts the script runs automatically.

On a different note do you get your shelly dropping wifi ? My shelly 1pm mosy of the time drops wifi for 30second to a minute before reconnecting to the internet. I have reset the shelly but experience the same problem

Yes, the Shellies Announce automation must always be run at the start of HA. Do you turn it off manually? HA shouldn’t turn it off. You can use initial_state: 'on' to be sure that automation will be run every HA start.

I have Shelly1 and Shelly2 and they never disconnect from the WiFi network.

yes I have added initial_state: 'on' and it works fine now.

my only criticism of shelly is that it drops wifi occasionally which is annoying. The distance between the router and the shelly is less than 5 meters.

how did you set your shelly up once you wired and installed it ?

also I have this entity from your script discovery Shelly1PM 60971A Energy 0 but the levels are always 0. Do you know if this is supported in your script or in shelly pm1?

When the energy meter will be greater than 0 then the value of the sensor will be greater than 0. The sensor displays the value in kWh, so some energy consumption is needed to display anything greater than 0. You have to remember that the Shelly restart causes the energy meter to be reset.

New version: 0.8.7

Changelog:

  • Add some abbreviation topics to Shelly RGBW2 config topic

Please anyone with Shelly RGBW2 to check that everything works well.

New version: 0.8.8

Changelog:

  • Partialy remove abbreviation topics to Shelly RGBW2 config topic

Thanks for your component.
I am just using in the discovery automation:

data_template:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      shelly1-XXXXXX-relay-0: 'light'

But my shelly1 is in any case in the switch group (switch.shelly1_XXXXXX_relay_0).
Is it correct?

If the letters are in the XXXXXX they should be upper case.

1 Like

Thanks.
It works nice!

New version: 0.8.9

Changelog:

  • lower case letters can be used in relays ID

New version: 0.8.10

Changelog:

  • Add abbreviation value for position_topic (HA 0.93 required)

New version: 0.9.0

Changelog:

  • Add support for Shelly Plug S