Shellies Discovery Script

Some of us experienced slow downs and re-connections with previous version. This one is rock solid for me.

1 Like

Thanks for the info. Did the update immediately.

getting this error in the log file

Logger: homeassistant.components.python_script.shellies_discovery.py
Source: components/python_script/__init__.py:221
Integration: Python Scripts (documentation, issues)
First occurred: 11:55:47 PM (1 occurrences)
Last logged: 11:55:47 PM

Error executing script: id value None is not valid, check script configuration
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 221, in execute
    exec(compiled.code, restricted_globals)
  File "shellies_discovery.py", line 513, in <module>
ValueError: id value None is not valid, check script configuration

Can anybody tell me what’s wrong ?

Solved this , there was a copy-paste error within the config.yaml.

Now there’s no error in the log, but also none shelly’s whe where “detected” of avaliable in the MQTT integration :S

When i start a listening to: shellies/# there are some showups like : Message 31 received on shellies/shellybadkamer/overtemperature

So there’s some MQTT traffic i supose , what’s the next thing to troubleshoot this ?

This is the automation.yaml for now:

- id: shellies_announce
  alias: 'Shellies Announce'
  trigger:
    - platform: homeassistant
      event: start
    - platform: time_pattern
      hours: "/1"  # Modifying this if you are using Shelly Motion can drain your device's battery quickly.
  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 }}'
      mode: '{{ trigger.payload_json.mode | default }}'

We need debug log for to help you. Look here GitHub - bieniu/ha-shellies-discovery: Script that adds MQTT discovery support for Shellies devices

i have a lot of flood sensors, and after a reboot ha they are all unavailable until the next update, I see the values in the mqtt, why is ha not updated?

Show me debug log for python_script component.

Hi,

Am building a new HA instance and am slowly getting to grips with how everything is supposed to work. This weekend I planned to get MQTT up and running so I can start deploying Shelly units - I want MQTT as I have some Zigbee sensors that will also use MQTT, and from what I’ve read the MQTT approach to Shellies means a very fast no-lag response.

As a first step I’ve started with the H&T units as they’re a (relatively) easy way to get the MQTT stuff working and there’s no need to mess with the power in the house yet. On paper this should all have been pretty straightforward but in reality…let’s just say that I’ve been beating my head against various walls for two straight days trying to get this to work. :frowning:

  1. I believe I have the Shelly discovery script properly set up (installed python as instructed, tested with HelloWorld, installed Shelly Discovery via HACS, copied and pasted the configs from the instructions to configuration.yaml and automations.yaml). The H&T units are discovered and added under Config > Integrations

  2. Data looks like it is getting through because the MQTT log also has entries like this:
    1623548735: New connection from 192.168.20.70 on port 1883.
    {“result”: “ok”, “data”: {}}1623548735: New client connected from 192.168.20.70 as shellyht-1E67D4 (p2, c1, k60, u’mqttuser’).

  3. I can confirm this using MQTT Explorer where I see data coming through with time stamps and it is doing this nice little trend.

  4. If I go to Config > Integrations > Mosquitto Broker > Configure and listen to shellies/# I can see data coming through.

  5. I can see my discovered Shellies listed as devices and entities in the Mosquitto Broker integration (they appeared as soon as I changed my automation.yaml discovery prefix to ‘homeassistant’)

But the way I see it now I think I have three problems:

A. Everything is listed twice
I expected that the devices would just appear (after a lengthy battle) but when they did I started seeing double!

I have these ‘Shelly Integration’ device entities:

sensor.study_h_t_battery
sensor.study_h_t_humidity
sensor.study_h_t_temperature

and

I have these ‘MQTT’ device entities:

sensor.shelly_h_t_study_battery
binary_sensor.shelly_h_t_study_firmware_update
sensor.shelly_h_t_study_humidity
sensor.shelly_h_t_study_ip
sensor.shelly_h_t_study_temperature

I don’t understand why I’m ending up with duplicates, I don’t know how they relate to each other…and I don’t know what this behaviour will mean when I start loading in shelly switches…

B. The ‘Shelly Integration’ sensors do not update
If I add a Lovelace card for the Shelly Integration devices they get the value at the point of integration, but they never update…not for HOURS, not even if the temperature changes. I can see the changes coming though on the MQTT Explorer and in the MQTT ‘Listen’ but nothing changes on the card. Ever.

In contrast, the MQTT device entities do update and if I add them to a Lovelace card I get updates all the time!

C. The MQTT updates seem to be very frequent
I have the update threshold set to 1C, but I’m regularly seeing updates of just 0.1C…and more than could be accounted for by parallel changes in humidity…as I understand it the Shellies should be asleep so I shouldn’t get any updates unless the temp or humidity changes by 1C or 5%. At time these updates are coming through in five minute intervals…which is also very strange.

Having added / removed / reinstalled for two days straight (to be fair it took a day to get it going because it is all so new) I’m at the point where I need to ask for help…

I’m running:

  1. HA OS running on a NUC (core-2021.6.3) - so everything is managed/containerised
  2. MariaDB as the database (seems to be working fine)
  3. Mosquitto Broker 6.0.1
  4. The lastest Shelly Script from HACS

There’s no obvious errors in the Supervisor log
There’s no obvious errors in the MQTT log
There’s no obvious errors in the Log Viewer
There’s no obvious errors anywhere…at least not the fat red ones…

What the heck am I missing?

Cheers,
CP.

Probably you configured devices with core Shelly integration and with the Shellies Discovery. If you prefer to use MQTT, simply remove core integration configs.

Hmmmm…maybe that’s it. I clicked on the Shelly core integration to read the documentation like you do in HACS (there wasn’t any) so then I just cancelled it. I didn’t add any devices…

So now I know that any integration you click on is immediately installed…even if it turns out you don’t need it…so now I need to figure out how to get rid of an integration I can’t see to stop it from always getting in the way…

Fun times.

I can’t seem to add my Shelly Duo - RGBW. I see that Duo is supported but I suppose not the RGBW version then?

So this was my bad. I’m going to keep my post here in case someone else mess up like I did. Make sure to have the latest firmware!

1 Like

Hello,

I use Shelly and MQTT on HA, i don’t find problème.

A friend have the same installation like me. But the Shelly don’t appear in HA:

  • Installed mosquitto add-on

  • Created user in user configuration

  • Set up integration (it now points to the add-on)

  • Run pyhon shelly discovery automations

  • Reboot HA

  • Shelly active MQTT and set up

Python script is ok.
Mosquitto MQTT is ok with MQTT Explorer.

Shelly status:
wifi_sta":{“connected”:true,“ssid”:“Freebox-690CD0”,“ip”:“192.168.1.124”,“rssi”:-59},“cloud”:{“enabled”:false,“connected”:false},“mqtt”:{“connected”:false},"

I have 2 Shelly with MQTT activated, none appear into HA intĂŠgration ou Supervisor Logs.

Any idear what i’m doing wrong ?

The device is not connected to the MQTT Broker.

Thanks for your answer and all you do for community :+1:

Ok, I understand the Shelly is not connected to MQTT, but why ? I don’t have any error… And all parameters look ok. Need help !!! :sob:

Check MQTT broker log and the device log.
You can enable Shelly log in the device web panel, Settings → Device Info → Enable Debug Log

New version: 0.40.0

Changelog:

  • remove mode argument for Shelly 2/Shelly 2.5 BREAKING CHANGE
  • use voltege topic for voltage sensor (Shelly 2/Shelly 2.5)
  • add light transition

Requirements:

  • firmware 1.11.0

Hi All,
i’m using Shellies Discovery since few months, i prefer it to standard integration.

Today i updated the shellies firmwares and it’s a mess.

First issues was that 2 shelly2.5 used as roller shutter stopped to be recognized as roller.
I delete them from HA, run an shelly announce and restarted HA with no luck.

now i have deleted all my shellies but they are not recognized well.

Every one has only few entities like this one

any ideas what happened?

Thanks

Yes, you have not read the changelog.

out of curiosity: what changed in v1.11 regarding mqtt?