Hi, I have an MQTT Switch, which works fine, my issue is I want HA to recognise when the MQTT broker is unavailable and hence make the MQTT switch “unavailable” or “unknown” in the UI.
HA knows when the MQTT switch (not broker) is offline via the MQTT will_message, that works fine.
I have a number of MQTT Sensors that detect when the MQTT broker is offline via the "expire_after: " under the sensors’ yaml config. The “expire_after” command is not an option for an MQTT switch
in yaml
This is the relevant config,.
switch:
- platform: mqtt
name: "Hydronic Heater"
state_topic: "hydronic_heater"
command_topic: "hydronic_heater_set"
availability_topic: "hydronic_heater_available"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
payload_available: "online"
payload_not_available: "offline"
optimistic: false
qos: 0
retain: false
mqtt:
discovery: false
broker: 192.168.20.100
keepalive: 30
birth_message:
topic: 'hass/status'
payload: 'online'
will_message:
topic: 'hass/status'
payload: 'offline'