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

Thanks for the reply!.

Yeah. I’ve created 2 seperate input_numbers. I’ve done this withing the helpers section and gave it values from 0 to 14 for light illuminance. But nothing happens


Alright; so i found out it has to be something else.
I’ve changed the LX from 0-14 to 14-250 and now it’s working.

I was thinking the value for turning it on needed to be in that range but it needs to be outside. So if you want to turn it on at 0-14 lx you need to exclude that from the range… Oops…

Great Blueprint, thank you for this! I have one issue here: as soon as I enter any value in the “Illuminance cutoff value” field inside the blueprint it stops working regardless how low I set the cutoff value.
Maybe I misunderstood how to configure it?

Please read the first post again, you need to define some helper input_number entities to use in the blueprint instead of entering values directly in the blueprint for the illuminance cutoff value.

2 Likes

I can confirm that this fixed my issues. Works really well now that the helpers are added. Sorry am new to HA. Thanks for your help.

1 Like

Hello all, I have this automation running fine for about 2 months but 2 nights ago I noticed it was not working anymore.
Bellow is the log I see every time the sensor detects anything\

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/__init__.py", line 112, in async_handle_turn_service
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 206, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 649, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 692, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 272, in async_handle_light_on_service
    supported_color_modes = light.supported_color_modes
AttributeError: 'EWeLinkToggle' object has no attribute 'supported_color_modes'

any help please?

I think your issue is not with this blueprint, but with your specific light integration.

I googled a bit and found this.

@MrRodz and @andyz I figured out a quick way to make the blueprint work by calling it from another automation. Here’s the sample yaml:

alias: Bathroom Lights Motion Trigger
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_7cb4b706_ias_zone
    from: 'off'
    to: 'on'
    for: '.5'
condition: []
action:
  - service: automation.trigger
    data: {}
    target:
      entity_id: >-
        automation.turn_on_light_switch_scene_script_or_group_based_on_motion_and_illuminance
mode: queued
max: 10

In plain english, I created a script based on this blueprint with my Aqara motion sensor and set up the obvious logic. I called this first one “Bathroom Light Motion Actions” and then created a second automation called “Bathroom Light Motion Trigger” (above) that triggers the blueprint automation after .5 seconds of motion. Might can get away with less than that even.

This gives the Aqara sensor a brief moment to get an illuminance reading before doing the “less than” logic.

For reference my “Bathroom Light Motion Actions” below:

alias: Bathroom Light Motion Actions
description: ''
use_blueprint:
  path: freakshock88/motion_illuminance_activated_entity.yaml
  input:
    motion_sensor: binary_sensor.lumi_lumi_sensor_motion_aq2_7cb4b706_ias_zone
    target_entity: light.brass_lamp_level_light_color_on_off
    illuminance_sensor: sensor.lumi_lumi_sensor_motion_aq2_7cb4b706_illuminance
    illuminance_cutoff: '22'
    no_motion_wait: '10'

1 Like

In the YAML example code you have " Bedroom lights no longer turn of before this time"

Shouldn’t it be “lights turn on” ?

1 Like

this does not work for me. Trying to set a simple automation that activates a script which turns on the main tv and turns off a nightlight if motion is detected between 4:15am and 6:00am. I set the input helper times but the automation turns on the tv no matter what time it is. what am i doing wrong? i tried removing the script and just added the tv device but that also turns on anytime motion is detected, no within the timeframe set by the input helpers

alias: weekday wakeup
description: ''
use_blueprint:
  path: freakshock88/motion_illuminance_activated_entity.yaml
  input:
    motion_sensor: binary_sensor.lr_motion
    time_limit_after: input_datetime.wake_time
    time_limit_before: input_datetime.end_wake_time
    target_entity: script.wakeup`

Are you sure you dont have any other (old) automations to turn on the tv of run the script when the binary_sensor.lr_motion turns on? You can check your home assistant Logbook to see if any automations are triggering when the motion sensor is tripped.

I have the same issue. Did you solve it?

Hi @freakshock thanks so much for your blueprint. Are you able to add a way to delay turning on the entity?

Top blueprint!
I try to set lux value but it seems it doesn’t work. Do you have any idea ?

I’m having a problem with this blueprint. If the light is turned off by another means the automation stops working.

is there a way to set Turn off wait time less that a minutes?

I think I could use a little help with this. I imported this blueprint, and ran actions, and out of all of the several here, this is the ONLY one that turned on my GE zwave light switch.
I have a smartthings motion sensor, and it shows up on cards as Clear and Detected for motion. So for the life of me I can’t get the BP to register the motion sensor telling the switch to come on. I’m no coder, but it seems like the BP is looking for diff input.
Thanks in advance!

You can try defining the input number with a lower minimum value than 1.
For instance, if you want the turn off wait time to be 30 seconds, the value of the input number should be 0.5.

The blueprint expects the triggering entity to have a state ‘on’ when there is motion.

You can check the exact state in the developer tools in Home Assistant, when motion is detected. This state is not the same as what the lovelace frontend says (like ‘Detected’).

The developer tools can be found in the left menu of Home Assistant, when go to the states page and find the entity that you want to be your triggering entity. And see what the state is the moment that motion is detected. If it is ‘on’, then that entity should be compatible with this blueprint.

Ok, I actually got it working. Sorry, Just pretty new to this, so big learning curve. Question: Can a certain helper, I have one that set the delay time in minutes input_number.waittime. Can this exact helper be used elsewhere in another automation/blueprint, or does this helper in this automation(yours) only work here?
I’m wondering if I set it in another different automation, if its possible the value in one automation becomes the same across all automations. Or is that not how it works. Thanks!

No worries!

If you define an input_number helper entity, it can be used anywhere.
It is an independent entity not bound to this blueprint/automation.
So you can reuse it, if you want to use the same value also in other automations/scripts etc.