YAMA - Yet Another Motion Automation (Scenes, Ambient Light and some Conditions )

Hi there,

This is just another motion automation.

Get started

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the Gist URL:

Capabilitys

  • Trigger on motion (in fact can be triggered by anything that switches between “on” and off")
  • Wait time for turning off
  • Only run if entity is in desired state (optional)
  • Sun elevation check (optional)
  • 4 Scenes for different times of day (optional)
  • ambient support with time frame (optional)
  • Default scene when motion stops (optional)
  • “no motion blocker” with user choosable state (optional)

What can i do with that stuff?

  • The simplest thing you can do is turn a light on when a motion sensor detects movement and turn it off when movement stops.
  • Instead of a motion sensor you can use a group to trigger this (very usefull if you want to group multiple motion sensors)
  • Anything what switches between “on” and “off” can trigger this automation (So an input boolean too)
  • With the automation blocker (only run if entity is in desired state) you can block this automation from running. This is can be usefull though you want an nightmode where you dont want to run this or when you have “TV Time” on in the living room with special light setting and do not want to change them during this time. You can use the automation blocker chooser to decide whether this blocker should be on or off. The used entity must be something with the states “on” and “off”
  • With the sun elevation check you can block this automation from running depending on the angle of the sun. Usefull when you only want to run this when it is getting dark/ before sunrise.
  • With scene support you can define different scenes for the day. Like special lights in the morning, normal lights during the day, dimmed lights in the evening and just a 30% Red light during the night to go on the bathroom.
  • With ambient support you can, during a specified time frame, have a default light and when motion starts lights change to whatever you want and after motion stops it goes back to ambient lights.
  • With default scene when motion stops you can execute a scene instead of turning of lights. This is usefull if you only want to use scenes or if you must. This is the case if you use switches instead of lights.
  • With the “no motion blocker” you can deactivate the actions if the entity switches to “off” (for configured wait time). You can use this if you want that nothing happens if you do something (which needs to set the blocker in the desired state) which needed the lights in its original states. Like you are going in the bathroom and your lights go on via motion. Now you take a shower and the motion sensor do not see you anymore. But humidity spikes which activates the no motion blocker, so lights stay on.

Flowcharts for better unstanding:

When no motion entity switches to “off” for desired wait time:
mermaid-diagramm-off

I am by no means an automation expert for Home Assistant (used node red before) but i am willing to add stuff to this if it possible (for me)

If you encounter any bug please post them so they can be fixed.
If you are missing a feature feel free to post them too.

Wishlist

  • Trigger another automation
  • Light Level as condition (optional)
  • Offset for working days

Changelog

20.12.2020: Added Automation Blocker (Only run if input_boolean is true)
21.12.2020: Removed entity from motion entity input
23.12.2020: Added sun elevation check
23.12.2020: Added optional default scene when motion stops
27.12.2020: Make automation blocker user choosable
30.12.2020: Add no motion blocker with user choosable state
01.01.2021: V08: restructure of action logic
04.01.2021: V09: fixed bug with elevation check
06.01.2021: V10: blocker must not be input boolean but can be anything with “on”/“off”

Originally forked from Enhanced motion controller to activate scenes by time and illuminance - now in addition with idle ambient scene

27 Likes

Great, this is wat I needed! My motion detector (tradfri) doesn’t have a lux meter so I couldn’t use the one you forked from. When I get home I’ll try yours!

1 Like

Thats good to hear. please let me know if everything you tested and if it worked :slight_smile:

Also i am in the process of adding groups as input also, i am trying to find an elegant way of doing this but i do not know if blueprints can do this.
Otherwise i need to use two inputs as triggers which could be confusing for user and makes the blueprint a lot harder to maintain.

We will see

1 Like

Added an automation blocker and updated original post.

2 Likes

Now not only motion sensor can trigger this. You can chosse whatever you want but it must switch between “on” and “off”.
I changed these because i need group as a trigger. (Best way to group multiple motion sensors)

Hi. How to Import to ha? Get failure: No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

Hi,
please use this link:

2 Likes

Getting the error when uploading the file to HA and trying to use it under BluePrints):

