1 """Support for Broadlink climate devices."""
3 from enum
import IntEnum
18 from .const
import DOMAIN, DOMAINS_AND_TYPES
19 from .device
import BroadlinkDevice
20 from .entity
import BroadlinkEntity
24 """Thermostat sensor modes."""
26 INNER_SENSOR_CONTROL = 0
27 OUTER_SENSOR_CONTROL = 1
28 INNER_SENSOR_CONTROL_OUTER_LIMIT = 2
33 config_entry: ConfigEntry,
34 async_add_entities: AddEntitiesCallback,
36 """Set up the Broadlink climate entities."""
37 device = hass.data[DOMAIN].devices[config_entry.entry_id]
39 if device.api.type
in DOMAINS_AND_TYPES[Platform.CLIMATE]:
44 """Representation of a Broadlink Hysen climate entity."""
46 _attr_has_entity_name =
True
47 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF, HVACMode.AUTO]
48 _attr_supported_features = (
49 ClimateEntityFeature.TARGET_TEMPERATURE
50 | ClimateEntityFeature.TURN_OFF
51 | ClimateEntityFeature.TURN_ON
53 _attr_target_temperature_step = PRECISION_HALVES
54 _attr_temperature_unit = UnitOfTemperature.CELSIUS
55 _enable_turn_on_off_backwards_compatibility =
False
57 def __init__(self, device: BroadlinkDevice) ->
None:
58 """Initialize the climate entity."""
65 """Set new target temperature."""
66 temperature = kwargs[ATTR_TEMPERATURE]
67 await self.
_device_device.async_request(self.
_device_device.api.set_temp, temperature)
74 if (sensor := data.get(
"sensor"))
is not None:
77 if data.get(
"auto_mode"):
82 if data.get(
"active"):
89 if self.
sensor_modesensor_mode
is SensorMode.OUTER_SENSOR_CONTROL:
96 """Set new target hvac mode."""
97 if hvac_mode == HVACMode.OFF:
98 await self.
_device_device.async_request(self.
_device_device.api.set_power, 0)
100 await self.
_device_device.async_request(self.
_device_device.api.set_power, 1)
101 mode = 0
if hvac_mode == HVACMode.HEAT
else 1
102 await self.
_device_device.async_request(
None _update_state(self, dict[str, Any] data)
None async_set_hvac_mode(self, HVACMode hvac_mode)
_attr_current_temperature
None __init__(self, BroadlinkDevice device)
None async_set_temperature(self, **Any kwargs)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)