Added 3 automations: motion, dimmer and dial

This commit is contained in:
Pavel Kachalouski
2023-05-20 12:24:11 +02:00
commit a5142410de
3 changed files with 704 additions and 0 deletions

View File

@@ -0,0 +1,186 @@
blueprint:
name: Turn on based on motion
description:
"Turn on a light, switch, scene, script or group based on motion detection,\
\ and low light level.\n\
\nRequired entities:\n - Motion sensor (single sensor or group)\n - Target entity\
\ (light, switch, scene or script)\n\n\nOptional features:\n- You can set a cutoff\
\ entity of which the value determines whether the illuminance level is low and\
\ the automation needs to trigger. \n- You can define a blocking entity, which blocks\
\ the automation from running when this entity's state is on. \n- You van define\
\ a turn-off blocking entity, which blocks the entity from turning off after the\
\ set delay. \n- Time limits can also be defined to limit the time before and after\
\ the automation should trigger. \n- If you want the entity to turn off after a\
\ certain amount of seconds, you can use the Wait Time input. \n- If you want another\
\ entity than the target_entity to turn off after the delay, you can define a\
\ separate Turn-off entity. \n- If you do not enable the optional entities the automation\
\ will skip these conditions."
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: This sensor will trigger the turning on of the target entity.
selector:
entity:
domain: binary_sensor
target_entity:
name: Target entity.
description:
The light, switch, scene to turn on (or script to run) when the
automation is triggered.
selector:
entity: {}
no_motion_wait:
name: Turn off wait time (seconds)
description:
Time in seconds to leave the target entity on after last motion
is detected.
default: 0
selector:
number:
min: 0
max: 600
unit_of_measurement: seconds
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:
number:
min: 0
max: 100
unit_of_measurement: lx
blocker_entity:
name: (OPTIONAL) Blocking entity
description:
If this entity's state is on, it will prevent the automation from
running. E.g. sleepmode or away mode.
default:
selector:
entity: {}
time_limit_after:
name: (OPTIONAL) Only run after time.
description:
Automation will only run when time is later than this input_datetime
value.
default:
selector:
entity:
domain: input_datetime
time_limit_before:
name: (OPTIONAL) Only run before time.
description:
Automation will only run when time is earlier than this input_datetime
value.
default:
selector:
entity:
domain: input_datetime
turn_off_blocker_entity:
name: (OPTIONAL) Turn-off Blocking entity
description:
If this entity's state is on, it will prevent the target entity
from turning off after the set delay.
default:
selector:
entity: {}
target_off_entity:
name: (OPTIONAL) Turn-off entity
description:
If defined, this entity will be turned off instead of the default
target entity. This can be helpful when using target entities of type scene
or script.
You cannot use Turn-off entity and Turn-off action, only one or the other. If both are defined, Turn-off entity will be used.
default:
selector:
entity: {}
target_off_action:
name: (OPTIONAL) Turn-off action
description:
If defined, this action will be run instead of the turning off the default target entity. This can be helpful when using taget entities of type scene or script.
You cannot use Turn-off entity and Turn-off action, only one or the other. If both are defined, Turn-off entity will be used.
default:
selector:
action: {}
source_url: https://github.com/apollo1220/blueprints/blob/main/motion_activated_entity.yaml
mode: restart
max_exceeded: silent
variables:
target_entity: !input "target_entity"
illuminance_currently: !input "illuminance_sensor"
illuminance_cutoff: !input "illuminance_cutoff"
blocker_entity: !input "blocker_entity"
time_limit_before: !input "time_limit_before"
time_limit_after: !input "time_limit_after"
no_motion_wait: !input "no_motion_wait"
turn_off_blocker_entity: !input "turn_off_blocker_entity"
target_off_entity: !input "target_off_entity"
target_off_action: !input "target_off_action"
trigger:
platform: state
entity_id: !input "motion_sensor"
to: "on"
condition:
- condition: template
value_template:
"{{ (states(target_entity) == 'on') or (illuminance_currently
== none) or (illuminance_cutoff == none) or (states[illuminance_currently].state
| int < illuminance_cutoff | int) }}"
- condition: template
value_template:
"{{ (blocker_entity == none) or (states[blocker_entity].state ==
'off') }}"
- condition: template
value_template: '{% set current_time = now().strftime("%H:%M") %}
{% if time_limit_before != none and time_limit_after == none %} {{ states[time_limit_before].state
> current_time }} {% elif time_limit_before == none and time_limit_after != none
%} {{ states[time_limit_after].state < current_time }} {% elif time_limit_before
!= none and time_limit_after != none %} {% set before_limit_is_on_next_day = states[time_limit_after].state
> states[time_limit_before].state %} {% if not before_limit_is_on_next_day %} {{ (states[time_limit_after].state
< current_time) and (states[time_limit_before].state > current_time) }} {% elif
before_limit_is_on_next_day %} {{ (states[time_limit_before].state > current_time)
or (states[time_limit_after].state < current_time) }} {% endif %} {% else %} true
{% endif %}
'
action:
- service: homeassistant.turn_on
entity_id: !input "target_entity"
- condition: template
value_template: "{{ no_motion_wait != none }}"
- wait_for_trigger:
platform: state
entity_id: !input "motion_sensor"
from: "on"
to: "off"
- delay:
seconds: "{{ no_motion_wait | int }}"
- condition: template
value_template:
"{{ (turn_off_blocker_entity == none) or (states[turn_off_blocker_entity].state
== 'off') }}"
- choose:
- conditions:
- condition: template
value_template: "{{ (target_off_entity != none) }}"
sequence:
- service: homeassistant.turn_off
entity_id: !input "target_off_entity"
- conditions:
- condition: template
value_template: "{{ (target_off_action != none) }}"
sequence: !input "target_off_action"
default:
- service: homeassistant.turn_off
entity_id: !input "target_entity"