Invalid blueprint: Expected a dictionary for dictionary value @ data['blueprint']['input']['motion_entity']['selector']. Got None
1 Like

I believe this is missing:

selector:
  entity:

I created a temporary fork to test it:

1 Like

Hi,

thanks for notice me.

I messed up some copy and pasting with Gist.

It is fixed now

Hi,

State of this Blueprint:

I do not know if anyone is really using this but at the moment i do not know how to move forward with this Blueprint. The last thing i need is that nothing happens if an input_boolean is true. (So after motion stops)
I can integrate this in a way it works for me and just stop then.

But i have some more ideas which could be usefull for other users.

Like defining an scene to activate if motion is stopping.
Or just read the entitys of an activated scene (if used) and turn this lights out (So no need to pick target lights if you want to use scenes). But for that i don´t know if it is easly possible to get the entitys of the used scene. Although it is possible to just get all and make this blueprint more complicated.

The thing is with everything optional chance is high that there are a lot of if, else, … which makes again, this blueprint harder too maintain. So if not used i do not need to configure this in :smiley:

Also i am thinking that this blueprint needs some rework and use of templeting.

1 Like

so far, it looks like its working just fine…

Im only using the first time setting (just a rough time for when it gets dark… been having issues with my blueprint that does so based on sun elevation…)

Thanks for letting me know.

I don’t really understand that. (you mean for ambience light?)
Can you describe what you want to do?

Sorry…
Not looking to do anything more than your blueprint currently does (I just happen to only use 1 of your time selections… Separate from that idea was that I wrote a blueprint that is supposed to trigger switches with motion but only when the sun is X degrees below the horizon (or, X or less above) and I ended up using your blueprint to effectively accomplish the same thing with your time settings… its a nice feature)…

Completely different note from all of that: I did modify yours a tiny bit to be able to be used with switches… (any chance you can have an either/or/both lights / switches all in 1 blueprint?)

This time settings are from the original fork, so props to @dkoehler

Am i right that sun elevation ist just one condition (one angle) ? I only worked with sunset/sunrise before.
Because i could build that in as optional blocker.
It would plain and simple blocks this automation from running if the elevation is outside the desired angle.

Switches as trigger should already work but you want that as target.
I would love to build that in but that is not easy at it seems. The target selector does not work with multiple domains and when i remove the light domain (then you could target what you want) the whole purpose of the target selector is gone.

But you could used scenes.

I´ve added an optional elevation check.
This means you can now check the angle between the sun and the horizon and block this automation frum running if it is not below an given angle.

I´ve added an optional default scene for “no motion”.

This means you can now execute a scene after motion stops instead of turning lights of.

So:

  • no motion
  • wait timer
  • if ambient scene set and in time frame -> ambient scene
  • if default no motion scene set -> no motion scene
  • if both not true -> turn of lights

Hey,

with the recent additions you could use this blueprint if you want.
Elevation check is implemented, also you can use a scene to execute when motion stops. So instead of turning off the switches you just execute a scene (where the switches are off).

As soon as a target selector supports multiple domains this could be achived without a scene, but at the moment this is not possible.

Well, i like this blueprint very much, but from my point of view one thing is missing:
a switch for workday/weekend mode.
on week days i sleep longer so all the times should be shiftet to 2 hours later.

So a flag to activate a time offset would be nice. Is this usefull/possible?

Greetings from germany and stay safe.

Ludger

Hi,

that is something i never thought of. I think having kids means there are no days where you can sleep longer :smiley:

In general this can be build in. Unfortunately i do not see an easy way make this happen without a helper input_boolean defined outside of this blueprint. An generally i want to avoid having external stuff in this blueprint (for easy use for everyone). So by making this optional this would be still true.

The best way i see at the moment is “use time offset (which is defined in blueprint) if a particular input_boolean is true)”

Other method i see is a boolean selector. With this user can choose if offset should be used or not. Downside is that i see no good way of make the days user definable.

(I really want a collapse feature in the blueprint fronend)

This offset would only be used for turning on scenes (or do you thought of something different?)

Also mabe someone else has a better idea

Greetings from Hannover

Edit:
Maybe it is smarter to use Workday Sensor intead of a input_boolean

1 Like