#Automation based on occupancy, time of day and ambient light

1 messages · Page 1 of 1 (latest)

neon pivot
#

Hi everyone ! First of all, please apologies if my english is not perfect.
I am very new to HA and I want to create an automation in my living room that :

  • turns lights ON at 100% when my presence sensor (Aqara FP2) detects someone, time of day is between 7:30AM and 11PM, and lux is below 100
  • turns lights OFF when lux is above 100 between 7:30AM and 11PM
  • turns lights ON at 20% between 11PM and 7:30AM when presence is detected

I have the automation ALMOST working... What doesn't work is when for example I am working in the living room, so my sensor is already in "detected" state, so when lux drops below 100 lights won't turn on because the sensor doesn't change state...

Would anyone have a solution please ? 🙂

Thanks !!

brazen marsh
#

The concept you need is called “matching triggers and conditions”. If you want the automation to trigger only when several things are true simultaneously then you need to trigger when each one becomes true, and then only execute the actions if all of them all true.

#

By the way, when you share code, don’t share images.

hollow hawkBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

neon pivot
#

Hello Mekaneck and thank you for your answer, I am sorry about the image, I will definitely use one of these sites from now on.

I googled "matching triggers and conditions" but I can't seem to find how it translates in Home Assistant...

So if I understand well, I put all my triggers together in the "When" part, and then what do I do ?

Thank you again, this is my very first "complex" automation so thank you for your kindness and patience 🙂

brazen marsh
#

Yes you should have 5 triggers. Ask yourself: what could change where I now want to take action? Anything that you think of should go in the trigger section:

  • presence sensor (Aqara FP2) detects someone (use a state trigger)
  • presence sensor (Aqara FP2) does not detect anyone (use a state trigger)
  • time of day is 7:30AM (use a time trigger)
  • time of day is 11PM (use a time trigger)
  • lux goes below 100 (use a numeric state trigger)
  • lux goes above 100 (use a numeric state trigger)
#

Then, for each option in your choose block, think about all the conditions that need to be true for that option to be executed. For example, for your first option, you need 3 conditions:

  • presence is detected (use a state condition)
  • time is after 7:30am and before 11pm (use a time condition)
  • lux is below 100 (use a numeric state condition)
#

You won’t be able to use trigger ID’s because any of 3 different triggers (that you care about for this option) could have fired to start the automation, but you still need to check if the others are currently true and so you have to list out the actual condition.

Which is why the concept is called “matching triggers and conditions” because you have to repeat the same items in your conditions that you already have in your triggers

#

Also consider whether or not you want the automation to “fight” you, meaning: do you want to enforce those scenarios no matter what? For example:

you walk into the room at 8pm, lux is 50, and so the light turns on at 100%. Great, automation is working as intended. Now, you walk over to the light and turn it to 50%. Do you want your automation to immediately change it back to 100%? If so, you need to add another trigger, which would be a state trigger for that light. If you reboot HA (or it was shut down for a while), do you want to verify the conditions in the room are correct and take action upon boot-up? If so, add a “homeassistant startup” trigger