various tidyups and esphome adds

This commit is contained in:
root
2026-02-16 22:13:42 +13:00
parent d7884770fe
commit 83e4040b84
16 changed files with 2251 additions and 113 deletions
+309
View File
@@ -0,0 +1,309 @@
##########################################################################################
# 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 %}