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

@Mogodon you have to go to Device info-Manage clusters-OccupancyCluster. Than in cluster attributes select

pir_o_to_u_delay

and select get zigbee attribute. In case there is number, not 0 you found a problem. Input 0 and press set zigbee attribute. I had the same problem, now it is working. Check and let me know.

1 Like

I’m undoubtedly being blind but where am I looking for manage clusters on the device info page?

hue-motion-device

Which integration do you use?

This one.

It would really good if it was possible to use Sunset or Sunrise in the start or finish times.
Otherwise an excellent Blueprint

Thank you

what i did was simple,
I wanted all lights that use this Automation to be identical, so i change the hard code of it

action:

  • service: homeassistant.turn_on
    entity_id: !input ‘target_entity’
    data:
    brightness: 255
    color_temp: 250

I have a couple questions:

  1. When I import the blueprint I get a different version than the code that is listed in the first post of this thread. It appears that the imported version is an older version. Correct?

  2. I am trying to resolve an issue that was reportedly corrected. I have a delay time set for 1 minute. After the motion sensor resets back to off, if I trip the motion sensor again the automation is NOT restarted. and the light turns off after the 1 minute delay. But the release notes say this was fixed.

I am currently using the version of the blueprint that I copied and pasted from the top of this thread. The blueprint includes the following lines:

condition:
# First condition: When entity was already on because the automation ran recently, do not check illuminance because it could have increased above threshold because of a light that was just turned on.
  - condition: template
    value_template: "{{ (states[target_entity].state == 'on') or (illuminance_currently == none) or (illuminance_cutoff == none) or (states[illuminance_currently].state | int(0) < states[illuminance_cutoff].state | int(0)) }}"
  - condition: template
    value_template: "{{ (blocker_entity == none) or (states[blocker_entity].state == 'off') }}"

The comment suggests that I do have the most recent version. Can anyone shed some light on how the “restart” is supposed to work? When the motion sensor is tripped again during the delay period, the automation is not restarted because it fails a condition test.

Note: I found the problem. The restart of the script does not seem to work when the target is a scene. I switched back to a light entity and it now works correctly.

I am trying to make some personal modifications to this blueprint and would appreciate any help with the correct syntax for the following condition statement which tests the current state and the current brightness of the target_entity:

  - condition: template
    value_template: "{{ (states[target_entity].state == 'off') or (state_attr[target_entity, 'brightness'] < 100) }}"

I have tried every format I can think of, but cannot get the syntax correct for the 2nd part of the condition which is trying to test the current brightness level of the target_entity.

Hi @Sentinel21 Thanks for posting the image of your solution - I’m trying to achieve something similar with a Hue Tap switch. I’m a real newbie to HomeAssistant and am capable of copy/paste but not much else at the moment :confused:

I currently have the switches integrated via eventsensor which turns button presses into events. Can you point me in the right direction for adapting your solution to turn them into an on/off stage please?

Great Blueprint!! Easy to set up and works great!! Thanks!!

I modified the blueprint and added ‘brightness’
It seems to be working but let me know if you have any issues

Make the following updates to the appropriate sections (input / variables / action)

  input:
    brightness_value:
      name: (OPTIONAL) Brightness percent
      description: Brightness (0-100)
      default:
      default: 100
      selector:
        number:
          max: 100
          min: 0
variables:
  brightness_value: !input brightness_value
action:
  - service: homeassistant.turn_on
    entity_id: !input target_entity
    data:
      brightness_pct: !input brightness_value

Hi, this is my first automation I use - so forgive me if I make basic mistakes. I setup this automation with a HUE motion sensor and a HUE based smart plug. Basics work: trigger when motion is detected, light is switched on (via smart plug), light is switched off. What does not work:

  • basically any parameters is set - but lets start with the very basic one. I deactivated (ie deleted any other optional settings) all features expect I want that the light is on for 2min after the last detection. Actually the light switches on but within a few seconds off again. Unclear why. What should happen: the light should be triggered by the motion sensor. It should be on for 2min. If any motion happens within the 2min, the light should be another 2min on from the last time of motion. so very basic automted motion detected light.

Is this what this automation should do and the parameter set should define?
If so, why does the light switch off so fast?

Any help appreciated.

thx
alexollon

Pic below show setting of automation as well as event log and light timing.




@Alexollon, the timeout should be an entity being 2 not a 2 itself

1 Like

thx! ok. how do I do that, I mean defining an entity? is this on any parameter set on such automations or just this one?
@ArnoutD_77 , are you sure? Because the docu of this automation says:

  • Turn off wait time [in minutes!] (input_number) - will not work with script or scene target entities.

using the helpers on the “4th” automation tab…

1 Like

Thx, @ArnoutD_77 .
It works now half - lights are turned on. But they dont turn off. Very strange. I am switching HUE light strips, motion sensor is also HUE, so fairly standard everything.

Following configuration:


the light can be manually switch on and off via the dashboard. The logs show that the automation routine is triggered. the lights are also switched on, but never off.

maybe that helps to look at…basically there is never an entry where at the end is an “off” command…

any idea what is wrong?

I like the blueprint but I got way more sensors in a single area to monitor eg my camera, door open/close sensor, motion sensors - is it somehow possible to modify this to take numerous sensors instead of just one?

If you define a scene as a turn-on entity, it is required you set a different (light) entity as a turn-off entity, since a scene cannot be turned off.

You can put multiple triggering entities in a group, then set the group as the triggering entity. If any of the entities have state ‘on’, the group will also have state ‘on’ and therefore fire the automation.