Shellies Discovery Script

Unfortunately, there is no easy way to remove MQTT device from HA. After adding device to ignored_devices, restarting HA and removing entities from entity registry, the device will still be present in integrations.
I saw on GitHub PR which will add the ability to remove MQTT devices from integration. You have to wait for it.

Not sure if it helps anyone, but I was able to remove the device after the shelly reboot. The reboot made the mqtt messages stop, which allowed deleting the retained messages. After restarting HA, the now greyed out entities could be deleted from the gui. Then I had to edit my device registry file by deleting the json for the shellydimmer device. After rebooting, the device is now gone for good. I wish it was easier; editing device registry for one seems a bit hacky. Would be nice we could simply delete a device from the integration via the gui, and that takes care of removing the device and entities… wishful thinking. I’m curious to see what that PR does.

@Bieniu @truglodite
Has either of you tested Zigbee2MqttAssistant? According to the features list, it should be able to remove (with forced remove) mqtt entities.

I wanted to test it in the next time, but for now, I haven’t, so can’t say if it works. :slight_smile:

Shellies Discovery is a script for python_script component. This component imposes huge restrictions, therefore only config topics can be removed from the broker by the script.

@truglodite Maybe we should take this into another thread, as it is more a mqtt-remove problem in general, than a shelly-discovery problem.

I found an older thread, with a guide to remove mqtt entries, here it is: [Guide] How to remove MQTT entity from Zigbee2mqtt, Mosquitto broker and Home Assisntant

I agree this isn’t really related to the shellies discovery script, and actually it isn’t related to mqtt removal either (I already read those threads and knew how to do it). If anything, this would be better in a shelly dimmer thread, due to the settings not sticking until after reboot problem that resulted in issues with the usual mqtt removal methods.

Hi.
After the last update I kepp getting this in the log.
Can you tell whats wrong or do I need to activate debug logger ?

Exception in discovery_callback when dispatching 'mqtt_discovery_updated_('binary_sensor', 'shellyswitch25-*******-overtemperature')': ({'name': 'Shelly2.5 ***** Overtemperature', 'state_topic': 'shellies/shellyswitch25-********/overtemperature', 'payload_on': '1', 'payload_off': '0', 'availability_topic': 'shellies/shellyswitch25-*********/online', 'payload_available': 'true', 'payload_not_available': 'false', 'device_class': 'heat', 'unique_id': 'shellyswitch25-**********-overtemperature', 'qos': '0', 'device': {'identifiers': ['******'], 'name': 'Shelly2.5 *******', 'model': 'Shelly2.5', 'sw_version': '20200309-104051/v1.6.0@43056d58', 'manufacturer': 'Allterco Robotics'}, 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/__init__.py", line 1186, in discovery_callback
    payload.pop(ATTR_DISCOVERY_HASH)
KeyError: 'discovery_hash'

It seems that this error isn’t related to Shellies Discovery. You can turn on debug and post the log here. Maybe I will find something that help you.

When I run the script it adds my shelly 2.5 as a relay. How can i force the script to add my shelly 2.5 as a cover?
The Shelly1PM and Dimmer work perfectly with this script

Please read the docs https://github.com/bieniu/ha-shellies-discovery/blob/master/README.md#arguments-for-shelly25

Hello,

I’m new to HA and MQTT and I have some problems with shelly working via MQTT.

First problem:
Discovery script don’t work. I make everything as described in instructions.

  • Installed shellies_discovery.py to python_scripts folder and add python_script: to configuration.yaml.
  • Add minimal configuration to automation.yaml
  • Configure shelly to mqtt:
  • Configure mosquitto broker:

In mosquitto broker LOG I can see that shelly is comunicating with broker:
“1586091984: New connection from 192.168.1.61 on port 1883.
1586091984: New client connected from 192.168.1.61 as shelly1-B9FACE (p2, c1, k60).”

  • Restart several times and there is NO shellies in integration.

Second problem:
I also tried manual adding shellies with code:

 - platform: mqtt
    name: "Kitchen Light mqtt"
    state_topic: "shellies/shelly1-B9FACE/relay/0"
    command_topic: "shellies/shelly1-B9FACE/relay/0/command"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    retain: false
    optimistic: false

After that I can add a button, but it is always OFF. Even if I press ON via button or via HA the button goes automaticaly back to OFF. The light didn’t turn ON.

With REST api everything work, but I want to MQTT start working.

What I am doing wrong?

Thanks.

Turn on debug for the python_script component and show me a log.

I put log on wetrransfer: https://we.tl/t-rH7uxpJ5oT

thx

Hello,

Please forgive me if this has been covered before. I tried to search but was not successful in finding answers.

I am using this amazing script and it is discovering all my devices. I am using a Shelly 1 for my garage doors and I have attached reed switches to them in hopes of detecting open/close states.

My confusion is how to use the information this script provides to create a card to display the open/close state. Any help would be appreciated.

Thank you

There is no information about running the Shellies Discovery script in your log.

Does Shelly1 support reed switches at all?

They do. Here is a url that has a guide that I was following in case it may help. https://www.sweharris.org/post/2019-05-19-garage/

Nie znałem tego rozwiązania. Nie znam żadnej karty frontendowej, która pokazywałaby taką konfigurację.

I don’t know what is wrong?

I put this to configuration.yaml:

logger:
  logs:
    homeassistant.components.python_script: debug

python_script:

Now I run both automation manualy in automation and there is a log file: https://we.tl/t-VlBVnNnwrc

Thx
David