1 """Support for Fujitsu HVAC devices that use the Ayla Iot platform."""
5 from ayla_iot_unofficial.fujitsu_hvac
import (
32 from .
import FGLairConfigEntry
33 from .const
import DOMAIN
34 from .coordinator
import FGLairCoordinator
37 FAN_LOW: FanSpeed.LOW,
38 FAN_MEDIUM: FanSpeed.MEDIUM,
39 FAN_HIGH: FanSpeed.HIGH,
40 FAN_AUTO: FanSpeed.AUTO,
42 FUJI_TO_HA_FAN = {value: key
for key, value
in HA_TO_FUJI_FAN.items()}
45 HVACMode.OFF: OpMode.OFF,
46 HVACMode.HEAT: OpMode.HEAT,
47 HVACMode.COOL: OpMode.COOL,
48 HVACMode.HEAT_COOL: OpMode.AUTO,
49 HVACMode.DRY: OpMode.DRY,
50 HVACMode.FAN_ONLY: OpMode.FAN,
52 FUJI_TO_HA_HVAC = {value: key
for key, value
in HA_TO_FUJI_HVAC.items()}
55 SWING_OFF: SwingMode.OFF,
56 SWING_VERTICAL: SwingMode.SWING_VERTICAL,
57 SWING_HORIZONTAL: SwingMode.SWING_HORIZONTAL,
58 SWING_BOTH: SwingMode.SWING_BOTH,
60 FUJI_TO_HA_SWING = {value: key
for key, value
in HA_TO_FUJI_SWING.items()}
65 entry: FGLairConfigEntry,
66 async_add_entities: AddEntitiesCallback,
68 """Set up one Fujitsu HVAC device."""
71 for device
in entry.runtime_data.data.values()
76 """Represent a Fujitsu HVAC device."""
78 _attr_temperature_unit = UnitOfTemperature.CELSIUS
79 _attr_precision = PRECISION_HALVES
80 _attr_target_temperature_step = 0.5
81 _attr_has_entity_name =
True
84 _enable_turn_on_off_backwards_compatibility: bool =
False
86 def __init__(self, coordinator: FGLairCoordinator, device: FujitsuHVAC) ->
None:
87 """Store the representation of the device and set the static attributes."""
88 super().
__init__(coordinator, context=device.device_serial_number)
92 identifiers={(DOMAIN, device.device_serial_number)},
93 name=device.device_name,
94 manufacturer=
"Fujitsu",
95 model=device.property_values[
"model_name"],
96 serial_number=device.device_serial_number,
97 sw_version=device.property_values[
"mcu_firmware_version"],
101 ClimateEntityFeature.TARGET_TEMPERATURE
102 | ClimateEntityFeature.TURN_ON
103 | ClimateEntityFeature.TURN_OFF
105 if device.has_capability(Capability.OP_FAN):
108 if device.has_capability(Capability.SWING_HORIZONTAL)
or device.has_capability(
109 Capability.SWING_VERTICAL
116 """Return the device object from the coordinator data."""
117 return self.coordinator.data[self.coordinator_context]
121 """Return if the device is available."""
122 return super().available
and self.coordinator_context
in self.coordinator.data
126 await self.
devicedevice.async_set_fan_speed(HA_TO_FUJI_FAN[fan_mode])
131 await self.
devicedevice.async_set_op_mode(HA_TO_FUJI_HVAC[hvac_mode])
135 """Set swing mode."""
140 """Set target temperature."""
141 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
143 await self.
devicedevice.async_set_set_temp(temperature)
147 if self.coordinator_context
in self.coordinator.data:
151 for mode
in self.
devicedevice.supported_fan_speeds
152 if mode
in FUJI_TO_HA_FAN
156 FUJI_TO_HA_HVAC[mode]
157 for mode
in self.
devicedevice.supported_op_modes
158 if mode
in FUJI_TO_HA_HVAC
162 FUJI_TO_HA_SWING[mode]
163 for mode
in self.
devicedevice.supported_swing_modes
164 if mode
in FUJI_TO_HA_SWING
None async_set_temperature(self, **Any kwargs)
None _handle_coordinator_update(self)
None async_set_swing_mode(self, str swing_mode)
None __init__(self, FGLairCoordinator coordinator, FujitsuHVAC device)
_attr_current_temperature
None async_set_hvac_mode(self, HVACMode hvac_mode)
None async_set_fan_mode(self, str fan_mode)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, FGLairConfigEntry entry, AddEntitiesCallback async_add_entities)