Motion detection to turn lights on in the morning

Hi there,

I want to have a first thing in the morning automation, so that wnem I walk downstairs, the kitchen lights turn on and then just stay on.

I have the following automation, but it just triggers constantly when walking around.

Any ideas how I can achieve this? I was thinking that I could have some sort of condition that says ‘if the sensor hasn’t seen motion for a minimum of two hours’ or something?!??

- id: '9'
  alias: 'Morning Motion'
  trigger:
    - platform: state
      entity_id: sensor.hall_motion_sensor
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: time
        before: '08:30:00'
        after: '03:00:00'
      - condition: state
        entity_id: group.family
        state: 'home'
  action:
    - service: notify.pushbullet
      data:
        message: 'Good Morning'
        target: 'device/Google Pixel 2'
    - service: script.good_morning

you could use a condition as you mentioned to restrict it triggering unless it has been ‘off’ for ‘x’ hours,
or,
you could use an input_boolean which is set on the first trigger and then forms part of a condition to prevent the automation triggering again later. You would then reset that input_boolean later, say at midnight via another automation or perhaps a bedtime routine.

I have split my day into 5 different time spans. Every part of the day, consists of a group of automations. E.g. when the time is 05:30:00 on a workday, the “Morning work” automation is triggered. What it does is, that it turns off all light automations, and turns on the ones defined in my “Morning Work Light” automation group. In that way, I can easily add new automations, and keep track of my light automations if something seems odd.

Thanks for the info people!

I have (hopefully) achieved it like this:

- id: 'morning_motion'
  alias: 'Morning Motion'
  trigger:
    - platform: state
      entity_id: sensor.hall_motion_sensor
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: time
        before: '08:30:00'
        after: '03:00:00'
      - condition: state
        entity_id: group.family
        state: 'home'
  action:
    - service: notify.pushbullet
      data:
        message: 'Good Morning'
        target: 'device/Google Pixel 2'
    - service: script.good_morning
    
- id: 'morning_motion_turn_off'
  alias: 'Morning Motion Disable'
  trigger:
    - platform: state
      entity_id: sensor.hall_motion_sensor
      to: 'on'
  action:
    - delay: '00:00:10'
    - service: notify.pushbullet
      data:
        message: 'Morning motion turned off'
        target: 'device/Google Pixel 2'
    - service: automation.turn_off
      entity_id: automation.morning_motion
    - service: automation.turn_off
      entity_id: automation.morning_motion_turn_off

- id: 'morning_motion_reset'
  alias: 'Morning Motion Enable'
  trigger:
    - platform: time
      at: '02:45:00'
  action:
    - service: automation.turn_on
      entity_id: automation.morning_motion
    - service: automation.turn_on
      entity_id: automation.morning_motion_turn_off

actually - it looks like this isn’t working. I can’t get the automation to turn itself off.

I think I may try the sensor to: ‘off’ for 2 hours option.

Aaaaargh!

I’m trying to add a condition for the sensor to be off for 2 hours, but it is throwing up errors.

Can someone take a look. It is definitely the sensor condition that is causing the error (I’m guessing a formatting issue).

- id: 'morning_motion'
  alias: 'Morning Motion'
  trigger:
    - platform: state
      entity_id: sensor.hall_motion_sensor
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: time
        before: '09:00:00'
        after: '03:00:00'
      - condition: state
        entity_id: group.family
        state: 'home'
      - condition: state
        entity_id: sensor.hall_motion_sensor
        to: 'off'
        for:
          hours: 2
  action:
    - service: notify.pushbullet
      data:
        message: 'Good Morning'
        target: 'device/Google Pixel 2'
    - service: script.good_morning