1 """Climate device for CCM15 coordinator."""
6 from ccm15
import CCM15DeviceState
27 from .const
import CONST_CMD_FAN_MAP, CONST_CMD_STATE_MAP, DOMAIN
28 from .coordinator
import CCM15Coordinator
30 _LOGGER = logging.getLogger(__name__)
35 config_entry: ConfigEntry,
36 async_add_entities: AddEntitiesCallback,
38 """Set up all climate."""
39 coordinator: CCM15Coordinator = hass.data[DOMAIN][config_entry.entry_id]
41 ac_data: CCM15DeviceState = coordinator.data
43 CCM15Climate(coordinator.get_host(), ac_index, coordinator)
44 for ac_index
in ac_data.devices
50 """Climate device for CCM15 coordinator."""
52 _attr_temperature_unit = UnitOfTemperature.CELSIUS
53 _attr_has_entity_name =
True
54 _attr_target_temperature_step = PRECISION_WHOLE
63 _attr_fan_modes = [FAN_AUTO, FAN_LOW, FAN_MEDIUM, FAN_HIGH]
64 _attr_swing_modes = [SWING_OFF, SWING_ON]
65 _attr_supported_features = (
66 ClimateEntityFeature.TARGET_TEMPERATURE
67 | ClimateEntityFeature.FAN_MODE
68 | ClimateEntityFeature.SWING_MODE
69 | ClimateEntityFeature.TURN_OFF
70 | ClimateEntityFeature.TURN_ON
73 _enable_turn_on_off_backwards_compatibility =
False
76 self, ac_host: str, ac_index: int, coordinator: CCM15Coordinator
78 """Create a climate device managed from a coordinator."""
80 self._ac_index: int = ac_index
85 (DOMAIN, f
"{ac_host}.{ac_index}"),
87 name=f
"Midea {ac_index}",
93 def data(self) -> CCM15DeviceState | None:
94 """Return device data."""
99 """Return current temperature."""
100 if (data := self.
datadatadata)
is not None:
101 return data.temperature
106 """Return target temperature."""
107 if (data := self.
datadatadata)
is not None:
108 return data.temperature_setpoint
113 """Return hvac mode."""
114 if (data := self.
datadatadata)
is not None:
116 return CONST_CMD_STATE_MAP[mode]
121 """Return fan mode."""
122 if (data := self.
datadatadata)
is not None:
124 return CONST_CMD_FAN_MAP[mode]
129 """Return swing mode."""
130 if (data := self.
datadatadata)
is not None:
131 return SWING_ON
if data.is_swing_on
else SWING_OFF
136 """Return the availability of the entity."""
137 return self.
datadatadata
is not None
141 """Return the optional state attributes."""
142 if (data := self.
datadatadata)
is not None:
143 return {
"error_code": data.error_code}
147 """Set the target temperature."""
148 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is not None:
152 """Set the hvac mode."""
156 """Set the fan mode."""
CCM15DeviceState|None data(self)
None async_set_temperature(self, **Any kwargs)
int|None target_temperature(self)
int|None current_temperature(self)
str|None swing_mode(self)
None async_set_fan_mode(self, str fan_mode)
None async_set_hvac_mode(self, HVACMode hvac_mode)
dict[str, Any] extra_state_attributes(self)
None async_turn_off(self)
None __init__(self, str ac_host, int ac_index, CCM15Coordinator coordinator)
None async_set_hvac_mode(self, ac_index, HVACMode hvac_mode)
CCM15SlaveDevice|None get_ac_data(self, int ac_index)
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)