#Is there a "area" option for Node-RED?

1 messages · Page 1 of 1 (latest)

tall epoch
#

I fond out that I could add area to turn on lights as per picture. But is there a equivalant for state_change in area? I would like to have all devices classed as motion sensors in "Basemnet Livingroom" to trigger this. Then if not active for 15 minutes then turn off light.

[When area "Basement Livingroom" is active] -> Turn on lights in that area
[When area "Basement Livingroom" has been inactive for 15 minutes] -> Turn off lights in that area.

#

Reasoning: I dont like to address entities directly, if I add another light or remove a motion sensor from that area I dont want to change all the code and find all places I used it. 🙂

astral ruin
#

Not sure I understand the issue you are facing?

#

You want to trigger on a motion sensor, that you put in the area in the HA configuration? On any sensor?

tall epoch
#

Yeah, Home assistant has the concept of "area" where I put all my devices e.g.. "kitchen" has 2 motion sensors and 3 lights.

I want to be able to say "If there is motion in kitchen, turn on all lights in the kitchen". Instead of adding two motion sensors as a state trigger i would like to add the "area" as a trigger. Like homey's zone activity:

https://support.homey.app/hc/en-us/articles/360026209853-Using-Zone-Activity

astral ruin
#

You could use the template trigger, Example below. In my kitchen I have motion sensor and it s entity is binary_sensor and has _occupancysuffix.

So what You can do is the following:

  • Select area entities
  • Get entities states
  • Search for specific entity format
  • Select only those with on state == occupancy
  • transfer to list and check if the number of them is greater than 0
{{ 
  area_entities('kitchen')
  | expand
  | selectattr('entity_id', 'match', 'binary_sensor.*_occupancy$')
  | selectattr('state', 'eq', 'on')
  | map(attribute='entity_id')
  | list
  | count > 0
}}
#

Full automation would the look like:

alias: New automation - motion
description: ""
triggers:
  - trigger: template
    value_template: |-
      {{ 
        area_entities('kitchen')
        | expand
        | selectattr('entity_id', 'match', 'binary_sensor.*_occupancy$')
        | selectattr('state', 'eq', 'on')
        | map(attribute='entity_id')
        | list
        | count > 0
      }}
conditions: []
actions: []
mode: single
#

In fact you don't need the map filter, it can be removed.