I use MQTT statestream communication to exchange states between two Home Assistant instances. This worked fine with sensors. But I failed with a switch, initially set up by the Community Add-on “AdGuard Home”. I’m able to read the switch state from the MQTT broker, but fail to set the switch to a a new state. My initial guesses like “set”, “ON”, etc. dont work. My code snipplets:
mqtt_statestream:
base_topic: rp42
include:
entities:
- switch.adguard_protection
(Switch)
- platform: mqtt
name: "adguard_protection_137"
state_topic: "rp42/switch/adguard_protection/state"
command_topic: "rp42/switch/adguard_protection/set"
payload_on: "on"
payload_off: "off"
state_on: "on"
state_off: "off"
optimistic: false
retain: true
A clumsy workaround with an additional input_boolean (coupling with a template switch and automations) is working, but painfull to look at.
Suggesions to find a solution, in particular finding the right command_topic string, are appreciated.