Trigger nodered flow from script

I have create a nodered flow that return a tts message for alexa tell me the days of bin trash collect.
The flow run only if I imsert a manual trigger at the start of the flow.

Now i’d like to create an alexa routine from the alexa app: when i say: Alexa tell me trash day…
The flow must be run… But… How can I link this event?
I think best way is create an HA script… So i can view it as a SCENARIO in Alexa app (using Haaska)… But same question: how can I run the flow from the script?

I use an input boolean. In my case, I use Google Home to run a script that turns my input boolean on. My node red flow looks for a change of state of the input boolean and when it changes to on it runs the flow. At the end of my flow I call a service to change the input boolean to off.

Ok thanks. So i can check also for state change only… To on or to off… without set at the end of the flow input boolean to off. To simplify all… Is it true?

You can, but then the input boolean will stay on and the next time you want to run the flow there will be no state change because it is already on.

Using input_boolean.toggle on the script?

I did something similar to call a script from a routine in Alexa. The node red flow just checks to see if the script is turned on and then triggers it. The Script is automatically toggle back to off after being triggered.

34

56

This is an example:

In my configuration.yaml:

input_boolean:
  close_blinds:
    name: Close Blinds
    initial: off

In my scripts.yaml:

close_blinds_google:
  alias: Close the blinds
  sequence:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.close_blinds

In node red, I have:

[{"id":"6c7f8617.f65618","type":"tab","label":"Example","disabled":false,"info":""},{"id":"31d9dea9.f2bda2","type":"api-call-service","z":"6c7f8617.f65618","name":"Close Blinds","server":"b9ff79d7.164bf8","service_domain":"remote","service":"send_command","data":"{\"entity_id\":\"remote.harmony_hub\",\"device\":\"59433490\",\"command\":\"down\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":730,"y":260,"wires":[["762e5bd4.5a3bf4"]]},{"id":"e5b45401.423288","type":"server-state-changed","z":"6c7f8617.f65618","name":"","server":"b9ff79d7.164bf8","version":1,"entityidfilter":"input_boolean.close_blinds","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":300,"y":260,"wires":[["bb6379bf.150348"]]},{"id":"bb6379bf.150348","type":"switch","z":"6c7f8617.f65618","name":"On?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":560,"y":260,"wires":[["31d9dea9.f2bda2"]]},{"id":"762e5bd4.5a3bf4","type":"api-call-service","z":"6c7f8617.f65618","name":"Reset State","server":"b9ff79d7.164bf8","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.close_blinds","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":260,"wires":[[]]},{"id":"b9ff79d7.164bf8","type":"server","z":"","name":"Home Assistant"}]

Hope that makes sense.

Yes your example is perfect.
I’m not sure but it can be simplified using serviceinput_boolean.toggle and removing initial: false

Using this, you can simplify the flow removing IS ON check and reset state… Do you think is ok my idea?

Give it a go and see.

Hi,
You can create a single dummy input boolean shared with all your scripts
and expose your script directly to node red (be careful to indicate in the node: state changed = on to avoid launching the automation twice)

image