Hi All,
My setup:
- B&R PLC publishing and subscribing from mosquitto broker.
- VM running HAS
- Using MQTT explorer to verify communication to the broker.
Goal:
Create a switch on my bash where I can switch a light on and off.
What I did in HAS:
Installed MQTT
Added the switch to my config file:
mqtt:
switch:
- unique_id: living_beam1_switch
name: "Living beam1"
state_topic: "homeassistant/living/beam1/switch"
command_topic: "homeassistant/living/beam1/switch/set"
availability_topic: "homeassistant/living/beam1/switch/available"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
optimistic: false
qos: 0
retain: true
The topics are visible in MQTT explorer. I also can publish to them through settings-> devices&services → Mosquitto broker.
So all fine until this point.
Now I want to add a button card. In the button card I can find my entity switch.living_beam1.
Now I start to struggle. What do I need to add in action and hold action?
When I take toggle, nothing happens
I can only get it partly working when I use the “Call service” - MQTT-publish and “hardcode” the topic and payload.
Issue is that I can not toggle the light in this case.
I hope somebody could guide me in the correct direction.
Thanks in advance.
Toon