Files
ha-template-migration/templates.yaml
T

267 lines
9.5 KiB
YAML

# ========================================
# MODERN TEMPLATE CONFIGURATION
# ========================================
# Migrated from legacy platform: template syntax
# Migration date: March 2026
# Deadline: Before HA 2026.6
# ========================================
# ========== BINARY SENSORS ==========
- binary_sensor:
# ------ NETWORK MONITORING ------
- name: "Router Authenticated"
unique_id: router_authenticated
state: >
{{ states('input_text.router_token') not in ['unknown', '', 'unavailable'] }}
icon: >
{% if states('input_text.router_token') not in ['unknown', '', 'unavailable'] %}
mdi:check-circle
{% else %}
mdi:close-circle
{% endif %}
- name: "Internet Connectivity"
unique_id: internet_connectivity
device_class: connectivity
state: >
{{ states('binary_sensor.ping_google') == 'on' or
states('binary_sensor.ping_cloudflare') == 'on' }}
icon: >
{% if states('binary_sensor.ping_google') == 'on' or
states('binary_sensor.ping_cloudflare') == 'on' %}
mdi:web
{% else %}
mdi:web-off
{% endif %}
- name: "Network System Healthy"
unique_id: network_system_healthy
state: >
{{ states('binary_sensor.ping_router') == 'on' and
states('binary_sensor.router_authenticated') == 'on' and
states('sensor.system_health_score') | int(0) >= 70 }}
icon: >
{% if states('binary_sensor.ping_router') == 'on' and
states('binary_sensor.router_authenticated') == 'on' and
states('sensor.system_health_score') | int(0) >= 70 %}
mdi:check-circle-outline
{% else %}
mdi:alert-circle-outline
{% endif %}
# ------ PARENTAL CONTROLS ------
- name: "Any Device Blocked"
unique_id: any_device_blocked
state: >
{{ states('sensor.devices_currently_blocked') | int(0) > 0 }}
icon: >
{% if states('sensor.devices_currently_blocked') | int(0) > 0 %}
mdi:shield-check
{% else %}
mdi:shield-off-outline
{% endif %}
- name: "Bedtime Hours"
unique_id: bedtime_hours
state: >
{% set now_time = now().strftime('%H:%M') %}
{% set bedtime_start = states('input_text.bedtime_start') %}
{% set bedtime_end = states('input_text.bedtime_end') %}
{% if bedtime_start and bedtime_end %}
{% if bedtime_start > bedtime_end %}
{# Bedtime crosses midnight #}
{{ now_time >= bedtime_start or now_time <= bedtime_end }}
{% else %}
{# Normal bedtime within same day #}
{{ bedtime_start <= now_time <= bedtime_end }}
{% endif %}
{% else %}
false
{% endif %}
icon: >
{% set now_time = now().strftime('%H:%M') %}
{% set bedtime_start = states('input_text.bedtime_start') %}
{% set bedtime_end = states('input_text.bedtime_end') %}
{% if bedtime_start and bedtime_end %}
{% if bedtime_start > bedtime_end %}
{% if now_time >= bedtime_start or now_time <= bedtime_end %}
mdi:sleep
{% else %}
mdi:sleep-off
{% endif %}
{% else %}
{% if bedtime_start <= now_time <= bedtime_end %}
mdi:sleep
{% else %}
mdi:sleep-off
{% endif %}
{% endif %}
{% else %}
mdi:sleep-off
{% endif %}
- name: "Homework Hours"
unique_id: homework_hours
state: >
{% set now_time = now().strftime('%H:%M') %}
{% set homework_start = states('input_text.homework_start') %}
{% set homework_end = states('input_text.homework_end') %}
{% if homework_start and homework_end %}
{{ homework_start <= now_time <= homework_end }}
{% else %}
false
{% endif %}
icon: >
{% if this.state == 'on' %}
mdi:school
{% else %}
mdi:school-outline
{% endif %}
- name: "Emergency Mode"
unique_id: emergency_mode
state: >
{{ states('input_boolean.emergency_unblock_all') == 'on' or
states('input_boolean.bypass_mode_enabled') == 'on' }}
icon: >
{% if states('input_boolean.emergency_unblock_all') == 'on' or
states('input_boolean.bypass_mode_enabled') == 'on' %}
mdi:alert-octagon
{% else %}
mdi:shield-check-outline
{% endif %}
- name: "Strict Parental Mode"
unique_id: strict_parental_mode
state: >
{{ states('input_boolean.strict_mode_enabled') == 'on' and
states('sensor.devices_currently_blocked') | int(0) >= 4 }}
icon: >
{% if states('input_boolean.strict_mode_enabled') == 'on' and
states('sensor.devices_currently_blocked') | int(0) >= 4 %}
mdi:shield-lock
{% else %}
mdi:shield-outline
{% endif %}
# ------ DEVICE CONNECTIVITY ------
- name: "Jess Laptop 1 Device Reachable"
unique_id: jess_laptop_1_reachable
device_class: connectivity
state: >
{% if states('input_text.jess_laptop_1_testing_mac') not in ['unknown', '', 'unavailable'] %}
{{ states('input_boolean.jess_laptop_1_online') == 'on' }}
{% else %}
false
{% endif %}
icon: >
{% if states('input_text.jess_laptop_1_testing_mac') not in ['unknown', '', 'unavailable'] %}
{% if states('input_boolean.jess_laptop_1_online') == 'on' %}
mdi:laptop
{% else %}
mdi:laptop-off
{% endif %}
{% else %}
mdi:help-box
{% endif %}
- name: "Bella Devices Reachable"
unique_id: bella_devices_reachable
device_class: connectivity
state: >
{{ states('input_boolean.bella_iphone_online') == 'on' or
states('input_boolean.bella_laptop_wireless_online') == 'on' or
states('input_boolean.bella_desktop_wireless_online') == 'on' }}
icon: >
{% if states('input_boolean.bella_iphone_online') == 'on' or
states('input_boolean.bella_laptop_wireless_online') == 'on' or
states('input_boolean.bella_desktop_wireless_online') == 'on' %}
mdi:account-check
{% else %}
mdi:account-off
{% endif %}
- name: "Xander Devices Reachable"
unique_id: xander_devices_reachable
device_class: connectivity
state: >
{{ states('input_boolean.xander_desktop_wired_online') == 'on' or
states('input_boolean.xander_desktop_wireless_online') == 'on' }}
icon: >
{% if states('input_boolean.xander_desktop_wired_online') == 'on' or
states('input_boolean.xander_desktop_wireless_online') == 'on' %}
mdi:account-check
{% else %}
mdi:account-off
{% endif %}
- name: "William Devices Reachable"
unique_id: william_devices_reachable
device_class: connectivity
state: >
{{ states('input_boolean.william_desktop_wireless_online') == 'on' or
states('input_boolean.william_laptop_wireless_online') == 'on' }}
icon: >
{% if states('input_boolean.william_desktop_wireless_online') == 'on' or
states('input_boolean.william_laptop_wireless_online') == 'on' %}
mdi:account-check
{% else %}
mdi:account-off
{% endif %}
# ------ SYSTEM STATUS ------
- name: "Configuration Complete"
unique_id: configuration_complete
state: >
{% set required_macs = [
'input_text.jess_laptop_1_testing_mac',
'input_text.bella_iphone_mac',
'input_text.bella_laptop_wireless_mac',
'input_text.xander_desktop_wired_mac',
'input_text.william_desktop_wireless_mac',
'input_text.william_laptop_wireless_mac'
] %}
{% set empty_count = namespace(value=0) %}
{% for mac in required_macs %}
{% if states(mac) in ['', 'unknown', 'unavailable'] %}
{% set empty_count.value = empty_count.value + 1 %}
{% endif %}
{% endfor %}
{{ empty_count.value == 0 and states('input_text.router_password') not in ['', 'unknown', 'unavailable'] }}
icon: >
{% set required_macs = [
'input_text.jess_laptop_1_testing_mac',
'input_text.bella_iphone_mac',
'input_text.bella_laptop_wireless_mac',
'input_text.xander_desktop_wired_mac',
'input_text.william_desktop_wireless_mac',
'input_text.william_laptop_wireless_mac'
] %}
{% set empty_count = namespace(value=0) %}
{% for mac in required_macs %}
{% if states(mac) in ['', 'unknown', 'unavailable'] %}
{% set empty_count.value = empty_count.value + 1 %}
{% endif %}
{% endfor %}
{% if empty_count.value == 0 and states('input_text.router_password') not in ['', 'unknown', 'unavailable'] %}
mdi:check-circle
{% else %}
mdi:cog-outline
{% endif %}
- name: "MAC Addresses Stable"
unique_id: mac_addresses_stable
state: >
{{ states('sensor.devices_with_changed_macs') | int(0) == 0 }}
icon: >
{% if states('sensor.devices_with_changed_macs') | int(0) == 0 %}
mdi:check-network-outline
{% else %}
mdi:alert-network-outline
{% endif %}