Files
HomeAssistantVS/custom_components/intelligent_heating_pilot/infrastructure/adapters/utils.py
T
2026-07-08 10:43:39 -04:00

24 lines
617 B
Python

"""Shared utility functions for infrastructure adapters."""
from __future__ import annotations
from typing import cast
from homeassistant.core import HomeAssistant
def get_entity_name(hass: HomeAssistant, entity_id: str) -> str:
"""Get the friendly name of an entity, falling back to entity_id.
Args:
hass: Home Assistant instance
entity_id: Entity ID to get name for
Returns:
Friendly name or entity_id if not found
"""
state = hass.states.get(entity_id)
if state:
return cast(str, state.attributes.get("friendly_name", entity_id))
return entity_id