1 """Support for SwitchBot Air Conditioner remotes."""
5 from switchbot_api
import AirConditionerCommands
18 from .
import SwitchbotCloudData
19 from .const
import DOMAIN
20 from .entity
import SwitchBotCloudEntity
22 _SWITCHBOT_HVAC_MODES: dict[HVACMode, int] = {
23 HVACMode.HEAT_COOL: 1,
30 _DEFAULT_SWITCHBOT_HVAC_MODE = _SWITCHBOT_HVAC_MODES[HVACMode.FAN_ONLY]
32 _SWITCHBOT_FAN_MODES: dict[str, int] = {
35 FanState.FAN_MEDIUM: 3,
39 _DEFAULT_SWITCHBOT_FAN_MODE = _SWITCHBOT_FAN_MODES[FanState.FAN_AUTO]
45 async_add_entities: AddEntitiesCallback,
47 """Set up SwitchBot Cloud entry."""
48 data: SwitchbotCloudData = hass.data[DOMAIN][config.entry_id]
51 for device, coordinator
in data.devices.climates
56 """Representation of a SwitchBot air conditioner.
58 As it is an IR device, we don't know the actual state.
61 _attr_assumed_state =
True
62 _attr_supported_features = (
63 ClimateEntityFeature.FAN_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
71 _attr_fan_mode = FanState.FAN_AUTO
79 _attr_hvac_mode = HVACMode.FAN_ONLY
80 _attr_temperature_unit = UnitOfTemperature.CELSIUS
81 _attr_target_temperature = 21
83 _enable_turn_on_off_backwards_compatibility =
False
87 hvac_mode: HVACMode |
None =
None,
88 fan_mode: str |
None =
None,
89 temperature: float |
None =
None,
92 new_mode = _SWITCHBOT_HVAC_MODES.get(
93 hvac_mode
or self.
_attr_hvac_mode_attr_hvac_mode, _DEFAULT_SWITCHBOT_HVAC_MODE
95 new_fan_speed = _SWITCHBOT_FAN_MODES.get(
96 fan_mode
or self.
_attr_fan_mode_attr_fan_mode, _DEFAULT_SWITCHBOT_FAN_MODE
99 AirConditionerCommands.SET_ALL,
100 parameters=f
"{new_temperature},{new_mode},{new_fan_speed},on",
104 """Set target hvac mode."""
110 """Set target fan mode."""
116 """Set target temperature."""
117 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
None async_set_hvac_mode(self, HVACMode hvac_mode)
int _attr_target_temperature
None _do_send_command(self, HVACMode|None hvac_mode=None, str|None fan_mode=None, float|None temperature=None)
None async_set_temperature(self, **Any kwargs)
None async_set_fan_mode(self, str fan_mode)
None send_api_command(self, Commands command, str command_type="command", dict|str parameters="default")
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config, AddEntitiesCallback async_add_entities)