💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

@Momo Thanks for the kind words.

A example: Motion detected, trigger received automation runs, motion is in the ON state, before it goes to the OFF state the door opened and goes to ON state, LUX goes to ON state and then motion goes to OFF state. Because motion has now gone to the OFF state it is ready to receive the next trigger. The door and the LUX will not send a trigger to the automation until the door is closed and opened again or the LUX go high and low again so the automation waits. The problem happens more when we have sensors that can be in a ON state for a long time like door, LUX, etc.

If you have 3 motion sensors apart from each other it can work well because they normal are only on for short time and keep sending triggers. But in saying that it is possible to have issues.

If you group the motion, door and the LUX sensor together it acts as one trigger. So you trigger motion and it goes to the ON state, then you open the door and it goes to ON state, then your LUX goes to the ON state, your door closes and then is OFF, motion then goes OFF but the LUX is still ON so the group or the trigger is still in a ON state waiting until all sensors go to the OFF state. Once that happens the time delay starts. Hope that make sense.

I try and name the helper group to the automation so I can find it easy. But normally we set it up and forget about it.

HA do a good job with groups so even though I do understand it is nice to have it all in one place as I to would like that, sometimes it is better to use what HA have perfected and maintain well like helper groups.

Here is the link on how to set up helper group if you need it. Click Here

I did more testing to pinpoint where the issue is coming from.

I put 2 motion sensors pretty close to each other and triggered only 1. Automation did not start as it failed on the first condition check.

condition:
- condition: or
  conditions:
  - condition: and
    conditions:
    - condition: state
      entity_id: !input motion_trigger
      state: 'on'
  - condition: and
    conditions:
    - condition: state
      entity_id: !input motion_trigger
      state: 'on'
    - condition: trigger
      id: t2
  - condition: and
    conditions:
    - condition: state
      entity_id: !input motion_trigger
      state: 'on'
    - condition: trigger
      id: t3
  - condition: and
    conditions:
    - condition: state
      entity_id: !input motion_trigger
      state: 'on'
    - condition: trigger
      id: t4

This first conditon is shown in Traces as conditions/0

Entity Id 0 was evaluated as true, but the overall first condition as false.

This is the first condition:
image

I believe the problem comes from the fact that the sensors are both under the same entity_id , hence the automation expects them to be both On to continue, which is wrong.

They should be evaluated separate and if ANY of them is ON, the automation should continue.

1 Like

And i think i fixed it :slight_smile:

condition:
- condition: or
  conditions:
  - condition: and
    conditions:
    - condition: state
      entity_id: !input motion_trigger
      match: any
      state: 'on'

only one sensor triggered, condition evaluated as true

Currently I have a script with a template for the lamp that retrieves the values from the adaptive lighting and adjusts accordingly.
If I let the lamp just turn on, I have partly a short flickering or have to wait a bit until the integration adjusts the lamp.
My script looks like this:

service: light.turn_on
data_template:
  entity_id: light.hue_signe_esszimmer
  brightness_pct: "{{ states('sensor.ct_helligkeit_esszimmer') }}"
  color_temp: "{{ states('sensor.ct_mired_esszimmer') }}"
alias: Licht einschalten (mit Template Woche)

The light currently goes off via the normal light.turn_off command.
But of course I could also do this with a script.

I would tinker with it myself, unfortunately I know too little :confused:

@Momo

Thank you, I will look into that and update the blueprint. :grinning: :+1:

EDIT
Mine worked the first time with 2 motions sensors, but looked at the traces showed it stopped (what the). Then I changed it and the traces looked good and it worked. Then I removed it and it didn’t work. Put it back and it works.

I will update the Blueprint with your fix, thanks again. :+1:

New update 1.9

Bug fix thanks to @Momo

When using multiple entities for the “Trigger Sensor - Binary Sensors”. Would not run.

Enjoy

Blacky :grinning:

Anytime :slight_smile:

Now i’m thinking of how to include some other check to keep lights on if standing still. For example check for TV power and if above 100W then do not turn lights off.
I like the idea of having an override switch like it is implemented but i’m the type that always forget to press some button. So an automated check for some entity property would be great.

1 Like

Remember the by-pass can be anything that has a ON state.

I will PM you.

I know but it is not enough. In my home office as we speak, working at PC. Lights just went off. PC is connected to a smart plug that sends power reports and status in HA. If i’m working then power will be > 100W. If i leave for a longer time then PC will be in sleep/hibernate.
There is nothing else around that has the on status , except the plug - but that is on all the time.
The power check is in general a widely used trigger for automations.

