diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index 4b8a211..a7fc370 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -224,6 +224,152 @@ automation: White Noise {% endif %} + - id: 5b45eeb2-171e-4bac-825b-8ac7aa672dab + alias: Emma Bedtime Update + description: Attempt to make readouts of when Emma went to bed more accurate + mode: restart + trigger: + - platform: state + entity_id: input_boolean.emma_sleeping + from: 'off' + to: 'on' + id: initial + - platform: event + event_type: timer.finished + event_data: + entity_id: timer.emma_bedtime_update + id: bedtime-timer-finished + - platform: event + event_type: timer.finished + event_data: + entity_id: timer.emma_naptime_update + id: naptime-timer-finished + - platform: state + entity_id: light.emma_bedroom_light + to: 'off' + id: lights-off + action: + - choose: + - conditions: + - condition: trigger + id: initial + sequence: + - choose: + - conditions: + - condition: and + conditions: + - condition: state + entity_id: input_boolean.emma_has_napped + state: 'off' + - condition: time + before: "23:00:00" + after: "04:00:00" + sequence: + - service: timer.start + target: + entity_id: timer.emma_naptime_update + data: + duration: "01:00:00" + - conditions: + - condition: or + conditions: + - condition: state + entity_id: input_boolean.emma_has_napped + state: 'on' + - condition: time + after: "23:00:00" + before: "04:00:00" + sequence: + - service: timer.start + target: + entity_id: timer.emma_bedtime_update + data: + duration: "01:00:00" + - conditions: + - condition: trigger + id: lights-off + sequence: + - if: + - condition: state + entity_id: input_boolean.emma_sleeping + state: 'on' + then: + - choose: + - conditions: + - condition: and + conditions: + - condition: state + entity_id: input_boolean.emma_has_napped + state: 'off' + - condition: time + before: "23:00:00" + after: "04:00:00" + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_down_for_nap + data: + datetime: "{{ as_timestamp(now()) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}" + - conditions: + - condition: or + conditions: + - condition: state + entity_id: input_boolean.emma_has_napped + state: 'on' + - condition: time + after: "23:00:00" + before: "04:00:00" + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_bedtime + data: + datetime: > + {% from 'time.jinja' import current_time %} + {{ current_time(24) }} + - conditions: + - condition: trigger + id: naptime-timer-finished + sequence: + - if: + - condition: state + entity_id: light.emma_bedroom_light + state: 'on' + then: + - service: timer.start + target: + entity_id: timer.emma_naptime_update + data: + duration: "01:00:00" + else: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_down_for_nap + data: + datetime: "{{ as_timestamp(now()) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}" + - conditions: + - condition: trigger + id: bedtime-timer-finished + sequence: + - if: + - condition: state + entity_id: light.emma_bedroom_light + state: 'on' + then: + - service: timer.start + target: + entity_id: timer.emma_bedtime_update + data: + duration: "01:00:00" + else: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_bedtime + data: + datetime: > + {% from 'time.jinja' import current_time %} + {{ current_time(24) }} + - id: e59f638a-519f-4619-bf7d-b13251b3a374 alias: Emma Meds Handler description: Handles reminders for Emma taking her meds when sick or teething @@ -787,4 +933,4 @@ script: seconds: 5 - service: fan.turn_off target: - entity_id: fan.emma_air_conditioner + entity_id: fan.emma_air_conditioner \ No newline at end of file