Pass data through nodes?

Hi,

I just started creating an alarm automation:

(this is just a start, very basic right now)

When the email is sent, it uses the name of the originating sensor node as a topic, however msg.payload is armed_away (as it leaves the “Alarmcheck” node). I would like to have the state of the triggering node in the payload instead, is that possible? How?

I found a way to accomplish what I want by using two outputs at the state node and routing them through different ways, where I change the payload to open or closed for the email text.

However I’m still interested in learning if I can access the payload from the trigger node after it passed the state check…

here how I did it, maybe can give you some ideas

[{"id":"8cdeea4.e1c5c18","type":"trigger-state","z":"5b8207c0.dcb8c8","name":"Motion","server":"e447d17a.16a64","entityid":"motion","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"id":"o01vdgeqsa9","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":70,"y":60,"wires":[["64aa5cac.4c7fc4"],[]]},{"id":"56093b73.0cf864","type":"api-call-service","z":"5b8207c0.dcb8c8","name":"trigger alarm","server":"e447d17a.16a64","version":"1","service_domain":"alarm_control_panel","service":"alarm_trigger","entityId":"alarm_control_panel.ha_alarm","data":"{\"code\":XXXX}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":490,"y":40,"wires":[[]]},{"id":"64aa5cac.4c7fc4","type":"api-current-state","z":"5b8207c0.dcb8c8","name":"armed away?","server":"e447d17a.16a64","version":1,"outputs":2,"halt_if":"armed_away","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"alarm_control_panel.ha_alarm","state_type":"str","state_location":"data.state","override_payload":"msg","entity_location":"data.entity","override_data":"msg","blockInputOverrides":false,"x":260,"y":60,"wires":[[],["56093b73.0cf864","6d0b47a.432a3b8"]]},{"id":"5b0741d4.02313","type":"function","z":"5b8207c0.dcb8c8","name":"Trigger Message","func":"var sensorname = msg.data.event.new_state.attributes.friendly_name;\nvar alerttime = msg.timestamp;\nvar trigmessage = \"Alarm triggered: Motion detected by \" + sensorname + \" at \" + alerttime + \"!\";\nflow.set (\"trigger_message\",trigmessage);","outputs":1,"noerr":0,"x":770,"y":100,"wires":[[]]},{"id":"6d0b47a.432a3b8","type":"moment","z":"5b8207c0.dcb8c8","name":"","topic":"","input":"data.event.new_state.last_changed","inputType":"msg","inTz":"Europe/Amsterdam","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm","locale":"POSIX","output":"timestamp","outputType":"msg","outTz":"Europe/Amsterdam","x":520,"y":100,"wires":[["5b0741d4.02313"]]},{"id":"e447d17a.16a64","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
1 Like

Thank you, will check it out :slight_smile: