Manual lists this configuration example:
on_connect / on_disconnect Trigger
This trigger is activated when a connection to the MQTT broker is established or dropped.
mqtt:
# ...
on_connect:
- switch.turn_on: switch1
on_disconnect:
- switch.turn_off: switch1
I made following mqtt config, on_message works, but on_connect and on_disconnect triggers show in editor popups like “[on_connect] is an invalid option for [mqtt]. Please check the indentation. No indentation correction fix the problem”. No indentation modifications help. What is wrong with on_connect in my config?
mqtt:
broker: "192.168.0.2"
username: "!secret"
password: "!secret"
id: mqtt_client
topic_prefix: ral/ral-esp8266-relay1
birth_message:
topic: mqtt/online
payload: 'true'
will_message:
topic: mqtt/online
payload: 'false'
on_connect:
- mqtt.publish:
topic: conf/flash_duty_on
payload: "500"
on_message:
- topic: control/buzzer_mute_on
then:
- switch.turn_on: sw_buzzer_mute