How to send an entity in a subflow

At the moment I am using node-red control my blinds based on time and the outside temperature. However due to a glitch in the way IKEA implemented the blinds you can close them to +100%. (Just have node-red/home assistant keep spamming the “Close” command.)

So in order to prevent this issue I have to use a “current state” node followed by a “call service” node. Since I have 3 blinds that currently looks like this:

Since this code is not really nice I want to clean it up a little bit so I only have to create 1 “main” flow containing 3 subflows where each subflow has a specified entity in it’s configuration so it knows where to send the command to.

So I see my new subflow as something like this:

But I don’t know how to get the subflow “configuration” wired into the “entity” of the “curent state” and “call service” nodes.

So the data I enter in the 1st screen (subflow instance) should be transfered to the “Entity ID” of the last screen.

But what do I need to enter in the “Entity ID” field?

the entity_id field accepts mustache templates. so for example if you have your entity in msg.payload.entity_id, just put {{payload.entity_id}} in the box.

1 Like

Ok, So to verify, I can’t use the “environment variables” to pass the entity in but I need to do this via the message.
Than I have a 2nd question, what is the best node to inject the “Entity ID”. I guess the “template” or “function” nodes can be used. However I guess the “template” node is more intended for this task.

can you write what is your goal here?
you have 3 blinds at home and you want to open and close them based on the time of the day and temperature. but if the blinds are already closed you want to stop the flow? or only close the blinds if they are open.

My main goal is indeed to control the blinds based on the time and/or temperature. However if the blinds are closed I want to prevent a re-send of the close command. (Otherwise my IKEA blinds close to more than 100%).

I also would like to create some more advanced control of the blinds (in the future). Since I don’t like the of having 3 copy-pasted flows I was thinking of putting all the blind control into 1 subflow and produce 3 instances of this flow so all blinds respond the same. (And if I update 1, all the instances will be updated).

The only remaining thing I have is how I can set the “Entity ID” so that each instance has the correct data.

Originally I was thinking of using the subflow environment variables for this. But if that is not possible I am also happy to use a template node (containing the Entity ID) flowed by the subflow.

the triggers (time or temperature) have to fire 3 times in order to close all 3 blinds. you can use get entities node. here I put together one example for motion sensor. you can still use subflows but i think this way it will not be too congested.


[{"id":"71d12bd7.8f8514","type":"debug","z":"de9989cc.589d18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1150,"y":520,"wires":[]},{"id":"8b0ee408.0376e8","type":"ha-get-entities","z":"de9989cc.589d18","server":"e447d17a.16a64","name":"","rules":[{"property":"entity_id","logic":"starts_with","value":"binary_sensor.hue","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":830,"y":520,"wires":[["cbc46b7f.83fc98"]]},{"id":"318514c3.7935cc","type":"inject","z":"de9989cc.589d18","name":"inject","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":670,"y":520,"wires":[["8b0ee408.0376e8"]]},{"id":"cbc46b7f.83fc98","type":"api-current-state","z":"de9989cc.589d18","name":"entity_id","server":"e447d17a.16a64","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"{{payload.entity_id}}","state_type":"str","state_location":"battery","override_payload":"msg","entity_location":"data.battery","override_data":"msg","blockInputOverrides":false,"x":1000,"y":520,"wires":[["71d12bd7.8f8514"],[]]},{"id":"e447d17a.16a64","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true}]

I found a working solution:

With this as an subflow:

My template nodes (just before the subflow) contain something like this:

The current state and call service have their entity set by the template like this:

The switch determines what action will be performed. This depends on the message.payload.

1 Like

I think you can skip the template node. You can just use ${ENVIRONMENT_KEYNAME} syntax. to the Entity ID inside your subflow.

for example, I have an Event State Node that read the DEVICE_ID


And I specified the value as input properties from my subflow.


1 Like