Shellies Discovery Script

With or without HT configuration I have all three sensors:

2020-05-15 08:34:28 DEBUG (SyncWorker_3) [homeassistant.components.python_script.shellies_discovery.py] Send to MQTT broker: qwerty/sensor/shellyht-012365478-temperature/config {"name": "Shelly H&T 012365478 Temperature", "stat_t": "~sensor/temperature", "unit_of_meas": "°C", "dev_cla": "temperature", "val_tpl": "{{value|float|round(1)}}", "exp_aft": 43200, "frc_upd": "False", "uniq_id": "shellyht-012365478-temperature", "qos": 1, "dev": {"ids": ["012365478"], "name": "Shelly H&T 012365478", "mdl": "Shelly H&T", "sw": "20190402-134544/v1.5.1@9be72c7e", "mf": "Allterco Robotics"}, "~": "shellies/shellyht-012365478/"}
2020-05-15 08:34:28 DEBUG (SyncWorker_3) [homeassistant.components.python_script.shellies_discovery.py] Send to MQTT broker: qwerty/sensor/shellyht-012365478-humidity/config {"name": "Shelly H&T 012365478 Humidity", "stat_t": "~sensor/humidity", "unit_of_meas": "%", "dev_cla": "humidity", "val_tpl": "{{value|float|round(1)}}", "exp_aft": 43200, "frc_upd": "False", "uniq_id": "shellyht-012365478-humidity", "qos": 1, "dev": {"ids": ["012365478"], "name": "Shelly H&T 012365478", "mdl": "Shelly H&T", "sw": "20190402-134544/v1.5.1@9be72c7e", "mf": "Allterco Robotics"}, "~": "shellies/shellyht-012365478/"}
2020-05-15 08:34:28 DEBUG (SyncWorker_3) [homeassistant.components.python_script.shellies_discovery.py] Send to MQTT broker: qwerty/sensor/shellyht-012365478-battery/config {"name": "Shelly H&T 012365478 Battery", "stat_t": "~sensor/battery", "unit_of_meas": "%", "dev_cla": "battery", "val_tpl": "{{value|float|round}}", "exp_aft": 43200, "frc_upd": "False", "uniq_id": "shellyht-012365478-battery", "qos": 1, "dev": {"ids": ["012365478"], "name": "Shelly H&T 012365478", "mdl": "Shelly H&T", "sw": "20190402-134544/v1.5.1@9be72c7e", "mf": "Allterco Robotics"}, "~": "shellies/shellyht-012365478/"}

Please turn on debug for python_script.

Hi Bieniu,

I’m not a good programmer, so I will try to refrain myself from attempting to help you on your github.
Could you add an item to the discovered shellies when you create them in Home Assistant:

  • Sensor for new firmware (it’s announced as new_fw)
  • Toggle button to allow for publishing “update_fw” to the command of the affected shelly.

I noticed today that my newly arrived shelly had a 2019 firmware and a new 2020 firmware was ready to be installed. I used a manual automation to do it right now accross all shellies (topic: shellies/command) but it would be more nice to use topic “shellies/shellyXXXXXXX/command” to target the specific device only.

I’m loving the script you’ve made. Instant plug and play!

Shellies don’t send the announce topic periodically so I think that it makes no sense to create sensors that will not automatically receive data from the devices. When Shelly Dev Team adds periodically sent announce or info topics (they announced that last year), then I will add such sensors.

But we can fake that with an automation? Send a periodic ‘update’ to shellies/command. Say like every 24 hours. Now with the Shellies Announce Automation you’ve set this on restart of HASS, why not set this to a 24h timeframe?

Not having that ‘toggle’ to send a update_fw could be ok. But having a sensor to show if new_fw is set to true would be awesome. Above ‘dirty’ hack of the automation could make this refresh of info happen?

I’m just curious to what’s possible and if this could be tweaked a bit so it’s usable.

Honestlly I don’t like this solution. Payloads of configuration topics are very large. With a large number of Shelly devices, the MQTT broker is flooded with mass of data. We should not repeat this more often than necessary.

You can use these sensors home-assistant-config/sensors.yaml at 057293cb091316bc3ac05b26bd5086a8720fee6e · bieniu/home-assistant-config · GitHub and this automation home-assistant-config/automations.yaml at 057293cb091316bc3ac05b26bd5086a8720fee6e · bieniu/home-assistant-config · GitHub

1 Like

ty! I’ll look into using this.

New version: 0.20.0

Changelog:

  • add support for Shelly Vintage

Hi Bieniu,

I’ve encountered another small Issue I can’t seem to find. Sorry to bother you with this question.
My dimmer slider is not showing up on a normal Shelly Dimmer (not rgbw).

What am I doing wrong in discovery. Is there any parameter I need to set for this?

Light is on/off only? Debug log please.

cat home-assistant.log| grep "2020-05-20 11:02:2[1-2]"

https://pastebin.com/hV9z2vxn
Output is in a pastebin, as the logging superseeded the 32.000 character boundry of this post.

Also another observance:
I have to run the shelly announce automation twice.
First time I get to see the devices in Home-Assistant, but they’re unusable:


“Niet beschikbaar” meaning “unavailable”

When I run the announce automation a second time, it’ll become available.
In this case I specifically went to the webinterface and put the light on to see it being updated with the correct light status. Brightness was set manually to 67%, but that didn’t trigger setting up any slider.

Edit number 3… Figured out that filtering on the script alone won’t tell you everything, you need the full logging of what happens in Homeassistant as well. Here you go. Updated logging. (PART 1)

It’s normal.

So brightness works or not? I don’t understand. Thera are no errors in your log. Everything looks good.

I set the brightness “manually” inside the web-interface of the shelly itself:

So I didn’t set this via Home-Assistant.

After fiddling around a bit I found that I had to click through on the entity card to get to the brightness setting:

It’s not a setting I apparently can set to see immediately. Sorry for the trouble :frowning:
I guess I have a bit more to learn and find out on how to present this slider directly on the entity card.

You can use this https://github.com/custom-cards/light-entity-row or this https://github.com/ljmerza/light-entity-card

It’s not related with the script.

Apologies, I am not using this script.
Wrong topic.

I will delete my previous post.
Thanks for your quick response.

No problem.

Thnx, HACs is on my installation now and that “light-entity-row” or “slider-entity-row” is golden!

Thanks!

New version: 0.21.0

Changelog:

  • add support for Shelly Air

Hello all
my python script is not working and i dont have any error.
I put python_script: in config. I created a python_scripts folder in the root and put the script inside…

How can i check?

See here https://github.com/bieniu/ha-shellies-discovery#troubleshooting-checklist