Add automation for Give Me Darkness if we haven't run it, close #161
This commit is contained in:
@ -2974,3 +2974,30 @@
|
|||||||
adapt_brightness: '{{ is_state(''switch.adaptive_lighting_adapt_brightness_master_bedroom'',''on'')
|
adapt_brightness: '{{ is_state(''switch.adaptive_lighting_adapt_brightness_master_bedroom'',''on'')
|
||||||
}}'
|
}}'
|
||||||
mode: restart
|
mode: restart
|
||||||
|
- id: '1697819133179'
|
||||||
|
alias: Give Me Darkness
|
||||||
|
description: Automatically trigger Give Me Darkness if it has not already happened
|
||||||
|
trigger:
|
||||||
|
- platform: template
|
||||||
|
value_template: '{% from ''time.jinja'' import ct %}
|
||||||
|
|
||||||
|
{% set ct = ct() | int %}
|
||||||
|
|
||||||
|
{% set bedtime = states(''input_datetime.kallen_bedtime'') | int + 1800 %}
|
||||||
|
|
||||||
|
{{ ct >= bedtime }}'
|
||||||
|
alias: When it is half an hour past K's bedtime
|
||||||
|
condition:
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.give_me_darkness
|
||||||
|
state: 'off'
|
||||||
|
alias: Give Me Darkness isn't already on
|
||||||
|
- condition: state
|
||||||
|
entity_id: binary_sensor.parents_home
|
||||||
|
state: 'on'
|
||||||
|
alias: We are home
|
||||||
|
action:
|
||||||
|
- service: script.give_me_darkness
|
||||||
|
data:
|
||||||
|
auto: 1
|
||||||
|
mode: single
|
||||||
|
37
scripts.yaml
37
scripts.yaml
@ -44,17 +44,36 @@ give_me_darkness:
|
|||||||
retain: true
|
retain: true
|
||||||
topic: house/time/give_me_darkness
|
topic: house/time/give_me_darkness
|
||||||
payload: 'on'
|
payload: 'on'
|
||||||
- if:
|
- alias: Security decision
|
||||||
- condition: state
|
if:
|
||||||
entity_id: input_boolean.guest_mode
|
- condition: and
|
||||||
state: 'off'
|
conditions:
|
||||||
|
- condition: state
|
||||||
|
entity_id: person.tony_stork
|
||||||
|
state: home
|
||||||
|
- condition: state
|
||||||
|
entity_id: person.christina_stork
|
||||||
|
state: home
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.guest_mode
|
||||||
|
state: 'off'
|
||||||
|
- condition: state
|
||||||
|
entity_id: alarm_control_panel.nerdhome_alarm_panel
|
||||||
|
state: disarmed
|
||||||
|
alias: Both adults are home, guest mode off, security disarmed
|
||||||
then:
|
then:
|
||||||
- if:
|
- alias: Auto or manual trigger?
|
||||||
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: '{{ is_state(''person.tony_stork'',''home'') and is_state(''person.christina_stork'',''home'')
|
value_template: '{{ auto == 1 }}'
|
||||||
}}'
|
alias: Triggered by automation
|
||||||
alias: Both adults are home
|
|
||||||
then:
|
then:
|
||||||
|
- service: alarm_control_panel.alarm_arm_home
|
||||||
|
data: {}
|
||||||
|
target:
|
||||||
|
entity_id: alarm_control_panel.nerdhome_alarm_panel
|
||||||
|
alias: Arm security
|
||||||
|
else:
|
||||||
- service: script.activate_alexa_actionable_notification
|
- service: script.activate_alexa_actionable_notification
|
||||||
data:
|
data:
|
||||||
text: <voice name='Joanna'><prosody rate='150%'>Would you like me to arm
|
text: <voice name='Joanna'><prosody rate='150%'>Would you like me to arm
|
||||||
@ -62,8 +81,6 @@ give_me_darkness:
|
|||||||
event_id: actionable_notification_night_security_arm
|
event_id: actionable_notification_night_security_arm
|
||||||
alexa_device: '{{ states(''sensor.last_alexa_entity_id'') }}'
|
alexa_device: '{{ states(''sensor.last_alexa_entity_id'') }}'
|
||||||
alias: Ask to arm security
|
alias: Ask to arm security
|
||||||
alias: Ask to arm security if both adults are home
|
|
||||||
alias: If guest mode is off
|
|
||||||
mode: single
|
mode: single
|
||||||
icon: mdi:weather-night
|
icon: mdi:weather-night
|
||||||
start_youtube:
|
start_youtube:
|
||||||
|
Reference in New Issue
Block a user