various tidyups and esphome adds

This commit is contained in:
root
2026-02-23 21:01:07 +13:00
parent 83e4040b84
commit 61b0c64a1e
28 changed files with 4052 additions and 3808 deletions
@@ -1,120 +0,0 @@
# ------------------------------
# TIMER HELPER (define in YAML so it definitely exists)
# ------------------------------
timer:
master_bedroom_climate_timer:
name: Master Bedroom Climate Timer
duration: "00:00:00"
# ------------------------------
# DROPDOWN (sleep timer)
# ------------------------------
input_select:
master_bedroom_climate_timer_duration:
name: Master Bedroom Aircon Sleep
options:
- "1 hour"
- "2 hours"
- "3 hours"
- "6 hours"
- "Cancel timer"
initial: "Cancel timer"
icon: mdi:timer-outline
# ------------------------------
# LIVE REMAINING (updates immediately on selection, and every minute)
# ------------------------------
template:
- trigger:
# Update once per minute (suits hh:mm display)
- platform: time_pattern
minutes: "/1"
# Update when timer STATE changes (idle/active/paused)
- platform: state
entity_id: timer.master_bedroom_climate_timer
# Update immediately when user changes the dropdown
- platform: state
entity_id: input_select.master_bedroom_climate_timer_duration
sensor:
- name: "Master Bedroom Climate Timer Remaining"
unique_id: master_bedroom_climate_timer_remaining
icon: mdi:timer
state: >-
{% set st = states('timer.master_bedroom_climate_timer') | lower %}
{% if st == 'idle' %}
0:00
{% else %}
{% set fa = state_attr('timer.master_bedroom_climate_timer', 'finishes_at') %}
{% if fa %}
{% set end = as_datetime(fa) %}
{% set sec = (end - now()).total_seconds() | int(0) %}
{% if sec < 0 %}{% set sec = 0 %}{% endif %}
{% set hh = (sec // 3600) | int %}
{% set mm = ((sec % 3600) // 60) | int %}
{{ hh }}:{{ '%02d' | format(mm) }}
{% else %}
0:00
{% endif %}
{% endif %}
# ------------------------------
# AUTOMATION: start/cancel timer when dropdown changes
# ------------------------------
automation:
- alias: "Start or Cancel Master Bedroom Climate Timer"
mode: restart
trigger:
- platform: state
entity_id: input_select.master_bedroom_climate_timer_duration
variables:
opt: "{{ states('input_select.master_bedroom_climate_timer_duration') }}"
dur_map:
"1 hour": "01:00:00"
"2 hours": "02:00:00"
"3 hours": "03:00:00"
"6 hours": "06:00:00"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ opt in dur_map }}"
sequence:
- service: timer.cancel
target:
entity_id: timer.master_bedroom_climate_timer
- delay: "00:00:01"
- service: timer.start
target:
entity_id: timer.master_bedroom_climate_timer
data:
duration: "{{ dur_map[opt] }}"
- conditions:
- condition: state
entity_id: input_select.master_bedroom_climate_timer_duration
state: "Cancel timer"
sequence:
- service: timer.cancel
target:
entity_id: timer.master_bedroom_climate_timer
- alias: "Turn Off Master Bedroom Climate on Timer Completion"
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.master_bedroom_climate_timer
action:
- service: climate.turn_off
target:
entity_id: climate.master_bedroom
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_climate_timer_duration
data:
option: "Cancel timer"
@@ -1,24 +0,0 @@
automation:
# Automation to turn on the heat pump at 9pm in the master bedroom (if switched on with the helper)
- id: master_bedroom_offpeak_dehumidify
alias: Master Bedroom Off-Peak Dehumidify
mode: single
triggers:
- trigger: time
at: "21:00:00"
conditions:
- condition: state
entity_id: input_boolean.master_bedroom_offpeak_dehumidify
state: "on"
actions:
- action: climate.set_hvac_mode
target:
entity_id: climate.master_bedroom
data:
hvac_mode: "heat_cool"
- wait_for_trigger:
- trigger: time
at: "00:00:00"
- action: climate.turn_off
target:
entity_id: climate.master_bedroom
@@ -1,85 +0,0 @@
input_select:
heat_pump_temperature_threshold:
name: Master Bedroom Night Cycle Temperature Min
options:
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
initial: "20"
icon: mdi:thermometer
input_boolean:
heat_pump_automation:
name: Enable Heat Pump Master Bedroom Night Cycling
initial: off
automation:
- alias: "Master Bedroom Heat Pump Night Cycling"
description: "Turns the climate.master_bedroom to 'cool' for 15 minutes every hour if temperature is below the selected threshold."
trigger:
- platform: time_pattern # Use time_pattern to run the automation on a recurring schedule.
minutes: "/30" # The "0" means on the hour or "/15" means every 15 minutes.
condition:
# Ensure the automation is enabled
- condition: state
entity_id: input_boolean.heat_pump_automation
state: "on"
# Check that the current temperature is above the selected threshold
- condition: template
value_template: >
{{ states('sensor.master_bedroom_environment_zth01_temperature_2') | float > states('input_select.heat_pump_temperature_threshold') | float }}
# Actions: Define the steps of the automation.
action:
# Action 1: Turn on the heat pump by setting HVAC mode to "cool".
- service: climate.set_hvac_mode
target:
entity_id: climate.master_bedroom
data:
hvac_mode: cool
# Action 2: Keep the heat pump on for x minutes.
- delay: "00:10:00"
# Action 3: Turn off the heat pump.
# Some integrations do not support hvac_mode: off via climate.set_hvac_mode,
# so we use the dedicated climate.turn_off service.
- service: climate.turn_off
target:
entity_id: climate.master_bedroom
mode: single # Ensures only one instance of this automation runs at a time.
# always switch off the automation at 5am
- alias: "Disable Heat Pump Automation at 5AM"
description: "Automatically turns off the heat pump automation (input_boolean.heat_pump_automation) at 5 AM."
trigger:
- platform: time
at: "04:59:00"
action:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.heat_pump_automation
mode: single
# ensure the heat pump is off at 5am if not already
- alias: "Ensure Heat Pump Off at 5 AM"
trigger:
- platform: time
at: "05:00:00"
action:
- service: climate.turn_off
target:
entity_id: climate.master_bedroom
mode: single
# ensure the automation is off on a HA reboot
- alias: "Ensure Heat Pump Automation is Off on Startup"
description: "Turns off the heat pump automation (input_boolean.heat_pump_automation) when Home Assistant starts."
trigger:
- platform: homeassistant
event: start
action:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.heat_pump_automation
mode: single
+10 -2
View File
@@ -35,6 +35,15 @@ sensor:
#unit_prefix: k
round: 0
- platform: filter
name: "32A EV Charger Power 1m Avg"
unique_id: ev_charger_32a_power_1m_avg
entity_id: sensor.main_house_3_phase_power_monitor_ev_wallcharger_power
filters:
- filter: time_simple_moving_average
window_size: "00:01"
precision: 3
input_select:
leaf_ev_charging_mode:
icon: mdi:ev-plug-type1
@@ -65,7 +74,6 @@ automation:
template:
- trigger:
# Update at least every 10 seconds (and also on HA start)
- platform: time_pattern
seconds: "/10"
- platform: homeassistant
@@ -75,7 +83,7 @@ template:
unique_id: ev_charger_32a_charging
icon: mdi:car-electric
state: >-
{{ (states('sensor.32a_ev_wallcharger_power') | float(0)) > 0.1 }}
{{ states('sensor.32a_ev_charger_power_1m_avg') | float(0) > 0.1 }}
delay_on:
seconds: 60
delay_off:
-309
View File
@@ -1,309 +0,0 @@
##########################################################################################
# heat_pump_helpers.yaml
#
# Panasonic Comfort Cloud (panasonic_cc) helpers for Heat/Cool control + presets.
#
# Purpose:
# - Provide "optimistic" UI feedback for cloud/slow mode changes
# - Provide one-tap scripts for Off/Heat/Cool/Dehumid
# - Provide a 3-step "Profile" cycler (Normal/Boost/Quiet) using preset_mode:
# * preset_mode: boost -> Powerful ON (we label this "Boost")
# * preset_mode: eco -> Quiet ON (we label this "Quiet")
# * preset_mode: none -> Powerful OFF + Quiet OFF (we label this "Normal")
#
# Notes:
# - Your climate entity supports preset_modes: [none, eco, boost]
# - The switch.lounge_ai_eco entity appears to be read-only (cannot be controlled),
# so "Eco" and "Eco/Quiet" profiles have been removed.
# - When turning the heat pump OFF, we also force preset_mode to "none" so that
# Boost/Quiet are cleared.
##########################################################################################
input_select:
# Used by your dashboard buttons to "light up" instantly (optimistic state).
# When set to something other than "none", the UI can treat that as "pending".
master_bedroom_hvac_requested_mode:
name: Master Bedroom HVAC Requested Mode
options:
- "none"
- "off"
- "heat"
- "cool"
- "dry"
initial: "none"
# Heat pump profile selector shown on the dashboard and cycled with one tap.
master_bedroom_heat_pump_profile:
name: Master Bedroom Heat Pump Profile
options:
- Normal
- Boost
- Quiet
initial: Normal
script:
########################################################################################
# One-tap HVAC mode scripts
# These set the optimistic helper first, then call the real climate services.
#
# IMPORTANT:
# - Off also clears Boost/Quiet by forcing preset_mode to "none".
########################################################################################
master_bedroom_hvac_off:
alias: Master Bedroom HVAC - Off
mode: restart
sequence:
# Optimistic UI: show "Off" immediately
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_hvac_requested_mode
data:
option: "off"
# Turn the unit off (more reliable than set_hvac_mode off on many cloud integrations)
- service: climate.turn_off
target:
entity_id: climate.master_bedroom
# Clear Panasonic preset flags: none = Boost OFF + Quiet OFF
- service: climate.set_preset_mode
target:
entity_id: climate.master_bedroom
data:
preset_mode: "none"
master_bedroom_hvac_heat:
alias: Master Bedroom HVAC - Heat
mode: restart
sequence:
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_hvac_requested_mode
data:
option: "heat"
- service: climate.turn_on
target:
entity_id: climate.master_bedroom
- service: climate.set_hvac_mode
target:
entity_id: climate.master_bedroom
data:
hvac_mode: "heat"
master_bedroom_hvac_cool:
alias: Master Bedroom HVAC - Cool
mode: restart
sequence:
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_hvac_requested_mode
data:
option: "cool"
- service: climate.turn_on
target:
entity_id: climate.master_bedroom
- service: climate.set_hvac_mode
target:
entity_id: climate.master_bedroom
data:
hvac_mode: "cool"
master_bedroom_hvac_dry:
alias: Master Bedroom HVAC - Dehumid
mode: restart
sequence:
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_hvac_requested_mode
data:
option: "dry"
- service: climate.turn_on
target:
entity_id: climate.master_bedroom
- service: climate.set_hvac_mode
target:
entity_id: climate.master_bedroom
data:
hvac_mode: "dry"
########################################################################################
# Profile logic: Apply + Cycle
#
# Profile definitions (Panasonic CC / panasonic_cc):
# - Normal -> preset_mode none (Boost OFF, Quiet OFF)
# - Boost -> preset_mode boost (Powerful ON)
# - Quiet -> preset_mode eco (Quiet ON)
#
# The profile selector is kept in-sync with the actual preset_mode via automation.
########################################################################################
master_bedroom_heat_pump_profile_apply:
alias: Master Bedroom Heat Pump - Apply Profile
mode: restart
fields:
profile:
description: Profile name (Normal, Boost, Quiet)
example: Normal
sequence:
- variables:
p: "{{ profile | default(states('input_select.master_bedroom_heat_pump_profile')) }}"
preset_for_profile: >-
{% if p == 'Normal' %}none
{% elif p == 'Boost' %}boost
{% elif p == 'Quiet' %}eco
{% else %}none
{% endif %}
# Optional: ensure the unit is on when applying a profile.
# Comment out if you want profile selection while the unit is off.
- service: climate.turn_on
target:
entity_id: climate.master_bedroom
# Set preset explicitly every time so Boost/Quiet are mutually exclusive
- service: climate.set_preset_mode
target:
entity_id: climate.master_bedroom
data:
preset_mode: "{{ preset_for_profile }}"
master_bedroom_heat_pump_profile_next:
alias: Master Bedroom Heat Pump - Next Profile
mode: restart
sequence:
- variables:
cur: "{{ states('input_select.master_bedroom_heat_pump_profile') }}"
nxt: >-
{% if cur == 'Normal' %}Boost
{% elif cur == 'Boost' %}Quiet
{% else %}Normal
{% endif %}
# Store the new selection (UI)
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_heat_pump_profile
data:
option: "{{ nxt }}"
# Apply it to the heat pump
- service: script.turn_on
target:
entity_id: script.master_bedroom_heat_pump_profile_apply
data:
variables:
profile: "{{ nxt }}"
automation:
########################################################################################
# Clear "requested mode" once the climate entity catches up, so the UI reflects reality.
# This prevents two mode buttons appearing lit due to stale cloud attributes.
########################################################################################
- id: master_bedroom_hvac_clear_requested_mode
alias: Master Bedroom HVAC - Clear Requested Mode
mode: restart
trigger:
- platform: state
entity_id: climate.master_bedroom
- platform: state
entity_id: input_select.master_bedroom_hvac_requested_mode
to:
- "off"
- "heat"
- "cool"
- "dry"
condition:
- condition: template
value_template: >
{{ states('input_select.master_bedroom_hvac_requested_mode') != 'none' }}
action:
# Small delay to allow the cloud integration to reflect the change
- delay: "00:00:03"
- choose:
- conditions:
- condition: template
value_template: >
{% set req = states('input_select.master_bedroom_hvac_requested_mode') %}
{% set mode = states('climate.master_bedroom') %}
{% set action = (state_attr('climate.master_bedroom','hvac_action') or '') %}
{{ (req == 'off' and (mode == 'off' or action == 'off'))
or (req in ['heat','cool','dry'] and mode == req) }}
sequence:
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_hvac_requested_mode
data:
option: "none"
default:
# Failsafe: if the cloud entity is slow or ambiguous, clear after a while anyway
- delay: "00:00:25"
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_hvac_requested_mode
data:
option: "none"
########################################################################################
# Sync the Profile selector from actual device preset_mode (including changes made in
# the Panasonic app). This keeps the UI truthful.
#
# Mapping:
# - preset boost -> Boost
# - preset eco -> Quiet
# - preset none -> Normal
########################################################################################
- id: master_bedroom_heat_pump_profile_sync_from_entities
alias: Master Bedroom Heat Pump - Sync Profile From Entities
mode: restart
trigger:
- platform: state
entity_id: climate.master_bedroom
action:
- delay: "00:00:02"
- variables:
preset: "{{ state_attr('climate.master_bedroom', 'preset_mode') or 'none' }}"
new_profile: >-
{% if preset == 'boost' %}
Boost
{% elif preset == 'eco' %}
Quiet
{% else %}
Normal
{% endif %}
- choose:
- conditions:
- condition: template
value_template: "{{ states('input_select.master_bedroom_heat_pump_profile') != new_profile }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.master_bedroom_heat_pump_profile
data:
option: "{{ new_profile }}"
template:
- sensor:
- name: Master Bedroom Heat Pump Profile Tile
unique_id: master_bedroom_heat_pump_profile_tile
state: "{{ states('input_select.master_bedroom_heat_pump_profile') }}"
icon: >
{% set p = states('input_select.master_bedroom_heat_pump_profile') %}
{% if p == 'Boost' %}
mdi:rocket-launch
{% elif p == 'Quiet' %}
mdi:leaf
{% else %}
mdi:gauge
{% endif %}
@@ -1,76 +0,0 @@
input_number:
master_bedroom_setpoint_ui:
name: Master Bedroom Setpoint UI
min: 10
max: 30
step: 0.5
mode: box
unit_of_measurement: "°C"
icon: mdi:thermometer
script:
master_bedroom_setpoint_sync_from_climate:
alias: Master Bedroom Setpoint Sync From Climate
mode: restart
sequence:
- variables:
sp: "{{ state_attr('climate.master_bedroom', 'temperature') | float(0) }}"
- service: input_number.set_value
target:
entity_id: input_number.master_bedroom_setpoint_ui
data:
value: "{{ sp }}"
master_bedroom_setpoint_adjust:
alias: Master Bedroom Setpoint Adjust
mode: queued
fields:
step:
description: "Step in degrees C, e.g. -0.5 or 0.5"
example: -0.5
sequence:
# ─────────────────────────────
# GUARD: only block when climate is OFF/unavailable/unknown
# (Do NOT use hvac_action == idle - Panasonic cloud often reports idle)
# ─────────────────────────────
- condition: template
value_template: >
{% set s = states('climate.master_bedroom') | lower %}
{{ s not in ['off', 'unavailable', 'unknown', 'none', ''] }}
# ─────────────────────────────
# Compute new setpoint
# Prefer UI helper if valid, otherwise use climate temp
# ─────────────────────────────
- variables:
cur_ui: "{{ states('input_number.master_bedroom_setpoint_ui') | float(0) }}"
cur_cl: "{{ state_attr('climate.master_bedroom', 'temperature') | float(0) }}"
cur: "{{ cur_ui if cur_ui > 0 else cur_cl }}"
raw: "{{ cur + (step | float(0)) }}"
new: "{{ [30, [10, raw] | max] | min | round(1) }}"
# Update UI immediately
- service: input_number.set_value
target:
entity_id: input_number.master_bedroom_setpoint_ui
data:
value: "{{ new }}"
# Send to climate (cloud may lag)
- service: climate.set_temperature
target:
entity_id: climate.master_bedroom
data:
temperature: "{{ new }}"
automation:
- id: master_bedroom_setpoint_sync
alias: Master Bedroom Setpoint Sync
mode: restart
trigger:
- platform: state
entity_id: climate.master_bedroom
- platform: homeassistant
event: start
action:
- service: script.master_bedroom_setpoint_sync_from_climate
@@ -10,7 +10,8 @@ input_number:
max: 30
step: 0.5
mode: box
unit_of_measurement: "C"
unit_of_measurement: ""
initial: 21.5
###############################################################################
# AUTOMATIONS
@@ -22,12 +23,12 @@ automation:
mode: queued
trigger:
- platform: state
entity_id: sensor.lounge_inside_temperature
entity_id: sensor.lounge_environment_lounge_environment_temperature
action:
- service: mqtt.publish
data:
topic: "hasp/openhasp_1/command/p1b1.text"
payload: "{{ states('sensor.lounge_inside_temperature')|float(0)|round(1) }} C"
payload: "{{ states('sensor.lounge_environment_lounge_environment_temperature')|float(0)|round(1) }} °C"
- id: hasp_setpoint_to_btn_text
alias: "HASP: update setpoint (p1b2.text)"
@@ -39,7 +40,9 @@ automation:
- service: mqtt.publish
data:
topic: "hasp/openhasp_1/command/p1b2.text"
payload: "Set: {{ states('input_number.lounge_setpoint')|float(0)|round(1) }} C"
payload: "Set: {{ states('input_number.lounge_setpoint')|float(0)|round(1) }} °C"
qos: 1
retain: true
- id: hasp_heater_status_to_btn_text
alias: "HASP: update heater status (p1b5.text)"
@@ -90,18 +93,24 @@ automation:
# --- PUSH INITIAL VALUES ON HA START / PANEL ONLINE -----------------------
- id: hasp_push_on_ha_start
alias: "HASP: push texts on HA start"
mode: queued
trigger:
- platform: homeassistant
event: start
action:
- service: script.hasp_push_all_texts
- id: hasp_push_on_plate_birth
alias: "HASP: push texts on panel birth"
- id: hasp_push_on_panel_online
alias: "HASP: push texts when panel goes online"
mode: queued
trigger:
- platform: mqtt
topic: "hasp/openhasp_1/state"
topic: "hasp/openhasp_1/status"
condition:
- condition: template
value_template: "{{ trigger.payload == 'online' }}"
action:
- delay: "00:00:05"
- service: script.hasp_push_all_texts
###############################################################################
@@ -115,11 +124,15 @@ script:
- service: mqtt.publish
data:
topic: "hasp/openhasp_1/command/p1b1.text"
payload: "{{ states('sensor.lounge_inside_temperature')|float(0)|round(1) }} C"
payload: "{{ states('sensor.lounge_environment_lounge_environment_temperature')|float(0)|round(1) }} °C"
- service: mqtt.publish
data:
topic: "hasp/openhasp_1/command/p1b2.text"
payload: "Set: {{ states('input_number.lounge_setpoint')|float(0)|round(1) }} C"
payload: "Set: {{ states('input_number.lounge_setpoint')|float(0)|round(1) }} °C"
qos: 1
retain: true
- service: mqtt.publish
data:
topic: "hasp/openhasp_1/command/p1b5.text"