1 """Demo platform for the vacuum component."""
3 from __future__
import annotations
5 from datetime
import datetime
23 SUPPORT_MINIMAL_SERVICES = VacuumEntityFeature.TURN_ON | VacuumEntityFeature.TURN_OFF
25 SUPPORT_BASIC_SERVICES = (
26 VacuumEntityFeature.STATE
27 | VacuumEntityFeature.START
28 | VacuumEntityFeature.STOP
29 | VacuumEntityFeature.BATTERY
32 SUPPORT_MOST_SERVICES = (
33 VacuumEntityFeature.STATE
34 | VacuumEntityFeature.START
35 | VacuumEntityFeature.STOP
36 | VacuumEntityFeature.PAUSE
37 | VacuumEntityFeature.RETURN_HOME
38 | VacuumEntityFeature.BATTERY
39 | VacuumEntityFeature.FAN_SPEED
42 SUPPORT_ALL_SERVICES = (
43 VacuumEntityFeature.STATE
44 | VacuumEntityFeature.START
45 | VacuumEntityFeature.STOP
46 | VacuumEntityFeature.PAUSE
47 | VacuumEntityFeature.STOP
48 | VacuumEntityFeature.RETURN_HOME
49 | VacuumEntityFeature.FAN_SPEED
50 | VacuumEntityFeature.SEND_COMMAND
51 | VacuumEntityFeature.LOCATE
52 | VacuumEntityFeature.STATUS
53 | VacuumEntityFeature.BATTERY
54 | VacuumEntityFeature.LOCATE
55 | VacuumEntityFeature.MAP
56 | VacuumEntityFeature.CLEAN_SPOT
59 FAN_SPEEDS = [
"min",
"medium",
"high",
"max"]
60 DEMO_VACUUM_COMPLETE =
"0_Ground_floor"
61 DEMO_VACUUM_MOST =
"1_First_floor"
62 DEMO_VACUUM_BASIC =
"2_Second_floor"
63 DEMO_VACUUM_MINIMAL =
"3_Third_floor"
64 DEMO_VACUUM_NONE =
"4_Fourth_floor"
69 config_entry: ConfigEntry,
70 async_add_entities: AddEntitiesCallback,
72 """Set up the Demo config entry."""
85 """Representation of a demo vacuum supporting states."""
87 _attr_should_poll =
False
88 _attr_translation_key =
"model_s"
90 def __init__(self, name: str, supported_features: VacuumEntityFeature) ->
None:
91 """Initialize the vacuum."""
96 self._cleaned_area: float = 0
101 """Return the current state of the vacuum."""
106 """Return the current battery level of the vacuum."""
111 """Return the current fan speed of the vacuum."""
116 """Return the list of supported fan speeds."""
121 """Return device state attributes."""
122 return {ATTR_CLEANED_AREA: round(self._cleaned_area, 2)}
125 """Start or resume the cleaning task."""
126 if self.
_state_state != STATE_CLEANING:
127 self.
_state_state = STATE_CLEANING
128 self._cleaned_area += 1.32
133 """Pause the cleaning task."""
134 if self.
_state_state == STATE_CLEANING:
135 self.
_state_state = STATE_PAUSED
138 def stop(self, **kwargs: Any) ->
None:
139 """Stop the cleaning task, do not return to dock."""
140 self.
_state_state = STATE_IDLE
144 """Return dock to charging base."""
145 self.
_state_state = STATE_RETURNING
151 """Perform a spot clean-up."""
152 self.
_state_state = STATE_CLEANING
153 self._cleaned_area += 1.32
158 """Set the vacuum's fan speed."""
164 """Locate the vacuum's position."""
165 await self.
hasshass.services.async_call(
167 "persistent_notification",
168 service_data={
"message":
"I'm here!",
"title":
"Locate request"},
170 self.
_state_state = STATE_IDLE
174 """Locate the vacuum's position."""
175 self.
_state_state = STATE_CLEANING
181 params: dict[str, Any] | list[Any] |
None =
None,
184 """Send a command to the vacuum."""
185 self.
_state_state = STATE_IDLE
189 self.
_state_state = STATE_DOCKED
list[str] fan_speed_list(self)
None async_locate(self, **Any kwargs)
None set_fan_speed(self, str fan_speed, **Any kwargs)
None stop(self, **Any kwargs)
dict[str, Any] extra_state_attributes(self)
None clean_spot(self, **Any kwargs)
None return_to_base(self, **Any kwargs)
None __set_state_to_dock(self, datetime _)
None async_send_command(self, str command, dict[str, Any]|list[Any]|None params=None, **Any kwargs)
None async_clean_spot(self, **Any kwargs)
None __init__(self, str name, VacuumEntityFeature supported_features)
list[str] fan_speed_list(self)
None async_write_ha_state(self)
None schedule_update_ha_state(self, bool force_refresh=False)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)