MQTT and Shellies_Discovery_Gen2 not running?

I’m struggling with the discovery of my Shellies, ok I only have H&T and Smoke, yet.

I feel that I have done everything correctly (Mosquitto broker, MQTT, Python, and the YAMLs, but the devices won’t appear.
As they are battery driven (even USB connected) I woke them up and run Shellies Announce Gen2 manually, but still no device. I only see the MQTT integration itself

configuration.yaml
python_scrippt: added

Python script shellies_discovery_gen2.py is under config/python_scripts

automation.yaml
I even added my known three devices under device ids

device_ids: # enter the list of device IDs (MQTT prefixes) here
  - shellyhtg3-e4b3232f910c
  - shellyhtg3-e4b323309d20
  - shellyplussmoke-2cbcbbf7568c

I see the Shellies in Mosquitto

With MQTT Explorer I see the correct values of the devices, connecting every 5 minutes (H&T) and delivering them

In the Automation I see both
Shellies Announce Gen2
Shellies Discovery Gen2

but I only have traces for Announce, but none for Discovery.
It seems it won’t be triggered ?
The docs saying it cannot be run manually as it need the variables passed.

litte bit clueless …

Devices should respond to the shellies_discovery topic, but that one is not visible in your screenshot.

How to debug

I can see shellies_discovery in the RPC part

The Python debug is not giving errors …

2026-01-04 11:06:44.392 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Running automation actions
2026-01-04 11:06:44.392 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeating sequence: Iteration 1 of 3 with item: 'shellyhtg3-e4b3232f910c'
2026-01-04 11:06:44.398 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Running automation actions
2026-01-04 11:06:44.398 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Executing step call service
2026-01-04 11:06:44.399 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Initialized trigger Shellies Announce Gen2
2026-01-04 11:06:44.399 INFO (MainThread) [homeassistant.components.automation.shellies_discovery_gen2] Initialized trigger Shellies Discovery Gen2
2026-01-04 11:06:44.407 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Executing step call service
2026-01-04 11:06:44.447 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeating sequence: Iteration 2 of 3 with item: 'shellyhtg3-e4b323309d20'
2026-01-04 11:06:44.447 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Running automation actions
2026-01-04 11:06:44.448 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Executing step call service
2026-01-04 11:06:44.461 INFO (MainThread) [homeassistant.components.automation.shellies_announce_gen2] Shellies Announce Gen2: Repeat at step 1: Executing step call service

No, you can see the messages that Shellies Discovery sends to the device, you can’t see the response. Probably your MQTT config is wrong.

I feel there is not much I can configure, checked various “tutorials”

When I test the wildcard “#” listener in “Listen to a topic
the Shellies are contributing towards MQTT

How should MQTT behave from here, where do I need to check that everything is ok with my MQTT settings?

Shelly device must send the response to the shellies_discovery topic.
Remember that battery-powered devices (even if powered by USB) must be awake when the announce automation is triggered.

I’m aware of it and already tried. Doing it again tonight.

hello world script is working…

If I try to run the py script, the action task response:

The action python_script.shellies_discovery_gen2 could not be executed. Error executing script (KeyError): ‘id’

You cannot run this script manually, it needs data from the device response.

Show me your Shellie’s discovery automations and a screenshot from the MQTT configuration from device’s web UI.

Thank you for your quick response.

  • Ahh, okay. The script is working, I got all the shellies in my MQTT integration.
1 Like

success

I was inpatient with such 3 seconds press on the H&T to get it really awaken. I was under the impression that a fresh power on does the same :thinking:

Thanks for accompany me @Bieniu

1 Like