How to get a Trigger:State node not to trigger on HA restart or entity registration?

Using NodeRed Entity nodes, I’ve defined a custom set of entities to control an old proprietary Lutron lighting system in my house. It turns out it will take clear text http commands to control the lights, but it does not communicate state, so i basically have to create a set of glorified toggles and ignore any implied state that HA tries to impose.

In any case, it actually works, but one weird thing with this setup is that any time I register an entity or restart HA, it seems to execute all of my trigger:state nodes, which has the annoying side effect of cycling through all the lights in the house multiple times.

Is there a simple way to stop this from happening? So far my Google searches have come up short. FWIW, I do NOT have ‘Output on Connect’ checked in the Trigger: State nodes (which it sure seems like it’s ignoring?)

BTW I’m running NodeRED 1.2.9 on HA 2021.3.4

For context, I’ve included an example entity/trigger flow below:

[{"id":"6baddd51.25d47c","type":"ha-entity","z":"21041dc9.7a09a2","name":"Office Test","server":"592207ea.3b9af8","version":1,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"lutron test"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:light-switch"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":860,"y":400,"wires":[[],[]]},{"id":"f9622e15.814d68","type":"api-call-service","z":"21041dc9.7a09a2","name":"Office Test","server":"592207ea.3b9af8","version":1,"debugenabled":false,"service_domain":"switch","service":"toggle","entityId":"switch.lutron_test","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":640,"y":400,"wires":[[]]},{"id":"b373125f.d3cb18","type":"trigger-state","z":"21041dc9.7a09a2","name":"","server":"592207ea.3b9af8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.lutron_test","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":1120,"y":400,"wires":[["9053576e.000368"],[]]},{"id":"9053576e.000368","type":"http request","z":"21041dc9.7a09a2","name":"Press Office Off","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.2.121","tls":"","persist":false,"proxy":"","authType":"","x":1400,"y":400,"wires":[[]]},{"id":"ff4c9801.5e35b","type":"inject","z":"21041dc9.7a09a2","name":"Press","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":400,"wires":[["f9622e15.814d68"]]},{"id":"592207ea.3b9af8","type":"server","name":"Home Assistant","addon":true}]

Instead of trigger state node please use a event state node, it can control such problems.

1 Like

Thank you!

I’m embarrassed by how easy that was. To be clear, the fix was to change to an Event State node and then set “Ignore state change event when”:

  • Previous state doesn’t exist
  • Previous state is unknown
  • Previous state is unavailable