181
philips_zigbee_dial.yaml Normal file
View File

@@ -0,0 +1,181 @@
blueprint:
name: Philips Tap Dial Switch
description: "Control lights with a Philips Hue Tap Switch.
Use the four buttons to control up to four light(s) with an on/off toggle. The dial can be used to dim the most recently used light.
"
domain: automation
input:
remote:
name: Philips Hue Tap Switch
selector:
device:
integration: zha
manufacturer: Signify Netherlands B.V.
model: RDM002
first_light:
name: First Light
description: The light(s) to control with first button
selector:
target:
entity: {}
second_light:
name: (OPTIONAL) Second Light
description: The light(s) to control with second button
default: {}
selector:
target:
entity: {}
third_light:
name: (OPTIONAL) Third Light
description: The light(s) to control with third button
default: {}
selector:
target:
entity: {}
forth_light:
name: (OPTIONAL) Forth Light
description: The light(s) to control with forth button
default: {}
selector:
target:
entity: {}
current_light:
name: (OPTIONAL) Current Light
description: "Text helper to track the current light to dim. Set for the dimmer controls to change which light they are controlling according to the last one turned on."
default:
selector:
entity:
domain: input_text
dim_scale:
name: Diming Scale
description: Scale factor for the dimming. This value will be multiplied by the value given from the dial. So lower number, more gradual dimming. Larger number, faster dimming.
default: 1.0
selector:
number:
min: 0.0
max: 5.0
step: 0.01
source_url: https://github.com/apollo1220/blueprints/blob/main/philips_zigbee_dial.yaml
mode: restart
max_exceeded: silent
variables:
first_light: !input "first_light"
second_light: !input "second_light"
third_light: !input "third_light"
forth_light: !input "forth_light"
current_light: !input "current_light"
dim_scale: !input "dim_scale"
lights:
first_light: !input "first_light"
second_light: !input "second_light"
third_light: !input "third_light"
forth_light: !input "forth_light"
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input "remote"
action:
- variables:
command: "{{ trigger.event.data.command }}"
args: "{{ trigger.event.data.args }}"
params: "{{ trigger.event.data.params }}"
scene: "{{ trigger.event.data.params.scene_id }}"
step_mode: "{{ trigger.event.data.params.step_mode }}"
step_size: "{{ trigger.event.data.params.step_size }}"
- choose:
- conditions:
- "{{ command == 'recall' }}"
- "{{ scene == 1 }}"
sequence:
- service: homeassistant.toggle
target: !input "first_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: first_light
- conditions:
- "{{ command == 'recall' }}"
- "{{ second_light != none }}"
- "{{ scene == 0 }}"
sequence:
- service: homeassistant.toggle
target: !input "second_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: second_light
- conditions:
- "{{ command == 'recall' }}"
- "{{ third_light != none }}"
- "{{ scene == 5 }}"
sequence:
- service: homeassistant.toggle
target: !input "third_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: third_light
- conditions:
- "{{ command == 'recall' }}"
- "{{ forth_light != none }}"
- "{{ scene == 4 }}"
sequence:
- service: homeassistant.toggle
target: !input "forth_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: forth_light
- conditions:
- "{{ command == 'step_with_on_off' }}"
- "{{ step_mode == 'StepMode.Up' }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: "{{ step_size * dim_scale }}"
transition: 1
default:
- service: light.turn_on
target: !input "first_light"
data:
brightness_step_pct: "{{ step_size * dim_scale }}"
transition: 1
- conditions:
- "{{ command == 'step_with_on_off' }}"
- "{{ step_mode == 'StepMode.Down' }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: "{{ -step_size * dim_scale }}"
transition: 1
default:
- service: light.turn_on
target: !input "first_light"
data:
brightness_step_pct: "{{ -step_size * dim_scale }}"
transition: 1

