Node Red Momentary Switch

I was searching for momentatry switch and found nothing I could use. I thought I’d post my work here. I created this flow.

When you turn it on, it will trigger an action and turn off.

It creates a Switch in Home Assistant
image

image

to make it unique,

  1. change the “name” values in the My Switch element
  2. change the Entity ID in the Trigger and Turn Off elements
  3. replace the yellow and pink elements with your desired service/action.

You can import this within Node Red.

[{"id":"f012c7fb.d76df8","type":"trigger-state","z":"f69946fd.2ac1b8","name":"My Switch Trigger","server":"cd4403b5.968d1","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.my_switch","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"odgjh18ppkk","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"id":"sr5e2tlj04","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":530,"y":720,"wires":[["69ef9e4.27b156","387cc7d7.1c98a8"],[]]},{"id":"69ef9e4.27b156","type":"api-call-service","z":"f69946fd.2ac1b8","name":"Turn Off My Switch","server":"cd4403b5.968d1","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.my_switch","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":790,"y":740,"wires":[[]]},{"id":"41975c3.22290a4","type":"mqtt out","z":"f69946fd.2ac1b8","name":"","topic":"OpenZWave/1/command/setvalue/","qos":"","retain":"","broker":"250eeee2.afada2","x":1080,"y":700,"wires":[]},{"id":"9e5e096b.d2ef28","type":"ha-entity","z":"f69946fd.2ac1b8","name":"My Switch","server":"cd4403b5.968d1","version":1,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"My Switch"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:account-arrow-left"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":310,"y":720,"wires":[[],[]],"outputLabels":["allowed","blocked"],"icon":"node-red/arduino.png"},{"id":"387cc7d7.1c98a8","type":"change","z":"f69946fd.2ac1b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"ValueIDKey\":281476526391348,\"Value\":29}","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":700,"wires":[["41975c3.22290a4"]]},{"id":"cd4403b5.968d1","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"250eeee2.afada2","type":"mqtt-broker","z":"","name":"192.168.1.8","broker":"192.168.1.8","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]