Aqara FP2: automation to turn off when away

Hello,

I’m considering buying 3 Aqara FP2 sensors to deactivate all my devices (lights, TV, speakers…) when I’m away from my apartment.
The idea is to put these sensors in my 2 bedrooms + the living room and if after 15 minutes, there is no activity detected in the 3 rooms, program an automation to turn everything off.
Note that I do not want to use the position of the phones for this routine: having a child, there may be a babysitter without us in the apartment and it would be a shame that she is in the dark.

Is it possible to program this type of automation with Home Assistant: measure the duration of inactivity of the 3 sensors and if it is 15 minutes, turn everything off?

Because I’d like to have an idea before spending 3x85€ :slightly_smiling_face:

Thanks a lot
F

Very easy. You can create group of these sensors and at as a triger use group state change to off for 15 minutes. Additionally group of all lights to be turned off or other devices (might need to be separate groups, as service to turn them off is different than for lights). Sowould be somethign like that:

group:
  presence_sensors:
    entities:
      - binary_sensor.living_room_fp2_presence_sensor_1
      - binary_sensor.bedroom_1_fp2_presence_sensor_1
      - binary_sensor.bedroom_2_fp2_presence_sensor_1
  lights:
    entities:
      - light.living_room
      - light.bedroom_1
      - light.bedroom_2

automation:
  - alias: "Turn off lights at absence"
    initial_state: true
    trigger:
      platform: state
      entity_id: group.presence_sensors
      to: 'off'
      for:
        minutes: 15
    action:
      - service: light.turn_off
        data:
          entity_id: group.lights

Not if didn’t make any errors in this code, but you get the idea.

1 Like

Thank you very much mirekmal!

I will try this code once I buy the sensors :slightly_smiling_face:
But if I understand correctly, the FP2 Aqara sensors will indeed be able to provide the info I need to run the automation?

Thanks again!

Well, it depends on how you define activity :slight_smile:
FP2 are real presence sensors, so even if you try to stay still, most likely it is enough to brethe for sensor to stay active. So far I only hear of very specific cases like people sleeping under the blanket, where sensor was not able to detect oresence.
However if you think about real activity (e.g. someone not just being present, but moving around the room) then traditional PIR sensor would be better solution.
But from the detailed description of what you want to achieve - definitely these sensors are able to deal with this!