337
philips_zigbee_dimmer.yaml Normal file
View File

@@ -0,0 +1,337 @@
blueprint:
name: Philips Dimmer Remote
description: 'Control lights with a Philips Hue Dimmer Switch.
The top "on" button will turn the lights on to the last set brightness
(unless the force brightness is toggled on in the blueprint).
Dim up/down buttons will change the brightness smoothly and can be pressed
and hold until the brightness is satisfactory.
The bottom "off" button will turn the lights off.
If defined it will optionally control up to 5 different sets of lights using the double through quintuple press options. Whichever light was turned on last will be controlled by the dimmer buttons.
'
domain: automation
input:
remote:
name: Philips Hue Dimmer Switch
description: Pick either RWL020 (US) or RWL021 (EU)
selector:
device:
integration: zha
manufacturer: Philips
model: RWL020
single_light:
name: Single Press Light
description: The light(s) to control with single press
selector:
target:
entity: {}
double_light:
name: (OPTIONAL) Double Press Light
description: The light(s) to control with double press (can also use switches)
default: {}
selector:
target:
entity: {}
triple_light:
name: (OPTIONAL) Triple Press Light
description: The light(s) to control with triple press (can also use switches)
default: {}
selector:
target:
entity: {}
quadruple_light:
name: (OPTIONAL) Quadruple Press Light
description: The light(s) to control with quadruple press (can also use switches)
default: {}
selector:
target:
entity: {}
quintuple_light:
name: (OPTIONAL) Quintuple Press Light
description: The light(s) to control with quintuple press (can also use switches)
default: {}
selector:
target:
entity: {}
force_brightness:
name: Force turn on brightness
description:
'Force the brightness to the set level below, when the "on" button
on the remote is pushed and lights turn on.'
default: false
selector:
boolean: {}
brightness:
name: Brightness
description: Brightness of the light(s) when turning on
default: 100
selector:
number:
min: 0.0
max: 100.0
mode: slider
step: 1.0
unit_of_measurement: "%"
current_light:
name: (OPTIONAL) Current Light
description:
'Text helper to track the current light to dim. Set for the dimmer controls to change which light they are controlling according to the last one turned on.
For instance, double press "on" and then the dimmer buttons will control the Double Press Light'
default:
selector:
entity:
domain: input_text
source_url: https://github.com/apollo1220/blueprints/blob/main/philips_zigbee_remote.yaml
mode: restart
max_exceeded: silent
variables:
double_light: !input "double_light"
triple_light: !input "triple_light"
quadruple_light: !input "quadruple_light"
quintuple_light: !input "quintuple_light"
force_brightness: !input "force_brightness"
current_light: !input "current_light"
lights:
single_light: !input "single_light"
double_light: !input "double_light"
triple_light: !input "triple_light"
quadruple_light: !input "quadruple_light"
quintuple_light: !input "quintuple_light"
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input "remote"
action:
- variables:
command: "{{ trigger.event.data.command }}"
cluster_id: "{{ trigger.event.data.cluster_id }}"
endpoint_id: "{{ trigger.event.data.endpoint_id }}"
args: "{{ trigger.event.data.args }}"
- choose:
- conditions:
- "{{ command == 'on_press' }}"
sequence:
- choose:
- conditions: "{{ force_brightness }}"
sequence:
- service: homeassistant.turn_on
target: !input "single_light"
data:
transition: 1
brightness_pct: !input "brightness"
default:
- service: homeassistant.turn_on
target: !input "single_light"
data:
transition: 1
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: single_light
- conditions:
- "{{ command == 'on_double_press' }}"
- "{{ double_light != none }}"
sequence:
- service: homeassistant.turn_on
target: !input "double_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: double_light
- conditions:
- "{{ command == 'on_triple_press' }}"
- "{{ triple_light != none }}"
sequence:
- service: homeassistant.turn_on
target: !input "triple_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: triple_light
- conditions:
- "{{ command == 'on_quadruple_press' }}"
- "{{ quadruple_light != none }}"
sequence:
- service: homeassistant.turn_on
target: !input "quadruple_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: quadruple_light
- conditions:
- "{{ command == 'on_quintuple_press' }}"
- "{{ quintuple_light != none }}"
sequence:
- service: homeassistant.turn_on
target: !input "quintuple_light"
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: input_text.set_value
target:
entity_id: !input "current_light"
data:
value: quintuple_light
- conditions:
- "{{ command == 'off_press' }}"
sequence:
- service: homeassistant.turn_off
target: !input "single_light"
data:
transition: 1
- conditions:
- "{{ command == 'off_double_press' }}"
- "{{ double_light != none }}"
sequence:
- service: homeassistant.turn_off
target: !input "double_light"
- conditions:
- "{{ command == 'off_triple_press' }}"
- "{{ triple_light != none }}"
sequence:
- service: homeassistant.turn_off
target: !input "triple_light"
- conditions:
- "{{ command == 'off_quadruple_press' }}"
- "{{ quadruple_light != none }}"
sequence:
- service: homeassistant.turn_off
target: !input "quadruple_light"
- conditions:
- "{{ command == 'off_quintuple_press' }}"
- "{{ quintuple_light != none }}"
sequence:
- service: homeassistant.turn_off
target: !input "quintuple_light"
- conditions:
- "{{ command == 'step' }}"
- "{{ args == [0, 30, 9] }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: 10
transition: 1
default:
- service: light.turn_on
target: !input "single_light"
data:
brightness_step_pct: 10
transition: 1
- conditions:
- "{{ command == 'step' }}"
- "{{ args == [0, 56, 9] }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: 25
transition: 1
default:
- service: light.turn_on
target: !input "single_light"
data:
brightness_step_pct: 25
transition: 1
- conditions:
- "{{ command == 'up_press' }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: 10
transition: 1
default:
- service: light.turn_on
target: !input "single_light"
data:
brightness_step_pct: 10
transition: 1
- conditions:
- "{{ command == 'step' }}"
- "{{ args == [1, 30, 9] }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: -10
transition: 1
default:
- service: light.turn_on
target: !input "single_light"
data:
brightness_step_pct: -10
transition: 1
- conditions:
- "{{ command == 'step' }}"
- "{{ args == [1, 56, 9] }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: -25
transition: 1
default:
- service: light.turn_on
target: !input "single_light"
data:
brightness_step_pct: -25
transition: 1
- conditions:
- "{{ command == 'down_press' }}"
sequence:
- choose:
- conditions: "{{ current_light != none }}"
sequence:
- service: light.turn_on
target: "{{ lights[states(current_light)] }}"
data:
brightness_step_pct: -10
transition: 1
default:
- service: light.turn_on
target: !input "single_light"
data:
brightness_step_pct: -10
transition: 1