Motion Activated Light, but with conditions

Thanks a lot! Exactly what I needed.

I am totally lost… If I want to have the motion activated light only during the night (so after sunset but before sunrise), what do I need to do?

Not like this, or?

I don’t use this, I don’t know.
I just helped by adding the roll-your-own condition selector.
No idea what it does.
I use my weather station to track lux outside to enable/disable lights like these.

Nice, but I see a problem. If you have a condition related with a luminance sensor (affected by the switched on lights), then even if you got additional movement the automation will not restart because the condition (low luminance) will not be met…

The light lux level controls a binary sensor for day or dark. That binary_sensor is a condition on my motion lights automations. The automation function is not affected by this other than to enable the function or disable that automation.
The light/dark defaults to dark so if something goes wrong, it defaults to the light working.
The light also will turn off when it kicks to day mode, so they don’t get stuck on all day (unless it is one of the timed on lights).

A lot of that is done with Tasmota and the dark/day is sent to the MQTT broker to facilitate that.

1 Like

Hello I’ve just started using Aqara FP2 for motion in my home office. I used the Blueprint provided by HA and once up and running converted it to standard Automation and added some Conditions in UI. One enhancement I would like to make is disregarding the 120 sec timer when the light switch is manually turned off so presence would trigger again if an entry to room was detected.

Is this possible?

alias: "Office: Light Presence"
description: ""
trigger:
  - platform: state
    entity_id: binary_sensor.presence_sensor_fp2_ae65_presence_sensor_1
    from: "off"
    to: "on"
condition:
  - condition: state
    entity_id: input_boolean.vacation_mode
    state: "off"
  - condition: state
    entity_id: input_boolean.guest_mode
    state: "off"
  - condition: time
    after: "05:30:00"
    before: "23:00:00"
    enabled: true
action:
  - alias: Turn on the light
    service: light.turn_on
    target:
      entity_id: light.schneider_electric_ch2ax_switch_1_light
    data: {}
  - alias: Wait until there is no motion from device
    wait_for_trigger:
      platform: state
      entity_id: binary_sensor.presence_sensor_fp2_ae65_presence_sensor_1
      from: "on"
      to: "off"
  - alias: Wait the number of seconds that has been set
    delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - alias: Turn off the light
    service: light.turn_off
    target:
      entity_id: light.schneider_electric_ch2ax_switch_1_light
    data: {}
mode: restart
max_exceeded: silent

I do not understand your issue.
Your version has no manual triggers, so nothing in there changes what happens when you turn the light on and off manually.
The only thing that affects the 2 minute timer is the correct change of state to

Thanks for your reply. The behaviour I’m seeing is as follows.

Detect presence and light turns on, leave room and turn off zigbee light switch. Walk back in 30sec later and light does not come on. If I wait a couple of minutes and try again the light comes on. Hope I’ve been clearer.

Adjust the delay?
Can be set to whatever you want.

So if the light is turned off manually at the switch when leaving room, the 120sec timer is irrelevant and the light should turn on again with fresh motion? This is not occurring. I want the 120sec timer, but when turning off light manually I don’t want to wait for it to complete.

If you just flip the manual switch, no. If you trigger the presence sensor then it will start the automation as programmed. One doesn’t care about the other.

Is there a way to make the automation aware to disregard the 120 sec delay when the Zigbee switch is turned off?

I suggest looking thru the blueprint exchange for other versions of a motion light instead of re-inventing the steel. There are many versions there.

Besides this is a solved topic, and your question is UN-relateed to the OP’s original question other than it had the same base software.

1 Like

Thanks @Sir_Goodenough

Thanks for the template! I am new to HA and I’m trying to use your template… When I use the link under “source_url” to import the template, it tells me “No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.” Can anyone help me how I can upload this template? Thanks!!

You are just going to have to copy that out directly and paste it in where it belongs. The source_url will not work like it was configured so I deleted that line.

If you are not sure where it goes, find the built=-n version of the motion light blueprint and mimic how that is installed but use a folder with your name instead of homeassistant.