Shellies Discovery Script

What device? ShellyHT?

Shelly 2.5 .

i am really happy about how it performs is really fast and show the states immediately

It’s normal temperature for Shelly2.5 relays. It is in Celsius.

Hi,

Many thanks for your script! I don’t know what happens but I have ended up with two entities configured for a single shelly1pm. One of them looks fine with all devices (energy, sensor, etc.) included and works like a charm. However the other one just shows as an entity (same name) but with no devices associated. Is this normal? Can I delete it?

Regards,

I don’t know what the reason for this issue is.It happened twice in my system. In both cases after Shelly firmware upgrade. In the first case, after several HA reboots, the empty device disappeared by itself. In the second case, I had to manually remove them from the device registry.

I think it was also related to firmware updates in the Shelly.

How did you end up deleting it? I have restarted HA several times but the entity is still there. Also I cannot delete it from “configuration/entity registry” as it does not appear there (only the devices associated to the correct entity appear). Thanks!

I enabled the script (python_script: at configuration.yaml), copied the script at the appropiate subdir, created the automations, and restarted a few times. However, I dont get any new entity created. I have all shellies configured (working flawlessly for far) using hassio MQTT addon server, which is configured using “discovery: true”.

This is what I get at logger, which looks fine for me (all shelies are there)

2019-08-29 19:32:46 INFO (SyncWorker_15) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-93A6C5', 'mac': 'BCDDC293A6C5', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:47 INFO (SyncWorker_9) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-942484', 'mac': 'BCDDC2942484', 'fw_ver': '20190821-094851/v1.5.2@4148d2b7', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:47 INFO (SyncWorker_14) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-554520', 'mac': 'B4E62D554520', 'fw_ver': '20190821-094851/v1.5.2@4148d2b7', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:48 INFO (SyncWorker_5) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-2C0F9F', 'mac': '3C71BF2C0F9F', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:48 INFO (SyncWorker_11) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-554C42', 'mac': 'B4E62D554C42', 'fw_ver': '20190821-094851/v1.5.2@4148d2b7', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:48 INFO (SyncWorker_0) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-259ACE', 'mac': 'CC50E3259ACE', 'fw_ver': '20190821-094851/v1.5.2@4148d2b7', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:48 INFO (SyncWorker_17) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-55600D', 'mac': 'B4E62D55600D', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:49 INFO (SyncWorker_7) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-BA1DD6', 'mac': 'A4CF12BA1DD6', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:49 INFO (SyncWorker_4) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-B9F9D2', 'mac': 'A4CF12B9F9D2', 'fw_ver': '20190821-094851/v1.5.2@4148d2b7', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:49 INFO (SyncWorker_16) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shellyrgbw2-2BB0B8', 'mac': '3C71BF2BB0B8', 'fw_ver': '20190415-132833/v1.4.9-hotfix3@1a30f929', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:49 INFO (SyncWorker_3) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-BA057E', 'mac': 'A4CF12BA057E', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:49 INFO (SyncWorker_12) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-59E19E', 'mac': 'B4E62D59E19E', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}
2019-08-29 19:32:49 INFO (SyncWorker_8) [homeassistant.components.python_script] Executing shellies_discovery.py: {'id': 'shelly1-BA6AD4', 'mac': 'A4CF12BA6AD4', 'fw_ver': '20190819-120540/v1.5.1@69c3ba74', 'discovery_prefix': 'hasshelly', 'temp_unit': 'C', 'qos': '2'}

However, no entities are shown at Configuration -> Integrations -> Mqtt Addon.

[Solved, last restart made te entities appear :slight_smile: ]

To delete device from devices registry:

  • stop Home Assistant
  • make a backup of folder /config/.storage
  • find devices registry file /config/.storage/core.device_registry
  • find “empty” device and delete it
  • valid file (ex. https://jsonlint.com/)
  • start Home Assistant

Many thanks again! Deleting the entry from /config/.storage/core.device_registry solved the problem. However, after re-starting home assistant now I have another (rather small) issue. In MQTT / Integrations, now not all entities appear associated to the shelly1pm device.

For instance, the switch, temperature and power sensors do not appear in the integration. They do appear in the device registry and work fine in HA just they does not seem to be associated with the device.

As I said, all works fine but maybe it can be a problem later?

Regards,

You probably removed the device that was not “empty” but the one to which the entities belonged. The easiest way to solve this is to stop HA and remove all Shelly1PM from the device registry and all entities of this Shelly from entities registry /config/.storage/core.entity_registry. After starting HA, everything should be added again.

I just realised that everything is OK when I visit HA from my phone (all sensors are associated to the shelly device in the “integrations/mqtt” page. However, they do not when I visited the same page using chrome on macos. Maybe a cache problem somewhere but definitely out of this script…

Thanks again for your work, soon I am going to add several (+10) shellies in my home so I will test your script extensively XD

It have to be cache porblem.

Great. If you find any issues I will try to fix them.

how can I delete all previously discovered shellies so I can add all from scratch?

You have to remove entities from Configuration -> Entity Registry, remove MQTT integration and restart HA.

you know how to have the cost day and month of consumption with a Shelly ?

New version: 0.11.3

Changelog:

  • add “ac_power” argument for ShellyH&T (if using USB adapter)
  • cleaning code

Hi,

just received a newsletter from shelly with a bunch of new products released!
Are they going to be supported? Really looking for Doors & Windows sensor!

Yes I will try to add support for new devices but it will take time.
Unfortunately, Shelly is very slowly updating the API docs page. I was also ignored by their support when I asked for some extra documentation.

It is a real pity Shelly is behaving like that.
I recently move down from MQTT integration (for shellies) to your custom component and it was a quantum leap forward!

I think we should make them aware of this thread?

Hmm Shellies Discovery is MQTT integration. If you mean about Shelly Smart Home custom component you are in wrong thread :wink: