I have connected HA to my MQTT broker. Connection works. As I want to use some information on another system, I want to write data from a HA sensor to the MQTT broker.
I have a sensor called
sensor.blitzortung_lightning_counter
which can assume a number of 0 and above. Now whenever it changes, I would like to write it into the MQTT topic
HA/lightning_counter
Is there any code which I can put into the configuration.yaml to do this? Can you help me with this?
You need an automation for this, read the docs first here.
The trigger will be your sensor changing state and the action will be publishing the state to an MQTT topic.
Thank you both. What I have found after I created an automation, is mqtt_statestream, which does what I need and which also has a quite straight forward configuration.