Create a subflow that takes entity ids as parameters

This is likely a very dumb, newby question, but my google foo seems to be failing me and I can't find the answer.

I have a series of nearly identical flows connected to different motion sensors. One half of the flows turn on the lights (if they are off and it's dark) and the other half turn the lights off again if no motion is detected for a while (again, if the lights are on). These seem like perfect candidates for subflows: The logic is the same, only the entity ids (what sensor to check for darkness and what lights to turn on or off). But I can't figure out how to get the entities ids in as variables that I can use in the "Entity ID" property of the "call service" or "current state" nodes.

I've tried triggering with the payload set to an object like:

{ "sensor": "sensor.xxxx_room_sensor_light_level", "lights": "light.bathroom, light.hallway" }

And I see that payload in the debug output in the subflow, but I don't know how to, say, set an environment variable of LIGHT_SENSOR to the contents of msg.payload.sensor. What keeps happening is that LIGHT_SENSOR gets set to "msg.payload.sensor" (that literal string).

Presumably, I will be able to just use ${LIGHT_SENSOR} as the entity id when I need it, I assume/hope, but I haven't been able to get to this point.

What silly thing am I missing?

So, I've confirmed that my entity ids can be env variables (e.g., "${LIGHT_SENSOR}") by hard-coding the values in my environment. How do I extract these values from the payload received by the input node?

Ah, I think I figured it out. Extract the values from the payload using a change node and set them to flow variables!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.