MQTT discovered devices automation

I’m new at Home Assistant and I’am trying to disover possibilities of HA.
I created two python script to emulate a MQTT auto-disocery capable switch and light endpoint.
Both are discovered by HA and work properly.
I tried to make two automation (ON/OFF) with automation editor to link the switch to the light but never worked. If I activate its manually the light turn on or off, but if I emulate a switching from the python script or the web UI the automations were not triggered.

Is there any limitations for auto-discovered entities automation?
Or what did I do wrong?



Bit difficult toi say without any code to check. Please follow the instructions in the blue banner at the top of the page when posting your automation code.

I have working discovered MQTT devices with manually added (yaml) automations. So no general issue with discovered devices.

OK, I found the problem. It works now.
I published from the script “ON” or “OFF” state but the state is “on” or “off” in HA. So the states are case sensitive strings, but I don’t understand why change my published upper case state to lower case? Or it is defined in switch component?


Sounds like you are confused between the mqtt published message (upper case in your example) and switch state (always lower case).