Got it fixed by a modification in the blueprint, it is now also capable on triggering true and false.
commited the changes in the fork on Github gist.
Got it fixed by a modification in the blueprint, it is now also capable on triggering true and false.
commited the changes in the fork on Github gist.
I would love this also did you get that going
yes it works like a charm now
I pushed the changes to GitHub Gist, I think someone should review the code and when approved merge it into the master.
I am getting an error every time it activates and stays active:
Logger: homeassistant.helpers.condition
Source: helpers/condition.py:458
First occurred: 11:59:19 AM (2 occurrences)
Last logged: 12:02:49 PM
Error during template condition: TemplateError: str: Invalid domain name āā
any ideas on that?
I have it working so far. Many thanks for your work here @networkingcat.
There are two things I didnāt manage to configure yet. Maybe someone could guide me into the right direction.
First thing Iād like is to prevent the automation from running after the lights are being activated by everything other than the automation itself. It should basically do nothing when the light is already on - not overriding the current light and not switching lights off. I tried it with the light as blocking entityā¦ but that just stops it from working alltogether. I know however this would only help me with the the first part and basically would prevent the automation from ever turning the lights off. Kind of a tailbiter for me at this point.
Second thing is Iād like to achieve is to have my Sonos-player as blocking entity. Basically it shouldnāt turn the light off while something is playing. I read that Iād probably have to build a helper entity for such a thing. Basically make a Boolean out of various states the Sonos-Player announcesā¦ but how?
I worked a bit on it and have a result which works quite well. I wanted to have the lighting dependant from light sensors so I took the code from here: Turn on light, switch, scene, script or group based on motion and illuminance (+ more conditions) and included it into this blueprint.
for thos who like to have it it i here (credits for both original creators! i simply merged both):
blueprint:
name: yama simon v2
description: >
# YAMA V10
Turn on lights or scenes when motion is detected.
Four different scenes can be defined depending on time of day.
For Details see this forum post:
https://community.home-assistant.io/t/yama-yet-another-motion-automation-scenes-ambient-light-and-some-conditions/257062?u=networkingcat
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)
domain: automation
source_url: https://gist.github.com/networkingcat/a1876d7e706e07c8bdcf974113940fb8
input:
motion_entity:
name: Motion Sensor
description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off")
selector:
entity:
light_target:
name: Light
selector:
target:
entity:
domain: light
#added from other blueprint
illuminance_sensor:
name: (OPTIONAL) Illuminance sensor
description: This sensor will be used to determine the illumination.
default:
selector:
entity:
domain: sensor
device_class: illuminance
illuminance_cutoff:
name: (OPTIONAL) Illuminance cutoff value
description: This input_number will be used to compare to the current illumination to determine if it is low.
default:
selector:
entity:
domain: input_number
#till here
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
automation_blocker:
name: Automation Blocker (Optional)
description: Only run if this boolean is in desired state (see next input)
default:
selector:
entity:
automation_blocker_boolean:
name: Automation Blocker Chooser (Optional)
description: Desired state of automation blocker, choose on for on and off for off
default: false
selector:
boolean:
no_motion_blocker:
name: No Motion Blocker (Optional)
description: No motion sequence is not run if this boolean is in desired state (see next input)
default:
selector:
entity:
no_motion_blocker_boolean:
name: No Motion Chooser (Optional)
description: Desired state of no motion blocker, choose on for on and off for off
default: false
selector:
boolean:
elevation_check:
name: Sun elevation check (Optional)
description: This is the angle between the sun and the horizon. Negative values mean the sun is BELOW the horizon.
default: none
selector:
number:
min: -90
max: 90
unit_of_measurement: degrees
scene_ambient:
name: Ambient Scene (Optional)
description: Scene for ambient state. Will be activated when no motion is detected.
default: scene.none
selector:
entity:
domain: scene
time_scene_ambient_start:
name: Ambient time frame start (Optional)
description: Time from which on ambient scene will be activated
default: "00:00:00"
selector:
time:
time_scene_ambient_end:
name: Ambient time frame end (Optional)
description: Time from which on ambient scene will be not activated
default: "00:00:00"
selector:
time:
scene_morning:
name: Scene for the morning (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_morning:
name: Time for the morning scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_day:
name: Scene for the bright day (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_day:
name: Time for the day scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "08:00:00"
selector:
time:
scene_evening:
name: Scene for the evening (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_evening:
name: Time for the evening scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "21:00:00"
selector:
time:
scene_night:
name: Scene for the dark night (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_night:
name: Time for the night scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detectedd.
default: "23:00:00"
selector:
time:
scene_no_motion:
name: Default scene for no motion (Optional)
description: Set this Scene if you want to activate a scene if motion stops
default: scene.none
selector:
entity:
domain: scene
mode: restart
max_exceeded: silent
variables:
#added from other blueprint
illuminance_currently: !input illuminance_sensor
illuminance_cutoff: !input illuminance_cutoff
#till here
scene_ambient: !input scene_ambient
scene_morning: !input scene_morning
scene_day: !input scene_day
scene_evening: !input scene_evening
scene_night: !input scene_night
automation_blocker: !input automation_blocker
automation_blocker_boolean : !input automation_blocker_boolean
no_motion_blocker: !input no_motion_blocker
no_motion_blocker_boolean: !input no_motion_blocker_boolean
elevation_check: !input elevation_check
scene_no_motion: !input scene_no_motion
motion_entity: !input motion_entity
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
- platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
for: !input no_motion_wait
# All Conditions must be true
condition:
# Check if automation blocker exist or is in desired state, otherwise do not run
- condition: or
conditions:
- "{{ automation_blocker == none }}"
- "{{ automation_blocker_boolean and states[automation_blocker].state == 'on' }}"
- "{{ not automation_blocker_boolean and states[automation_blocker].state == 'off' }}"
# Check if elevation input exist or is below desired value, otherwise do not run
- condition: template
value_template: "{{ (elevation_check == none) or (state_attr('sun.sun','elevation') <= elevation_check | float(90)) }}"
action:
- choose:
# Trigger to state == "on"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
#added from other blueprint
- condition: template
value_template: "{{ (illuminance_currently == none) or (illuminance_cutoff == none) or (states[illuminance_currently].state | int < states[illuminance_cutoff].state | int) }}"
#till here
sequence:
- choose:
# Morning Scene
- conditions:
- "{{ scene_morning != 'scene.none'}}"
- condition: time
after: !input time_scene_morning
before: !input time_scene_day
sequence:
- scene: !input scene_morning
# Day Scene
- conditions:
- "{{ scene_day != 'scene.none'}}"
- condition: time
after: !input time_scene_day
before: !input time_scene_evening
sequence:
- scene: !input scene_day
# Evening Scene
- conditions:
- "{{ scene_evening != 'scene.none'}}"
- condition: time
after: !input time_scene_evening
before: !input time_scene_night
sequence:
- scene: !input scene_evening
# Night Scene
- conditions:
- "{{ scene_night != 'scene.none'}}"
- condition: time
after: !input time_scene_night
before: !input time_scene_morning
sequence:
- scene: !input scene_night
# If State -> "On" defaulting to turn light on
default:
- service: light.turn_on
target: !input light_target
# Trigger to state = "off"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
# Check if no motion blocker exist or in in desired state, otherwise do not run any no motion action
- condition: or
conditions:
- "{{ no_motion_blocker == none }}"
- "{{ no_motion_blocker_boolean and states[no_motion_blocker].state == 'on' }}"
- "{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == 'off' }}"
sequence:
- choose:
# Used if ambient scene is true and in ambient scene time frame
- conditions:
- "{{ scene_ambient != 'scene.none' }}"
- condition: time
after: !input time_scene_ambient_start
before: !input time_scene_ambient_end
sequence:
- scene: !input scene_ambient
# Used if default no motion scene is set
- conditions:
- "{{ scene_no_motion != 'scene.none' }}"
sequence:
- scene: !input scene_no_motion
# If State -> "off" default to turn lights off
default:
- service: light.turn_off
target: !input light_target
Figured it out, had to use Node RED though. Even works with the Sonos player.
In case someone finds this looking for the same, glad to help.
@networkingcat
The one missing feature for me is: An option to keep lights on when tv or pc is on
then it is a complete package for me.
Thanks for the awesome work!
Iāve been playing around with this automation the past few days, Iām using the sun elevation check at 5 degrees so the lights only turn on when itās dark outside.
I have two scenes setup, one with the light at its lowest brighteness (night) and one at 70% brightness (morning/evening). Iāve set the time for the night scene to 22:00 but it still triggers the light at 70% brightness. Does anyone have any suggestions?
Edit: Think I solved it by simply making sure I had set a time for the day scene.
Hi guys.Im new in HA and have some trouble to set up automation.
1.In bedroom i have 2x aqara bulbs and aqara motion sensor.I wonāt motion not to be triggered and turn the lights on , from 17h to 22h .
2.In kitchen i would like to have bulbs turn On 20% brightness from 23h to 06.
How can I achieve that ?
Thanks in advance.
@networkingcat, could you help me out?
In my automation the lights on the driveway will be activated when:
When I walk over the driveway in the night the lights turn on, the hassio logbook shows records of the trigger and shows that the lights are activated by the scene.
But the lights never go off again.
I played around with adding a scene in the default scene for no motion that defines the lights in off state also used that scene in the ambient setting but with no succes.
The question is, how can I achieve that when the automation is activated it will de-activate the lights after the configured time?
Hey guys,
I want this automation to trigger only at a certain lux AND only when disarmed. Now i know i can configure this with the BOOLEAN(?) but sadly I have no idea how to. Is there someone thatās got an example for me to try?
I think Iām running into a similar (if not the same) issue. What (I think) Iāve tracked it to is that since Iām using the sun elevation, itās āblockingā the āoffā from turning the lights back off.
What I have observed is that at night, everything works as expected:
Near sunrise (15 degrees) Iāve noticed that the lights will come one due to motion, but then wonāt turn off after motion ends. This morning (after upgrading to 2021.04!) I took a look in the automations trace (my new favorite feature!!) and it seems to confirm this suspicion:
I noticed this as well, I had to make another automation for a numeric state of the sun elevation to turn my lights off.
Has anyone gotten the No Motion Blocker to work? If so can you explain the steps needed. I have a humidity sensor tied to a switch that activates when humidity reaches certain level. I have tried using just the switch entity on as well as that automation. This is the last piece I need to get working.
Hi, I created a input_boolean that is toggled depending on my brightness sensors, I use this boolean as a input blocker so that the lights are not switched on if brightness is too high. All of this works fine, except that the lights are never switched off when the input blocker is blocking.
I fixed this by disabling the condition checks on the āoffā part of the blueprint.
How about adding a toggle that toggles this behaviour out of the box? (Or just adding support for brightness sensors into the blueprint?)
can the target ālightā be any kind of binary entities such as switches, scripts, ā¦?
Hi,
I use your blueprint throughout my apartment and it works great!
However would it be possible to add a condition based on a helper drop down as well?
For example, I set it to ānight modeā i.e. dimmed very low from a certain time e.g. 11pm. However I would like to be able to press a switch which changes my helper dropdown to āsleepā and it it is set to sleep it should activate the dimmed lights no matter what time it is. The reason is that I donāt go to bed at the same time each day and I would like to have an additional control beyond the time of day.
Hope you can get my point. Any idea if this could be added? Or does anyone know of another blueprint that can achieve this?
Thanks a lot
Hi,
how can you set a trasitiontime for the scenes?
Thanks in advance.
Does this blueprint support brightness levels? I donāt want my nightlight at full brightness.