@Momo back to the group but first need to add a binary sensor into your “configuration.yaml” . Then change the ‘sensor.septic_tank_power’ to your computer sensor power. restart HA. Make a group and put it into the group. 85 is your power.

binary_sensor:
  - platform: template
    sensors:
      computer:
        friendly_name: "work computer power"
        device_class: power
        icon_template: mdi:laptop
        value_template: >-
          {% if states('sensor.septic_tank_power')|float > 85 %}
            on
          {% else %}
            off
          {% endif %}

Ha !. I haven’t thought about that lol. Template entities :slight_smile: ofc this can work

@Blacky
Can you please tell me why is this wait here?
image

it results in

and lights turn on with some delay. Is there a special need to wait for the sensor to be off? as i think lights should go on immediately as the sensor is on.

The lights are turned on by the call homeassistant.turn_on right before that wait… Then after the lights are on, that action waits until the motion stops before continuing to the other actions…

1 Like

I see. Usually motion sensors turn off very fast after they have been breached and enter a state of no report for some seconds. They do not stay on for 20 seconds if one continues to move in front of them. It’s more like On,Off, Wait a predifined interval, On, Off again.

so basically that wait for the motion sensor to go off only delays everything after it for 1-2 seconds - unless you have a motion sensor where you can define a time for which the motion sensor stays on after breach.

This wait is after the light is ON. So there should be no delay. Mine turn on instantly (milliseconds). Could be your network, your HA set up… the size/configuration, maybe a integration if you are using it to turn the lights on, maybe your motion sensor, maybe what is used to turn ON the light. Testing here is instantly to turn ON.

My motion sensors will be in the ON state for about 3 seconds and then go to the OFF state. If you continue to move then it will stay in the ON state until it doesn’t detect motion. If it goes OFF there is no delay, if it detects motion again it goes to ON state instantly.

The wait for the OFF is there so it will keep the light ON and not time out. If you have a motion sensor to define time it can work but that is why the delay time is there in the blueprint.

Example; Because we have the new presence sensors they are good at detecting and keeping a ON state so we don’t want to time out if it is in the ON state (like a door, window, LUX, your computer, etc). We would just like it to wait until it goes to OFF state and then time out. Helper group can resolve problems, like when you walk into your office light goes ON with motion and then you move your mouse and your computer wakes up. Now if your computer binary sensor goes to the ON state before your motion sensor goes to the OFF state your computer will never send a trigger to the blueprint because it will already be in the ON state (not passing from OFF to ON). If entities are separate in the blueprint you will then have to make sure you don’t move and trigger the motion sensor put your computer back to sleep and wake it up again, then your computer will send a trigger because it has gone from OFF to ON state, it will then wait on your computer state change to OFF. If you group motion & computer together it will just work perfectly using 1 trigger, wait until OFF and the time delay.

If you have 2 motion sensors going ON & OFF all the time (sending multiple triggers within the time delay) then the blueprint will work with separate entities as the trigger. In saying that sometimes having 2 motion sensors can cause problems so if this is the case it is best to use a helper group to resolves the problem. We find when we have 2 or more trigger sensors and a trigger sensor that holds it’s ON state for a long time it is best if we use the helper group as it acts as 1 trigger and if any entity is in the ON state it is ON. When all the entities in the helper group go to OFF then the wait until OFF is true and the time delay starts.

For anyone else reading this here is the link on how to set up helper group if you need it. Click Here

Hope this helps

aha cheers for the detailed explanation:) it makes sense now. I’ll have to look into my motion sensors to see what they do, because in HA interface i clearly see them going On,Off,On,Off. Did not time them yet.

@Momo All good happy to help, you should be all good to go now but if you have any questions just let us know.

Enjoy

Blacky :grinning:

Now, is it possible to ask for improvments or new features? If it is, then here are a few, if it’s not, just ignore the message :slight_smile:

  1. Dimmable lights with preset for time interval (night/day)
  2. Multiple ambient Light Sensors as condition with AND or OR - very usefull for stairs where there are 2 motion sensors with illuminance (bottom and top of stairs)
  3. Check the lights status before sending commands to it in order to reduce traffic in zwave/zigbee networks.

Question also: how does the bypass works? is it checking for On state for a certain period of time or just the instant On/Off status ? As i’d like to use a binary motion sensor as bypass with the off status of some minutes.

As for #2

Multiple ambient Light Sensors as condition with AND or OR - very usefull for stairs where there are 2 motion sensors with illuminance (bottom and top of stairs)

You could very easily accomplish this using a helper.

For instance, with a min / max / mean / median sensor helper. You could make it a mean, min, or max of the two sensors. Or even the last updated.

1 Like