1 """Provides time enties for Home Connect."""
3 from datetime
import time
6 from homeconnect.api
import HomeConnectError
13 from .
import HomeConnectConfigEntry, get_dict_from_home_connect_error
17 SVE_TRANSLATION_PLACEHOLDER_ENTITY_ID,
18 SVE_TRANSLATION_PLACEHOLDER_SETTING_KEY,
19 SVE_TRANSLATION_PLACEHOLDER_VALUE,
21 from .entity
import HomeConnectEntity
23 _LOGGER = logging.getLogger(__name__)
28 key=
"BSH.Common.Setting.AlarmClock",
29 translation_key=
"alarm_clock",
36 entry: HomeConnectConfigEntry,
37 async_add_entities: AddEntitiesCallback,
39 """Set up the Home Connect switch."""
42 """Get a list of entities."""
45 for description
in TIME_ENTITIES
46 for device
in entry.runtime_data.devices
47 if description.key
in device.appliance.status
54 """Convert seconds to a time object."""
55 minutes, sec = divmod(seconds, 60)
56 hours, minutes = divmod(minutes, 60)
57 return time(hour=hours, minute=minutes, second=sec)
61 """Convert a time object to seconds."""
62 return t.hour * 3600 + t.minute * 60 + t.second
66 """Time setting class for Home Connect."""
69 """Set the native value of the entity."""
71 "Tried to set value %s to %s for %s",
77 await self.
hasshass.async_add_executor_job(
78 self.
devicedevice.appliance.set_setting,
82 except HomeConnectError
as err:
84 translation_domain=DOMAIN,
85 translation_key=
"set_setting",
86 translation_placeholders={
88 SVE_TRANSLATION_PLACEHOLDER_ENTITY_ID: self.
entity_identity_id,
89 SVE_TRANSLATION_PLACEHOLDER_SETTING_KEY: self.
bsh_keybsh_key,
90 SVE_TRANSLATION_PLACEHOLDER_VALUE:
str(value),
95 """Update the Time setting status."""
96 data = self.
devicedevice.appliance.status.get(self.
bsh_keybsh_key)
98 _LOGGER.error(
"No value for %s", self.
bsh_keybsh_key)
101 seconds = data.get(ATTR_VALUE,
None)
102 if seconds
is not None:
None async_set_value(self, time value)
list[BaseAprilaireSensor] get_entities(type[BaseAprilaireSensor] entity_class, AprilaireCoordinator coordinator, str unique_id, tuple[AprilaireSensorDescription,...] descriptions)
int time_to_seconds(time t)
time seconds_to_time(int seconds)
None async_setup_entry(HomeAssistant hass, HomeConnectConfigEntry entry, AddEntitiesCallback async_add_entities)
dict[str, Any] get_dict_from_home_connect_error(api.HomeConnectError err)
bool time(HomeAssistant hass, dt_time|str|None before=None, dt_time|str|None after=None, str|Container[str]|None weekday=None)