What I want to do is change the payload on/off toggle based on its state,
I see lots of syntax using {{%… but when I use this the payload is the {{%… text
I cant see how to either use a variable as the payload and set it based on the current state, or programmatically set the state text within the assignment
To clarify,if the MQTT value is off I want to change it to on and if on change it to off when the button is pressed, HA knows it as sensor.ChargeTime/0000 and as I said the above works, and updates the MQTT broker, with whatever I have after the payload: be it fixed text or {{% logic
I can pass the segment to to scrip and it works in the MQTT topic, but I cant see how to format it so that the is_state(‘sensor.chargetime_0000’, ‘on’) so that the 0000 can also be replaced with the {{segment}} value im passing