Using mqtt explorer check the topics around the device. If you see something like commands or cmnd you may be able to publish to that topic and change things.
But what am I supposed to define as trigger? Generate a dummy device which I can set to on or off?
So this would be my first attempt for the automation header:
automation:
# Publish to the mqtt topic a JSON message
trigger:
- # What do I have to use as trigger? a dummy device which gets set to a new value (ie 100)?
# action will be used to perform the publishing
action:
- action: mqtt.publish
topic: /device/cmd/ # the mqtt topic where I want to publish
payload: >-
{ "name": "haoscmd",
"unixtime": <INSERT current Unix time here>,
"relais": { "r_wp": <INSERT 1 or 0> }
}
Is this correct so far? Do I have to create seperate actions for 0 or 1? How do I insert the current unix time?
This is a trigger which runs every minute. You can use choose to do different actions based on conditions within one automation or 2 different automations. You can trigger the publish anyway you want as it’s very flexible. Yes you can use an Input Boolean “a dummy device” to trigger.
Your YAML isn’t formatted correctly. Use the visual editor in automations to guide you. I don’t know how to insert the unix time but I suspect you would use sensor.time entity.
Still missing is the parameter to insert after the timestamp. But I guess I can use the state() command from my dummy device.
I.e. user switches on the dashboard the dummy device to “ON” the mqtt will be using the new value then.
I guess I am done here so far as the rest I am going to figure out on my own.