Hi guys,
I’m trying to modify one of nice blueprint for light and scenes controller by motion.
blueprint:
name: Falo-Motion-activated light scene with surrounding light level check and optional
ambient scene
description: Turn on a light scene when motion is detected. Three different scenes
can be defined depending on time of day. Furthermore a source for checking sourrounding
light can be defined to enable light only if it is dark enough.
domain: automation
# source_url: https://gist.github.com/dirkk1980/3e5c23acb05fb639bafdc5036b91aae6
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
lightsensor_entity:
name: Illuminance Sensor
selector:
entity:
domain: sensor
device_class: illuminance
illuminace_level:
name: Max Illuminance
description: Maximal immuminance level in lux. If illuminance is higher, light
will not be enabled
default: 600
selector:
number:
min: 0.0
max: 5000.0
unit_of_measurement: lux
step: 1.0
mode: slider
light_target:
name: Light
selector:
target:
entity:
domain: light
#AMBIENT
scene_ambient:
name: Ambient Scene (Optional)
description: Scene for ambient state. Will be activated when no motion is detected
and light level is under threshold. Default value = scene.none
default: scene.none
selector:
entity:
domain: scene
sun_scene_ambient_start:
name: Ambient time frame start
description: Time from which on ambient scene will be activated
default: none
selector:
number:
min: -90
max: 90
unit_of_measurement: degrees
time_scene_ambient_end:
name: Ambient time frame end
description: Time from which on ambient scene will be not activated
default: 00:00:00
selector:
time: {}
#MORNING
scene_morning:
name: Scene for the morning
default: scene.none
selector:
entity:
domain: scene
sun_scene_morning_start:
name: Time for the morning scene
description: A time input which defines the time from which on the scene will
be activated if motion is detected. Default value = scene.none
default: none
selector:
number:
min: -90
max: 90
unit_of_measurement: degrees
#DAY
scene_day:
name: Scene for the bright day
default: scene.none
selector:
entity:
domain: scene
time_scene_day:
name: Time for the day scene
description: A time input which defines the time from which on the scene will
be activated if motion is detected. Default value = scene.none
default: 00:00:00
selector:
time: {}
#EVENING
scene_evening:
name: Scene for the evening
default: scene.none
selector:
entity:
domain: scene
sun_scene_evening_start:
name: Time for the evening scene
description: A time input which defines the time from which on the scene will
be activated if motion is detected. Default value = scene.none
default: none
selector:
number:
min: -90
max: 90
unit_of_measurement: degrees
#NIGHT
scene_night:
name: Scene for the dark night
default: scene.none
selector:
entity:
domain: scene
time_scene_night:
name: Time for the night scene
description: A time input which defines the time from which on the scene will
be activated if motion is detectedd. Default value = scene.none
default: 00:00:00
selector:
time: {}
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
mode: restart
max_exceeded: silent
variables:
scene_ambient: !input 'scene_ambient'
trigger:
platform: state
entity_id: !input 'motion_entity'
from: 'off'
to: 'on'
action:
- choose:
#scene morning
- conditions:
- condition: template
value_template: "{{(sun_scene_morning_start == none) or ((state_attr('sun.sun','elevation')) > (sun_scene_morning_start | int)) }}"
- condition: time
# after: !input 'time_scene_morning'
before: !input 'time_scene_day'
- condition: numeric_state
entity_id: !input 'lightsensor_entity'
below: !input 'illuminace_level'
sequence:
- scene: !input 'scene_morning'
#scene day
- conditions:
- condition: time
after: !input 'time_scene_day'
# before: !input 'time_scene_evening'
- condition: template
value_template: "{{(sun_scene_evening_start == none) or ((state_attr('sun.sun','elevation')) > (sun_scene_evening_start | int)) }}"
- condition: numeric_state
entity_id: !input 'lightsensor_entity'
below: !input 'illuminace_level'
sequence:
- scene: !input 'scene_day'
#scene evening
- conditions:
- condition: template
value_template: "{{((sun_scene_evening_start == none) or ((state_attr('sun.sun','elevation')) <= (sun_scene_evening_start | int)) }}"
- condition: time
# after: !input 'time_scene_evening'
before: !input 'time_scene_night'
- condition: numeric_state
entity_id: !input 'lightsensor_entity'
below: !input 'illuminace_level'
sequence:
- scene: !input 'scene_evening'
#scene night
- conditions:
- condition: time
after: !input 'time_scene_night'
- condition: template
value_template: "{{((sun_scene_morning_start == none) or ((state_attr('sun.sun','elevation')) <= (sun_scene_morning_start | int)) }}"
# before: !input 'time_scene_morning'
# - condition: numeric_state
# entity_id: !input 'lightsensor_entity'
# below: !input 'illuminace_level'
sequence:
- scene: !input 'scene_night'
#turning on ambient
- wait_for_trigger:
platform: state
entity_id: !input 'motion_entity'
from: 'on'
to: 'off'
- delay: !input 'no_motion_wait'
- choose:
- conditions:
- '{{ scene_ambient != ''scene.none''}}'
- condition: template
value_template: "{{((sun_scene_ambient_start == none) or ((state_attr('sun.sun','elevation')) <= (sun_scene_ambient_start | int)) }}"
- condition: time
# after: !input 'time_scene_ambient_start'
before: !input 'time_scene_ambient_end'
- condition: numeric_state
entity_id: !input 'lightsensor_entity'
below: !input 'illuminace_level'
sequence:
- scene: !input 'scene_ambient'
default:
- service: light.turn_off
target: !input 'light_target'
It looks like blueprint is somehow creating automation ONLY in YAML, but it’s not visible in HA.
In logs have following error:
Logger: homeassistant.components.automation
Source: components/automation/__init__.py:651
Integration: Automation (documentation, issues)
First occurred: 1:09:52 AM (2 occurrences)
Last logged: 1:09:52 AM
Blueprint Falo-Motion-activated light scene with surrounding light level check and optional ambient scene generated invalid automation with inputs OrderedDict([('motion_entity', 'binary_sensor.pir_kitchen_coffe'), ('lightsensor_entity', 'sensor.wardrobe_light_bh1750_illuminance'), ('illuminace_level', 180), ('light_target', OrderedDict([('entity_id', 'light.kitchencoffeled')])), ('scene_ambient', 'scene.kitchencoffe_ambient'), ('sun_scene_ambient_start', 2), ('time_scene_ambient_end', '23:30:00'), ('scene_morning', 'scene.kitchencoffe_evening'), ('sun_scene_morning_start', 5), ('scene_day', 'scene.kitchencoffe_evening'), ('scene_evening', 'scene.kitchencoffe_evening'), ('time_scene_day', '08:00:00'), ('scene_night', 'scene.kitchen_corner_night'), ('time_scene_night', '22:00:00'), ('no_motion_wait', 5), ('sun_scene_evening_start', -5)]): invalid template (TemplateSyntaxError: unexpected '}', expected ')') for dictionary value @ data['action'][0]['choose'][2]['conditions'][0]['value_template']. Got None
I tried to change all )
in template, but in dev tools this template works, but here not…
Any suggestions?
P.S.
Idea is to have night scene ending based on sun elevation and evening scene starts also on sun elevation.