Skip to content

Commit

Permalink
wakeup event: fix no device off
Browse files Browse the repository at this point in the history
fix A/C (fan, sound machine) not being turned off when light disabled.
  • Loading branch information
brianhanifin committed Oct 4, 2023
1 parent 03c00ed commit 4aa6819
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 100 deletions.
10 changes: 4 additions & 6 deletions integrations/events/event_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ automation:
{%- if event_hour < 6 %}
{{ high_school_day }}
{%- else %}
{{ high_school_day_tomorrow or high_school_day_tomorrow }}
{{ high_school_day_tomorrow }}
{%- endif %}
{%- elif id == "bedtime_boys_daysoff" %}
{%- if event_hour < 6 %}
Expand Down Expand Up @@ -118,7 +118,6 @@ automation:
event_enabled: '{{ is_state("input_boolean.event_enabled_" + id, "on") }}'
skipnext_entity: 'input_boolean.event_skipnext_{{ id }}'
do_not_skipnext: '{{ is_state(skipnext_entity, "off") }}'
light_enabled: '{{ is_state("input_boolean.event_light_" + id, "on") }}'

event_hour: '{{ states(entity_id)[:2]|int(default=0) }}'
work_day: '{{ is_state("binary_sensor.work_day","on") }}'
Expand Down Expand Up @@ -158,15 +157,14 @@ automation:
# title: '{{ title|default("") }}'
# message: |
# id: {{ id }}
# light_enabled: {{ light_enabled }}
# event_today: {{ event_today }}
# {{ light_enabled and event_today and event_enabled }}
# {{ event_today and event_enabled }}
# {{ do_not_skipnext }}
# notification_id: '{{ id|default("debug_" ~ as_timestamp(now())) }}'

- alias: 'Continue if the wakeup light is enabled, today is an event day, and the event is not deactivated.'
- alias: 'Continue when today is an event day, and the event is not deactivated.'
condition: template
value_template: '{{ light_enabled and event_today and event_enabled }}'
value_template: '{{ event_today and event_enabled }}'

- choose:
- conditions: '{{ do_not_skipnext }}'
Expand Down
3 changes: 2 additions & 1 deletion integrations/events/event_wakeup_brian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ script:
- variables:
id: &id >
wakeup_brian
light_enabled: '{{ states("input_boolean.event_light_" ~ id|trim) }}'
light_name: &light_name >
{{ states("input_select.event_light_" ~ id|trim) }}
wakeup_light: &wakeup_light >
{%- set entity_list = states.light | selectattr("name","eq",light_name) | map(attribute="entity_id") | list %}
{{ iif(entity_list|count > 0, entity_list[0], "error") }}
- if:
- '{{ wakeup_light != "error" }}'
- '{{ light_enabled == "on" and wakeup_light != "error" }}'
then:
- service: script.event_light
continue_on_error: true
Expand Down
26 changes: 9 additions & 17 deletions integrations/events/event_wakeup_kyle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@
script:
event_wakeup_kyle:
sequence:
# - service: light.turn_on
# target:
# entity_id: light.kyle_bedside
# data:
# brightness: 26
# - delay:
# seconds: 1
# - service: light.turn_on
# target:
# entity_id: light.kyle_bedside
# data:
# brightness: 26

- service: script.event_light
data:
light: light.kyle_bedside
id: wakeup_kyle
- if:
- condition: state
entity_id: input_boolean.event_light_wakeup_kyle
state: "on"
then:
- service: script.event_light
data:
light: light.kyle_bedside
id: wakeup_kyle

event_timeout_wakeup_kyle:
sequence:
Expand Down
14 changes: 9 additions & 5 deletions integrations/events/event_wakeup_lucas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
script:
event_wakeup_lucas:
sequence:

- service: climate.set_hvac_mode
data:
hvac_mode: "off"
target:
entity_id: climate.lucas_room_thermostat

- service: script.event_light
data:
entity_id: light.lucas_room
id: wakeup_lucas
- if:
- condition: state
entity_id: input_boolean.event_light_wakeup_lucas
state: "on"
then:
- service: script.event_light
data:
entity_id: light.lucas_room
id: wakeup_lucas

event_timeout_wakeup_lucas:
sequence:
Expand Down
69 changes: 0 additions & 69 deletions integrations/events/event_wakeup_lucas_late_start.yaml.disabled

This file was deleted.

3 changes: 2 additions & 1 deletion integrations/events/event_wakeup_nerene.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ script:
- variables:
id: &id >
wakeup_nerene
light_enabled: '{{ states("input_boolean.event_light_" ~ id|trim) }}'
light_name: &light_name >
{{ states("input_select.event_light_" ~ id|trim) }}
wakeup_light: &wakeup_light >
{%- set entity_list = states.light | selectattr("name","eq",light_name) | map(attribute="entity_id") | list %}
{{ iif(entity_list|count > 0, entity_list[0], "error") }}
- if:
- '{{ wakeup_light != "error" }}'
- '{{ light_enabled == "on" and wakeup_light != "error" }}'
then:
- service: script.event_light
data:
Expand Down
3 changes: 2 additions & 1 deletion integrations/events/event_wakeup_nerene_modified.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ script:
- variables:
id: &id >
wakeup_nerene_modified
light_enabled: '{{ states("input_boolean.event_light_" ~ id|trim) }}'
light_name: &light_name >
{{ states("input_select.event_light_" ~ id|trim) }}
wakeup_light: &wakeup_light >
{%- set entity_list = states.light | selectattr("name","eq",light_name) | map(attribute="entity_id") | list %}
{{ iif(entity_list|count > 0, entity_list[0], "error") }}
- if:
- '{{ wakeup_light != "error" }}'
- '{{ light_enabled == "on" and wakeup_light != "error" }}'
then:
- service: script.event_light
continue_on_error: true
Expand Down

0 comments on commit 4aa6819

Please sign in to comment.