Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[Home Assistant] Open window reminder

This automation is triggered when a window stays open for >10 minutes. It will then send a reminder every 10 minutes (max 6 times).

This post helped me to create this script.

alias: Open window reminder
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_xxx_on_off
    from: 'off'
    to: 'on'
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition: []
action:
  - repeat:
      while:
        - condition: state
          entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_xxx_on_off
          state: 'on'
        - condition: template
          value_template: '{{ repeat.index <= 6 }}'
      sequence:
        - variables:
            counter: '{{ repeat.index * 10 }}'
        - service: telegram_bot.send_message
          data:
            message: Window is open for {{ counter }} minutes
        - delay: '00:10:00'
mode: single

[Home Assistant] Control lights with multiple motion sensors

Create group of motion sensors in groups.yaml
https://www.home-assistant.io/integrations/group/

cellar_motion:
  name: Cellar Presence
  icon: mdi:motion-sensor
  entities:
    - binary_sensor.bewegungsmelder_xxx_ias_zone
    - binary_sensor.bewegungsmelder_xxx_ias_zone

Next, if you have more than one light you’d like to control, create a group of lights in your configuration.yaml
https://www.home-assistant.io/integrations/light.group/

# Light Groups      
light:
  - platform: group
    name: Cellar Lights
    entities:
      - light.ikea_of_sweden_tradfri_bulb_e27_ww_806lm_xxx_level_on_off
      - light.ikea_of_sweden_tradfri_bulb_e27_ww_806lm_xxx_level_on_off   

And finally use both in an automation

alias: My motion activated lights
description: Turn on a light when motion is detected.
trigger:
  - platform: state
    entity_id: group.cellar_motion
    from: 'off'
    to: 'on'
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: light.cellar_lights
    data: {}
  - wait_for_trigger:
      platform: state
      entity_id: group.cellar_motion
      from: 'on'
      to: 'off'
  - delay: 120
  - service: light.turn_off
    target:
      entity_id: light.cellar_lights
    data: {}
mode: restart
max_exceeded: silent # https://www.home-assistant.io/docs/automation/modes/