Shellies Discovery Script

I think that we should use off_delay parameter https://www.home-assistant.io/integrations/binary_sensor.mqtt/#off_delay

Yes! I agree that would solve the issue. Do you think it would it be possible to add it as an argument in the script configuration?

Thanks for looking into this.

New version: 0.13.3

Changelog:

  • add off_delay: 3 parameter to longpush binary sensor
  • fix RGBW2 effect list

Many thanks @Bieniu. Version 0.13.3 does indeed fix the longpush behavior.

Regards,

1 Like

Just used this script for Shelly 2.5 and Shelly Dimmer. Thanks it seems to work well. I did run into a few issues any ideas? These may just be shelly firmware issues.

  1. On the Shelly 2.5 the switch inputs (binary sensor 0 and 1) are inverted (connecting to live is off). Ticking the reverse option in the switch settings does not seem to address.
  2. A binary senor for the inputs is not created in the MQTT server. The input itself exists (shellies/shellydimmer-F36490/input/0). I cannot see a reason to run in detached mode? Why does it have two inputs?

Script uses state on for value 1 and state off for value 0 for input binary_sensor. Check values for your Shelly’s topics.

There isn’t information about input topic for Dimmer on Shelly API documentation page.

New version: 0.14.0

Changelog:

  • add support for Shelly Door/Window
1 Like

Hi all
i have had trouble setting this up, here is what i’ve done so far.
**34 **


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123

# Text to speech
tts:
** - platform: google_translate**

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
python_script:

logger:
** logs:**
** homeassistant.components.automation: info**

# Example configuration.yaml entry
#mqtt:
# discovery: true
# discovery_prefix: homeassistant

and in automations file

python_script:

automation:

  • id: shellies_announce
    alias: ‘Shellies Announce’
    trigger:

    • platform: homeassistant
      event: start
      action:
      service: mqtt.publish
      data:
      topic: shellies/command
      payload: announce
  • id: ‘shellies_discovery’
    alias: ‘Shellies Discovery’
    trigger:

    • platform: mqtt
      topic: shellies/announce
      action:
      service: python_script.shellies_discovery
      data_template:
      id: ‘{{ trigger.payload_json.id }}’
      mac: ‘{{ trigger.payload_json.mac }}’
      fw_ver: ‘{{ trigger.payload_json.fw_ver }}’

And logs from MQTT

[13:54:49] INFO: Setup mosquitto configuration
[13:54:49] WARNING: SSL not enabled - No valid certs found!
[13:54:49] INFO: Found local users inside config
[13:54:51] INFO: Initialize Hass.io Add-on services
[13:54:51] INFO: Initialize Home Assistant discovery
[13:54:51] INFO: Start Mosquitto daemon
1578837291: mosquitto version 1.6.3 starting
1578837291: Config loaded from /etc/mosquitto.conf.
1578837291: Loading plugin: /usr/share/mosquitto/auth-plug.so
1578837291: |-- *** auth-plug: startup
1578837291: ├── Username/password checking enabled.
1578837291: ├── TLS-PSK checking enabled.
1578837291: └── Extended authentication not enabled.
1578837291: Opening ipv4 listen socket on port 1883.
1578837291: Opening ipv6 listen socket on port 1883.
1578837291: Opening websockets listen socket on port 1884.
1578837292: Warning: Mosquitto should not be run as root/administrator.
1578837292: New connection from 192.168.1.177 on port 1883.
[INFO] found hassio on local database
1578837295: New client connected from 192.168.1.177 as mqtt_53856c09.3aa494 (p2, c1, k60, u’hassio’).
1578837300: New connection from 192.168.1.143 on port 1883.
1578837300: New client connected from 192.168.1.143 as DVES_6337F9 (p2, c1, k30, u’hassio’).
1578837300: New connection from 192.168.1.55 on port 1883.
1578837300: New connection from 192.168.1.90 on port 1883.
1578837300: New connection from 192.168.1.131 on port 1883.
1578837300: New client connected from 192.168.1.55 as DVES_B1D60C (p2, c1, k30, u’hassio’).
1578837300: New client connected from 192.168.1.90 as DVES_893B5A (p2, c1, k30, u’hassio’).
1578837300: New client connected from 192.168.1.131 as DVES_499E2F (p2, c1, k30, u’hassio’).
1578837305: New connection from 192.168.1.179 on port 1883.
1578837305: New client connected from 192.168.1.179 as shellyem-B9E43D (p2, c1, k60, u’hassio’).
1578837314: New connection from 192.168.1.95 on port 1883.
1578837314: New client connected from 192.168.1.95 as mqtt_51de11c9.0cc89 (p2, c1, k60).

Please format your post correctly and look here.

Hi
Shellies discovery is not available on HACS anymore and manual install doesn’t seem to work after latest hassio update

Not true

sorry my mistake I forgot to enable scripts on hacs install

1 Like

Thank you for making this!

1 Like

First, thanks for this great script!

I noticed an issue that seems to occur with newer Shelly 2.5. My Shelly 2.5 were not getting discovered while it s working fine for the other Shelly models. The device id has become longer than it is for the other Shelly. It is now 12 digits instead of 6 (e.g. “shellyswitch25-98F4ABF2D39C” vs. “shelly1-F42429”), which breaks the script.

I made a local change in line 184 (from “if id[:-7] == “shellyswitch25”:” to “if id[:-13] == “shellyswitch25”:” which got working for me, but may not be the cleanest solution as I suspect the device id format could also change for other Shelly devices in future.

There is no official information about change the length of the ID. This would be a breaking change for the script. You should ask Shelly support about that.

Actually I saw such information (in changelog or in discussion on FB). they extended it to full MAC address because of conflicts reported by users

Please try this version https://github.com/bieniu/ha-shellies-discovery/blob/228a7210b9fd85e7635b59a4f7182e7ad6953fef/python_scripts/shellies_discovery.py

Hi

Again thank you for the script. I works great but I have one problem regarding the cover positions on Shelly 2.5
Is it possible to get the Shelly 2.5 cover position info and position control?

I don’t know. Is it possible with manual MQTT configuration?

Yes I made it with Mqtt using these lines:

  • shellies/shellyswitch-<deviceid>/roller/0/pos reports the current position in percent
  • shellies/shellyswitch-<deviceid>/roller/0/command/pos accepts a number between 0 and 100, which is the target position in percent.

I did the calibration first
-shellies/shellyswitch-/roller/0/command/rc (performs roller calibration)