Trigger node - send payload & topic

I have a flow controlling a light which I control via Google Home voice commands, to MQTT, to a tasmota remote device.

If I tell google to switch the device on, it sends;
{"payload":"on","topic":"cmnd/sonoff2/POWER"} to the MQTT node.
...but, I don't want to forget to turn it off, so I've included a trigger node, and set it send another msg 5 minutes later to turn it off;

delay

..but it doesn't produce the correct msg format & fails, it produces;

{"payload":{"payload":"off","topic":"cmnd/sonoff2/POWER"},"topic":"cmnd/sonoff2/POWER"}

Where have I gone wrong?

instead of {"payload":"off","topic":"cmnd/sonoff2/POWER"}

As you would expect, as the trigger node sends a msg.payload not a msg.

Why not set the topic prior to the trigger and send both on and off from the trigger (to same or different outputs).
e.g.

[{"id":"b5db95460639fe7a","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":580,"wires":[["56e5fb6e81c96f21"]]},{"id":"56e5fb6e81c96f21","type":"change","z":"da8a6ef0b3c9a5c8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"tasmota/topic","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":580,"wires":[["86dfb82af7806939"]]},{"id":"86dfb82af7806939","type":"trigger","z":"da8a6ef0b3c9a5c8","name":"","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":500,"y":580,"wires":[["441b83f51eec6037"]]},{"id":"441b83f51eec6037","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":660,"wires":[]}]

Yes thanks @E1cid .
Shouldn't there be an option to send a complete msg object?

It does send a complete msg you just have to construct it beforehand, would be nice to be able to construct internally though. As it stands you can not sent a payload to a msg property either.

1 Like

Does the Sonoff have Tasmota?
Set PulseTime 1 to 400 and the relay should turn itself off 5 minutes after the last ON message. (Not specifically tsted with Sonoff but it's a basic Tasmota option.)

2 Likes

Thanks, I'd forgotten about that feature. It's probably a better solution because it's not dependent upon a reliable network, as once the command is received, it executes without further commands.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.