Skip to content

Instantly share code, notes, and snippets.

@ALERTua
Created November 15, 2025 10:17
Show Gist options
  • Select an option

  • Save ALERTua/9d8f2d784f3c9d6257a6b3889fb0b57e to your computer and use it in GitHub Desktop.

Select an option

Save ALERTua/9d8f2d784f3c9d6257a6b3889fb0b57e to your computer and use it in GitHub Desktop.
power outage starts in
alias: Power Outage Starts in
description: ""
triggers:
- event: start
offset: "-2:0:50"
entity_id: calendar.planned_outages_kiiv_dtek_3_1
trigger: calendar
enabled: false
- event: start
offset: "-1:0:50"
entity_id: calendar.planned_outages_kiiv_dtek_3_1
trigger: calendar
enabled: false
- event: start
offset: "-0:30:50"
entity_id: calendar.planned_outages_kiiv_dtek_3_1
trigger: calendar
- event: start
offset: "-0:5:50"
entity_id: calendar.planned_outages_kiiv_dtek_3_1
trigger: calendar
- event: start
offset: "-0:0:50"
entity_id: calendar.planned_outages_kiiv_dtek_3_1
trigger: calendar
enabled: false
conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.audio_alerts
state: "on"
enabled: false
- condition: state
entity_id: input_boolean.power_outage_calendar
state: "on"
- condition: state
entity_id: binary_sensor.power
state: "on"
- condition: state
entity_id: binary_sensor.someone_s_home
state: "on"
- condition: template
value_template: "{{trigger.calendar_event.description == 'Definite'}}"
- condition: not
conditions:
- condition: or
conditions:
- condition: state
entity_id: sensor.kiiv_dtek_3_1_next_planned_outage
state: unavailable
- condition: state
entity_id: sensor.kiiv_dtek_3_1_next_planned_outage
state: unknown
actions:
- action: pyscript.broadcast_optional
data:
language: uk
message: >-
{% set battery1 = states('sensor.delta_pro_battery_level') | default(-1)
| float %}
{% set battery1_target = states('number.delta_pro_max_charge_level') |
default(100) | float %}
{% set start = trigger.calendar_event.start|as_datetime|as_local %}
{% set start_minutes = (start - now()).seconds // 60 %}
{% set end = trigger.calendar_event.end|as_datetime|as_local %}
{% set duration_hours = (end - start).seconds // 60 // 60 %}
{% set end_str = end|as_timestamp|timestamp_custom('%H:%M') %}
Відключення електроенергії може відбутися за {{ start_minutes }} хвилин
і продовжиться {{ duration_hours }} години до {{end_str}}. {% if
start_minutes <= 5 -%}
Не забудьте закипятити воду, а потім перемкнутися на екофл`оу.
{%- endif %}
{% if battery1 >= 0 and battery1 < battery1_target - 15 %}
Рівень заряду екофлоу дельта про - {{battery1 | round(0) | int }} відсотків.
{% endif %}
enabled: true
- action: system_log.write
metadata: {}
data:
level: info
message: >-
Power Outage Starts in trigger.calendar_event:
{{trigger.calendar_event}}
{{trigger.calendar_event.description}}
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment