From 25d44e8d373130ce31e09a8cf26b50e592ddc0d6 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Tue, 11 Nov 2025 11:20:27 +0100 Subject: [PATCH] Enhance compressor phase with state translations in ViCare integration (#156238) --- homeassistant/components/vicare/sensor.py | 3 ++- homeassistant/components/vicare/strings.json | 13 ++++++++++++- homeassistant/components/vicare/utils.py | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/vicare/sensor.py b/homeassistant/components/vicare/sensor.py index 82764f88019f..ca204ff47a58 100644 --- a/homeassistant/components/vicare/sensor.py +++ b/homeassistant/components/vicare/sensor.py @@ -58,6 +58,7 @@ from .utils import ( get_compressors, get_device_serial, is_supported, + normalize_state, ) _LOGGER = logging.getLogger(__name__) @@ -1086,7 +1087,7 @@ COMPRESSOR_SENSORS: tuple[ViCareSensorEntityDescription, ...] = ( ViCareSensorEntityDescription( key="compressor_phase", translation_key="compressor_phase", - value_getter=lambda api: api.getPhase(), + value_getter=lambda api: normalize_state(api.getPhase()), entity_category=EntityCategory.DIAGNOSTIC, ), ) diff --git a/homeassistant/components/vicare/strings.json b/homeassistant/components/vicare/strings.json index d90adaa7fb53..17eed6fae984 100644 --- a/homeassistant/components/vicare/strings.json +++ b/homeassistant/components/vicare/strings.json @@ -213,7 +213,18 @@ "name": "Compressor hours load class 5" }, "compressor_phase": { - "name": "Compressor phase" + "name": "Compressor phase", + "state": { + "cooling": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::cooling%]", + "defrost": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::defrosting%]", + "heating": "[%key:component::climate::entity_component::_::state_attributes::hvac_action::state::heating%]", + "off": "[%key:common::state::off%]", + "passive_defrost": "Passive defrosting", + "pause": "[%key:common::state::idle%]", + "preparing": "Preparing", + "preparing_defrost": "Preparing defrost", + "ready": "[%key:common::state::idle%]" + } }, "compressor_starts": { "name": "Compressor starts" diff --git a/homeassistant/components/vicare/utils.py b/homeassistant/components/vicare/utils.py index ef018a60f161..4d831cf625a1 100644 --- a/homeassistant/components/vicare/utils.py +++ b/homeassistant/components/vicare/utils.py @@ -133,3 +133,8 @@ def get_compressors(device: PyViCareDevice) -> list[PyViCareHeatingDeviceCompone def filter_state(state: str) -> str | None: """Return the state if not 'nothing' or 'unknown'.""" return None if state in ("nothing", "unknown") else state + + +def normalize_state(state: str) -> str: + """Return the state with underscores instead of hyphens.""" + return state.replace("-", "_")