#Run automation when house is empty

1 messages · Page 1 of 1 (latest)

wanton musk
#

I want to turn off lights when only one person is at home and opens the front door.

So when the last person leaves they see the lights turn off as they exit.

How do I integrate the house count into this code so that happens?

`
alias: Enter - leave home
description: ""
triggers:

  • type: opened
    device_id: 838ee5f0b7fbbf904d8f4668319b5341
    entity_id: 5e04ae5fa22a5bd1e7280e2633ba99cb
    domain: binary_sensor
    trigger: device
    for:
    hours: 0
    minutes: 0
    seconds: 1
    conditions: []
    actions:
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: light.living_lights
  • wait_for_trigger:
    • type: opened
      device_id: 838ee5f0b7fbbf904d8f4668319b5341
      entity_id: 5e04ae5fa22a5bd1e7280e2633ba99cb
      domain: binary_sensor
      trigger: device
      for:
      hours: 0
      minutes: 0
      seconds: 2
      timeout:
      hours: 12
      minutes: 0
      seconds: 0
      milliseconds: 0
  • action: adaptive_lighting.apply
    data:
    lights:
    - light.living_lights
    transition: "90"
    adapt_brightness: true
    adapt_color: true
    turn_on_lights: true
  • action: light.turn_on
    metadata: {}
    data:
    brightness_pct: 15
    target:
    entity_id: light.pendant_lights
  • delay:
    hours: 0
    minutes: 3
    seconds: 0
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: light.pendant_lights
    mode: single
    `
charred sage
#

add a condition that checks the number of people in the zone.home is 1

noble glade
#

home has a value of the number of people in it
so I would do it like this:
trigger: door opens
condition: ~~numeric_~~state of home = 1
action: <your actions>

charred sage
#

numeric state doesn't do ==

noble glade
#

sorry I didn't mean numeric state - just state

wanton musk
#

condition: state entity_id: zone.home attribute: persons state: "1"

noble glade
#

I don't think you need the attribute?

#

yes, drop the attribute

#

the attribute has the persons in it - you only want the value of zone.home

wanton musk
#

condition: numeric_state
entity_id: zone.home
below: 1

#

Condition passes

noble glade
#

then either nobody is home or you haven't configured their device trackers correctly

wanton musk
#

Wym

#

No one is home rn

noble glade
#

ah ok - I expected you to be home
you can use numeric_state but then you need to do below 2, because you want 1 person
or you use state (without the numeric)

wanton musk
#

If I did state ,these are my options

charred sage
#

put a 1 in quotes in that field

#

"1"

#

actually, don't put the quotes, try that first. If that doesn't work, add the quotes.

#

because your're doing this on mobile, you want to make sure you don't use fancy quotes.

wanton musk
#

Ok no qoutes with 0 passes . Then when set to 1 it did not.

#

Cool!

#

Might be cool to add “hello (member who just got home) to that but that may be over my head

#

There is a actions in parallel block, would I make a choose action be inside that

noble glade
wanton musk
#

Can you elaborate? I have never used the zones in automation before

#

Please

#

It would be nice to have tasks run independently to each other but use same variables

charred sage
#

Use parallel

karmic fjord
# wanton musk I want to turn off lights when only one person is at home and opens the front do...

I think the problem here is if only one person is at home but it simply opens the door. To a visitor, etc... I solve this problem from two sides. One automation launches if detects anybody outside home zone and no detector (PIR, mini wave, some smart plugs off) has been activated for 5 minutes. Then HA sends me a mobile app notification and switch off(plugs, lights, etc) or on (some cameras) The other way is that I have a ZigBee double button that allows me to activate or deactivate the same "scenes". Works fine most of the time 🙂

#

I have that double ZigBee button next to the entrance door

wanton musk
wanton musk
#

Ik this would be hardware but what zigbee presence sensors do you use @karmic fjord

charred sage
#

which defeats the purpose of parallel

wanton musk
#

Oh

karmic fjord
# wanton musk Ik this would be hardware but what zigbee presence sensors do you use <@11523258...

The IKEA ones. It's important to use the IKEA AAA bateries due to the sensibility to voltage. Around 10€ in Spain. Very cheap and stetically nice https://www.ikea.com/es/es/p/vallhorn-sensor-movimiento-inalambrico-inteligente-blanco-90504341/

karmic fjord
wanton musk
#

I saw a hacks integration for room detection

wanton musk
#

I feel like I need to redo this automation in node red or something

#

I’m getting presence sensors tomorrow

#

Node red doesn’t start for me from the add on

#

I have it as a proxmox lxc but how do I link the two

noble glade
#

Why do you think you need nodered?

charred sage
#

some people don't understand/like using the built in automation engine

wanton musk
#

I thought it would be easier to have different flows together.

#

Utilizing ai more and mmWave presence sensors

charred sage
#

Well, as above, if you're referring to parallel, all you needed to do was add the parallel actions to parallel, but you put them below parallel outside parallel

wanton musk
#

So I need 2 parallel blocks for it to be effective

charred sage
#

why

#

you can have multiple parallel actions in a single block

wanton musk
#

`alias: Enter - leave home
description: ""
triggers:

  • type: opened
    device_id: 838ee5f0b7fbbf904d8f4668319b5341
    entity_id: 5e04ae5fa22a5bd1e7280e2633ba99cb
    domain: binary_sensor
    trigger: device
    for:
    hours: 0
    minutes: 0
    seconds: 1
    conditions:
  • condition: state
    entity_id: zone.home
    state: "1"
    actions:
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: light.living_lights
  • wait_for_trigger:
    • type: opened
      device_id: 838ee5f0b7fbbf904d8f4668319b5341
      entity_id: 5e04ae5fa22a5bd1e7280e2633ba99cb
      domain: binary_sensor
      trigger: device
      for:
      hours: 0
      minutes: 0
      seconds: 2
      timeout:
      hours: 12
      minutes: 0
      seconds: 0
      milliseconds: 0`
#

` - choose:
- conditions:
- condition: and
conditions:
- condition: state
entity_id: person.alec_wren
state: home
- condition: state
entity_id: person.hunter
state: not_home
sequence:
- action: assist_satellite.announce
metadata: {}
data:
message: Welcome Home Alec
preannounce: true
target:
entity_id: assist_satellite.home_assistant_voice_097b4f_assist_satellite
- conditions:
- condition: and
conditions:
- condition: state
entity_id: person.hunter
state: home
- condition: state
entity_id: person.alec_wren
state: not_home
sequence:
- action: assist_satellite.announce
metadata: {}
data:
message: Welcome Home Hunter
preannounce: true
target:
entity_id: assist_satellite.home_assistant_voice_097b4f_assist_satellite

  • action: adaptive_lighting.apply
    data:
    lights:
    - light.living_lights
    transition: "90"
    adapt_brightness: true
    adapt_color: true
    turn_on_lights: true
  • action: light.turn_on
    metadata: {}
    data:
    brightness_pct: 15
    target:
    entity_id: light.pendant_lights
  • delay:
    hours: 0
    minutes: 3
    seconds: 0
  • action: light.turn_off
    metadata: {}
    data: {}
    target:
    entity_id: light.pendant_lights
    mode: single`
#

Will this work

charred sage
#

Are you asking about parallel?

wanton musk
#

No

#

In general

charred sage
#

it looks odd to me

#

Why are you doing the same thing twice via 2 separate triggers?

#

just make 2 separate triggers, label each one, use a choose statement for each path.

#

you can make the automation itself parallel