Add translation keys to ViCare integration (#104425)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
1cfbdd6a5d
commit
17cef8940f
7 changed files with 385 additions and 134 deletions
|
@ -5,6 +5,9 @@ from contextlib import suppress
|
|||
import logging
|
||||
from typing import Any
|
||||
|
||||
from PyViCare.PyViCareDevice import Device as PyViCareDevice
|
||||
from PyViCare.PyViCareDeviceConfig import PyViCareDeviceConfig
|
||||
from PyViCare.PyViCareHeatingDevice import HeatingCircuit as PyViCareHeatingCircuit
|
||||
from PyViCare.PyViCareUtils import (
|
||||
PyViCareCommandError,
|
||||
PyViCareInvalidDataError,
|
||||
|
@ -107,18 +110,15 @@ async def async_setup_entry(
|
|||
"""Set up the ViCare climate platform."""
|
||||
entities = []
|
||||
api = hass.data[DOMAIN][config_entry.entry_id][VICARE_API]
|
||||
device_config = hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG]
|
||||
circuits = await hass.async_add_executor_job(_get_circuits, api)
|
||||
|
||||
for circuit in circuits:
|
||||
suffix = ""
|
||||
if len(circuits) > 1:
|
||||
suffix = f" {circuit.id}"
|
||||
|
||||
entity = ViCareClimate(
|
||||
f"Heating{suffix}",
|
||||
api,
|
||||
circuit,
|
||||
hass.data[DOMAIN][config_entry.entry_id][VICARE_DEVICE_CONFIG],
|
||||
device_config,
|
||||
"heating",
|
||||
)
|
||||
entities.append(entity)
|
||||
|
||||
|
@ -148,13 +148,19 @@ class ViCareClimate(ViCareEntity, ClimateEntity):
|
|||
_current_action: bool | None = None
|
||||
_current_mode: str | None = None
|
||||
|
||||
def __init__(self, name, api, circuit, device_config) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
api: PyViCareDevice,
|
||||
circuit: PyViCareHeatingCircuit,
|
||||
device_config: PyViCareDeviceConfig,
|
||||
translation_key: str,
|
||||
) -> None:
|
||||
"""Initialize the climate device."""
|
||||
super().__init__(device_config, api, circuit.id)
|
||||
self._attr_name = name
|
||||
self._circuit = circuit
|
||||
self._attributes: dict[str, Any] = {}
|
||||
self._current_program = None
|
||||
self._attr_translation_key = translation_key
|
||||
|
||||
def update(self) -> None:
|
||||
"""Let HA know there has been an update from the ViCare API."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue