Shellies Discovery Script

Hi,

I have a shelly dw2. It works fine but some time the open close status doesn’t get updated correctly any more. For example in MQTT it is still open when the Shelly App and of course the window :wink: says that it is closed.

Any advice please.

Thanks

If the device reports an invalid state via MQTT then you should ask Shelly support for help.

Hi Bieniu,

first Shelly Button is still running strong!

Edit: After initial problems now also the 2nd button runs the automation fine!

Stills strange behaviour that HA does not pick up the diagnostics of all sensors, some entities it states were disbaled by the integration

This is not strange, but intended behavior. Those entities are disabled by default and you have to enable it yourself.

I’m using a Shelly 1 in detached mode with a Reed switch to operate my garage door.
I installed your script, the device was discovered and is working properly as a (inching) switch.

I’m not a super HA expert. Is there a way to discover the Shelly directly as an HA cover instead?

No, only Shelly 2 can be configured as a cover entity.

I was able to manually configure my Shelly 1 as a garage cover by adding the following to configuration.yaml:

# Manually configured MQTT Shelly 1 cover
mqtt:
  cover:
    - name: "Garage Door"
      unique_id: "dxdgarage"
      device_class: garage
      command_topic: "shellies/dxdgarage/relay/0/command"
      state_topic: "shellies/dxdgarage/input/0"
      qos: 0
      retain: false
      payload_open: "on"
      payload_close: "on"
      payload_stop: "on"
      state_open: "0"
      state_opening: "0"
      state_closed: "1"
      state_closing: "0"

but now I have sort of duplicated entities: cover and switch:

Just wondering if it’s possible to customize the shellies_discovery automation to create a garage cover instead of a switch.

Shelly 1 does not support roller mode so the script will not support a cover platform for this device.

1 Like

For some reason, migrating from old mqtt broker, updating home assistant, updating script itself… I’m stuck with two shelly dimmers that after announce have “mqtt”:{“connected”:false} in info payload.

If I manually change those to true in mqtt explorer and publish, they work as they should.

However, as soon as announce / discovery runs normally, they change back to mqtt connected false and I lose control of those two devices.

What do I lose if I disable the scripts completely, after I have added all my devices?

Hi
First let me thank you for writing and maintaining this!
I am a new HA user but have most things working so far, but not this…and have spent several hours reading trying/retrying this and the github docs and following a youtube on thnis. I have a couple basic initial questions:

  1. When I copy/paste the code into a new automation yaml, should I do 1/2 at a time, to create Announce and Discovery separately, or should a single paste recreate both?

  2. Whichever way I do it, when I paste and try to save, I get the error “Message malformed: extra keys not allowed @ data[‘0’]”. Searching this string I see that can mean the version of HA is not compatable with this. I an on a new install as a Proxmox VM…

Home Assistant 2023.7.1
Supervisor 2023.07.1
Operating System 10.3
Frontend 20230705.1 - latest

Here is the code I used (simply a paste)

- id: shellies_announce
  alias: Shellies Announce
  trigger:
  - platform: homeassistant
    event: start
  - platform: time_pattern
    hours: /1
  action:
    service: mqtt.publish
    data:
      topic: shellies/command
      payload: announce
- id: shellies_discovery
  alias: Shellies Discovery
  mode: queued
  max: 999
  trigger:
    platform: mqtt
    topic: shellies/announce
  action:
    service: python_script.shellies_discovery
    data:
      id: '{{ trigger.payload_json.id }}'
      mac: '{{ trigger.payload_json.mac }}'
      fw_ver: '{{ trigger.payload_json.fw_ver }}'
      model: '{{ trigger.payload_json.model | default }}'
      mode: '{{ trigger.payload_json.mode | default }}'
      host: '{{ trigger.payload_json.ip }}'

Thanks!!

It depends if you add automation via UI or edit YAML files manually. If you use UI then you have to add automations one at a time.

Hi Thanks for the reply. Yes, I was assuming pasting into yaml automations. By Your answer I am assuming I can past the script and it will create two automations: Announce and Discovery.

My bigger issue is the error I receive as posted above, as that prevents me from creating/saving the automations. I have also tried doing them through the UI. IN that case I can create them, but I dont get any devices/entities or see any evedence it is working. Do you have any idea why I would receive that based on my config listed or the code I showed (which is just a copy of the recommended minimal code).

Thanks

Troubleshooting list and How to debug sections ha-shellies-discovery/README.md at master · bieniu/ha-shellies-discovery · GitHub

thank you for that link I will try that and see if I can determine what the problem is.

Thanks

Is there a way to suppress the following message in HA log?

Invalid event type  for event.kuche_anrichte_button_0 received on topic shellies/ku_sw_anrichte/input_event/0, payload {"event_type":""}

Shelly 1 is configured with Button Type Edge Switch. So event_type will never be sent by the switch.

HA 2013.9.2 - on Raspi 4 - Mosquitto broker version: 6.3.1- old shellies discovery script. around 12 shellies gen 1.

My Shelly 1PM melt completely with a load of 3000W but here we reached 43°C this year (plastic housing melt, no clue why overtemperature show only OK) so I got a new one (hard to find as mo more stock).
I needed the old version because of old addon and temp sensor do not fit the new +1PM.
When it arrived I upgrade the fw to latest v1.14. and all the usual setting including MQTT.
so far so good. with MQTT Explorer I can see everything including shellies/shelly1pm-B903E8/ext_temperature/1 values.

In HA with this integration I could see all entities for shelly1pm-B903E8 but not the addon ext temp sensor entities. (despite being published by Mosquito) I don’t know why, and I could do with your help.

clues: the now dead 1PM was working fine with FW v1.10 and I had the ext. temp sensors entities.
I see some messages on Reddit for person having same trouble with FW v1.12.

I have a very old version of this python script (where do I see the version number? not sure how to update shelly discovery script ? (installed over 2 years ago)). is it just delete the old script and uploading the latest one ? no dependency will break ?

I didn’t update the script as I got the last of my 5 Shelly2.5 which refused FW update from v1.10. this WAR is now over. (bloody shelly Coit protocol who flood the network, Mqtt and #Bieniu script are a life saver)
I finally managed to have all Shelly in V1.13 or V1.14 so I am now happy to update Shellies discovery script.
One more question with Shelly with MQTT, could we untick coit (unicast, ip:5683) recommended with shelly integration ?
Thank you for your help.

ext-temperature-0: true? GitHub - bieniu/ha-shellies-discovery: Script that adds MQTT discovery support for Shellies devices

By HACS or manually GitHub - bieniu/ha-shellies-discovery: Script that adds MQTT discovery support for Shellies devices

Of course, CoIot is not needed.

Thank you Bienu for being here.

It’s working now with this addition in /config/automations.yaml
shelly1pm-B903E8:
ext-temperature-0: true
ext-temperature-1: true

but it was nothing here for the old 1PM when it was working, still mystery ???

Script update not done yet, 2 years ago you did help me a lot (more coffee coming your way tonight) and I did a bit of both (HACS & Manually) to finally succeed.
so if I try manual update I uploaded v4.5.2 open the ZIP file to find the script, then place it into /config/python_scripts/shellies_discovery.py is that OK? anything else ? (I do worry to break something)

Yes, you need to save shellies_discovery.py file to the /config/python_scripts folder. Remember that the newest version of the script requires Home Assistant 2023.9.0 or newer.

I encourage you to use HACS. thanks to it, you will receive script updates whenever they are available.

1 Like

Hacs it is ! all good
Thank you Bienu for your help.