mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 01:11:51 -04:00
Enhance compressor phase with state translations in ViCare integration (#156238)
This commit is contained in:
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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("-", "_")
|
||||
|
||||
Reference in New Issue
Block a user