Home Assistant Unofficial Reference 2024.12.1
date.py
Go to the documentation of this file.
1 """Support for Vallox date platform."""
2 
3 from __future__ import annotations
4 
5 from datetime import date
6 
7 from vallox_websocket_api import Vallox
8 
9 from homeassistant.components.date import DateEntity
10 from homeassistant.config_entries import ConfigEntry
11 from homeassistant.const import EntityCategory
12 from homeassistant.core import HomeAssistant
13 from homeassistant.helpers.entity_platform import AddEntitiesCallback
14 
15 from .const import DOMAIN
16 from .coordinator import ValloxDataUpdateCoordinator
17 from .entity import ValloxEntity
18 
19 
21  """Representation of a Vallox filter change date entity."""
22 
23  _attr_entity_category = EntityCategory.CONFIG
24  _attr_translation_key = "filter_change_date"
25 
26  def __init__(
27  self,
28  name: str,
29  coordinator: ValloxDataUpdateCoordinator,
30  client: Vallox,
31  ) -> None:
32  """Initialize the Vallox date."""
33  super().__init__(name, coordinator)
34 
35  self._attr_unique_id_attr_unique_id = f"{self._device_uuid}-filter_change_date"
36  self._client_client = client
37 
38  @property
39  def native_value(self) -> date | None:
40  """Return the latest value."""
41 
42  return self.coordinator.data.filter_change_date
43 
44  async def async_set_value(self, value: date) -> None:
45  """Change the date."""
46 
47  await self._client_client.set_filter_change_date(value)
48  await self.coordinator.async_request_refresh()
49 
50 
52  hass: HomeAssistant,
53  entry: ConfigEntry,
54  async_add_entities: AddEntitiesCallback,
55 ) -> None:
56  """Set up Vallox filter change date entity."""
57 
58  data = hass.data[DOMAIN][entry.entry_id]
59 
61  [
63  data["name"], data["coordinator"], data["client"]
64  )
65  ]
66  )
None __init__(self, str name, ValloxDataUpdateCoordinator coordinator, Vallox client)
Definition: date.py:31
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: date.py:55