1 """Demo platform that offers a fake climate device."""
3 from __future__
import annotations
29 config_entry: ConfigEntry,
30 async_add_entities: AddEntitiesCallback,
32 """Set up the demo climate platform."""
36 unique_id=
"climate_1",
37 device_name=
"HeatPump",
38 target_temperature=68,
39 unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
41 current_temperature=77,
44 current_humidity=
None,
46 swing_horizontal_mode=
None,
47 hvac_mode=HVACMode.HEAT,
48 hvac_action=HVACAction.HEATING,
49 target_temp_high=
None,
51 hvac_modes=[HVACMode.HEAT, HVACMode.OFF],
54 unique_id=
"climate_2",
56 target_temperature=21,
57 unit_of_measurement=UnitOfTemperature.CELSIUS,
59 current_temperature=22,
62 current_humidity=54.2,
64 swing_horizontal_mode=
"auto",
65 hvac_mode=HVACMode.COOL,
66 hvac_action=HVACAction.COOLING,
67 target_temp_high=
None,
69 hvac_modes=[cls
for cls
in HVACMode
if cls != HVACMode.HEAT_COOL],
72 unique_id=
"climate_3",
74 target_temperature=
None,
75 unit_of_measurement=UnitOfTemperature.CELSIUS,
77 preset_modes=[
"home",
"eco",
"away"],
78 current_temperature=23,
81 current_humidity=
None,
83 swing_horizontal_mode=
None,
84 hvac_mode=HVACMode.HEAT_COOL,
88 hvac_modes=[cls
for cls
in HVACMode
if cls != HVACMode.HEAT],
95 """Representation of a demo climate device."""
97 _attr_has_entity_name =
True
99 _attr_should_poll =
False
100 _attr_translation_key =
"ubercool"
101 _enable_turn_on_off_backwards_compatibility =
False
107 target_temperature: float |
None,
108 unit_of_measurement: str,
110 current_temperature: float,
111 fan_mode: str |
None,
112 target_humidity: float |
None,
113 current_humidity: float |
None,
114 swing_mode: str |
None,
115 swing_horizontal_mode: str |
None,
117 hvac_action: HVACAction |
None,
118 target_temp_high: float |
None,
119 target_temp_low: float |
None,
120 hvac_modes: list[HVACMode],
121 preset_modes: list[str] |
None =
None,
123 """Initialize the climate device."""
126 if target_temperature
is not None:
128 if preset
is not None:
130 if fan_mode
is not None:
132 if target_humidity
is not None:
134 if swing_mode
is not None:
136 if swing_horizontal_mode
is not None:
138 if HVACMode.HEAT_COOL
in hvac_modes
or HVACMode.AUTO
in hvac_modes:
140 ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
143 ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
157 self.
_fan_modes_fan_modes = [
"on_low",
"on_high",
"auto_low",
"auto_high",
"off"]
164 identifiers={(DOMAIN, unique_id)},
170 """Return the unique id."""
175 """Return the unit of measurement."""
180 """Return the current temperature."""
185 """Return the temperature we try to reach."""
190 """Return the highbound target temperature we try to reach."""
195 """Return the lowbound target temperature we try to reach."""
200 """Return the current humidity."""
205 """Return the humidity we try to reach."""
210 """Return current operation ie. heat, cool, idle."""
215 """Return hvac target hvac state."""
220 """Return the list of available operation modes."""
225 """Return preset mode."""
230 """Return preset modes."""
235 """Return the fan setting."""
240 """Return the list of available fan modes."""
245 """Return the swing setting."""
250 """List of available swing modes."""
255 """Return the swing setting."""
260 """List of available swing modes."""
264 """Set new target temperatures."""
265 if kwargs.get(ATTR_TEMPERATURE)
is not None:
268 kwargs.get(ATTR_TARGET_TEMP_HIGH)
is not None
269 and kwargs.get(ATTR_TARGET_TEMP_LOW)
is not None
273 if (hvac_mode := kwargs.get(ATTR_HVAC_MODE))
is not None:
278 """Set new humidity level."""
283 """Set new swing mode."""
288 """Set new swing mode."""
293 """Set new fan mode."""
298 """Set new operation mode."""
303 """Update preset_mode on."""
304 self.
_preset_preset = preset_mode
float|None target_temperature_high(self)
float|None target_humidity(self)
list[str]|None preset_modes(self)
str|None swing_horizontal_mode(self)
str|None preset_mode(self)
HVACAction|None hvac_action(self)
None __init__(self, str unique_id, str device_name, float|None target_temperature, str unit_of_measurement, str|None preset, float current_temperature, str|None fan_mode, float|None target_humidity, float|None current_humidity, str|None swing_mode, str|None swing_horizontal_mode, HVACMode hvac_mode, HVACAction|None hvac_action, float|None target_temp_high, float|None target_temp_low, list[HVACMode] hvac_modes, list[str]|None preset_modes=None)
list[str] swing_modes(self)
None async_set_humidity(self, int humidity)
None async_set_temperature(self, **Any kwargs)
float current_temperature(self)
float|None current_humidity(self)
None async_set_swing_horizontal_mode(self, str swing_horizontal_mode)
str|None swing_mode(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
_current_swing_horizontal_mode
None async_set_fan_mode(self, str fan_mode)
list[str] fan_modes(self)
list[str] swing_horizontal_modes(self)
float|None target_temperature_low(self)
None async_set_swing_mode(self, str swing_mode)
float|None target_temperature(self)
list[HVACMode] hvac_modes(self)
str temperature_unit(self)
None async_set_preset_mode(self, str preset_mode)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)