Turn on light, switch, scene, script or group based on motion, illuminance, sun (+ more conditions)

I think I know what you mean but just to check, you think the input fields for ‘Only run before time’ and ‘Only run after time’ should be swapped? That makes sense to me;) I will change it in the blueprint.

That is hard to support with a good input field for this automation, because weekday inputs are not yet supported.
A workaround I can think of is creating 2 automations with this blueprint, and then turning the automations on and off based on the weekday.

Something a bit like:

  - alias: Turn off blueprint automation 1
    initial_state: true
    trigger:
      platform: time
      at: '00:00:00'
    condition:
      condition: time
      weekday:
        - mon
        - wed
        - fri
    action:
      - service: automation.turn_off
        entity_id: automation.generated_from_blueprint_1

It looks like the motion sensor trigger is looking for an on state.

trigger:
  platform: state
  entity_id: !input motion_sensor
  to: 'on'

My motion sensor has a few different values that it switches between.

  • Clear
  • Tampering - Cover Removed
  • Motion Detected at Unknown Location

It would be great if we could set the sensor value to as an input so this can support different types of motion sensors.

Hello,

I am quite new to HA.
I ran successfully the automation, but when I try to set before / after time I can’t have it running.

Here is my yaml:

alias: Turn on light in Bedroom
description: ''
use_blueprint:
  path: freakshock88/motion_illuminance_activated_entity.yaml
  input:
    motion_sensor: binary_sensor.motion_sensor_533b
    target_entity: switch.shelly1l_84cca8ace9c8
    time_limit_after: '19:00:00'

Any advice?

@Stephen_Tittel and @MapTo0
You both seem to use hardcoded time conditions.

Please read the first post, it explains you need to create input_datetime entities for specifying the time conditions.

I think motion sensors being ‘on’ when motion is detected is HA default behavior.

So your case is really an edgecase.
I don’t think modifying the blueprint for every edgecase that exists is a good idea for it’s maintainability.

To solve the problem I would suggest creating a binary template sensor based on your exising motion sensor that has state on when motion is detected.

Let me know if you need help with that.

Good evening, the script works perfectly, I would like to have the light switched on via a door contact and if no movement was detected for a period of 5 minutes, switch the light off again. Maybe someone can help me

Just use the door sensor as the motion sensor entity.
Otherwise just use the blueprint as described, it will work if the door sensor state = ‘on’ when the door is open :slight_smile:

1 Like

Hey, i use this automation to trigger two scripts that call rest commands. One as the turn on entity and one as the turn off entity.Any ideas how I can wrap these scripts in some entity so that the turn off wait time will work?

Indeed, my apologies (RTFM). It’s now up and running in the correct way.

I created two automations with it: one for a Xiaomi based motion sensor, the other with a Lidl sensor.

The Xiaomi based sensor works well with the script; the Lidl one (which has no Illuminance) doesn’t trigger the script. I created different Helpers to check if that is the case ( I wanted different settings), but it didn’t help so far.

Am I doing something wrong?

Hmmm, again I know the answer. Just import the latest Blueprint, delete the old one. Everything works what I want to achieve.

1 Like

Hello I have a question.
I want to use this blueprint to toggle my lighswitch with a motion sensor.
I want that the light is turned off after 2mins, I used 2 as InputNumber.
But the switch is tunred off after 1,30 mins. It tunes off after the motion sensor change to state clear.

I hope you can help me

I’ve got a feature request. At night I prefer to have the lights a little bit less bright.

Could you add a brightness parameter to turning on the lights?
And optionally… a second brightness between specific times. But I could work around this by creating 2 blueprint automations I guess

Can you add conditions for sunrise and sunset?

If you want to trigger script A as the turn on entity and script B as the turn off entity, you could do this:

  • Simply set script A as turn on entity
  • Define a input_boolean value, called ‘script B trigger’ or something.
  • Create an automation that triggers on the input_boolean turning off, which has an action to run script B.

I dont know if this effort is worth your while just to be able to use this blueprint, but I’ll let you be the judge of that :wink:

Have you created an input_number entity like described in the first post? Or have you entered a hardcoded value in the blueprint? Please read the first post again.

Do do this, you can define a scene for the light(s) with a specific brightness you want, and use this scene as the target entity.

Indeed, you can create 2 automations with different time limits (and different target entity scenes) to do this.

Well I don’t really see the point in that… you either want to control your lights based on illuminance levels or by sunstate right? Or am I overlooking some usecase?

I want that light turns on motion sensors, but only after sunset and before sunrise.

Hi, first of all, thank you for all the effort you’ve put into this Blueprint.
I probably have a noob question but I was wondering the Following:
my setup is pretty basic: Activate a scene(since I want to dim my light) by motion and auto turn the
target entity off. My Yaml file looks like this.

- id: '1612558178556'
  alias: Turn on light, switch, scene, script or group based on motion and illuminance.
  description: ''
  use_blueprint:
    path: freakshock88/motion_illuminance_activated_entity.yaml
    input:
      motion_sensor: binary_sensor.shenzhen_neo_electronics_co_ltd_battery_powered_pir_sensor_v2_sensor_5
      target_entity: scene.badkamer_snachts
      target_off_entity: light.badkamer
      no_motion_wait: input_number.badkamer_wait_time

Unfortunately the light does not turn off automatically.
any idea where this is going wrong?

Thanks in advance!

I think there’s other blueprints available to suit that purpose, this one supports illuminance conditions.
I don’t want to make an overcomplicated blueprint that ‘does-it-all’, that would be unmaintanable.