1 """Support for Melissa Climate A/C."""
3 from __future__
import annotations
22 from .
import DATA_MELISSA
24 _LOGGER = logging.getLogger(__name__)
34 FAN_MODES = [FAN_AUTO, FAN_HIGH, FAN_MEDIUM, FAN_LOW]
40 async_add_entities: AddEntitiesCallback,
41 discovery_info: DiscoveryInfoType |
None =
None,
43 """Iterate through and add all Melissa devices."""
44 api = hass.data[DATA_MELISSA]
45 devices = (await api.async_fetch_devices()).values()
51 if device[
"type"] ==
"melissa"
58 """Representation of a Melissa Climate device."""
60 _attr_hvac_modes = OP_MODES
61 _attr_supported_features = (
62 ClimateEntityFeature.FAN_MODE
63 | ClimateEntityFeature.TARGET_TEMPERATURE
64 | ClimateEntityFeature.TURN_OFF
65 | ClimateEntityFeature.TURN_ON
67 _attr_temperature_unit = UnitOfTemperature.CELSIUS
68 _enable_turn_on_off_backwards_compatibility =
False
70 def __init__(self, api, serial_number, init_data):
71 """Initialize the climate device."""
72 self.
_name_name = init_data[
"name"]
75 self.
_data_data = init_data[
"controller_log"]
81 """Return the name of the thermostat, if any."""
82 return self.
_name_name
86 """Return the current fan mode."""
93 """Return the current temperature."""
95 return self.
_data_data[self.
_api_api.TEMP]
100 """Return the current humidity value."""
102 return self.
_data_data[self.
_api_api.HUMIDITY]
107 """Return the supported step of target temperature."""
108 return PRECISION_WHOLE
112 """Return the current operation mode."""
117 self.
_api_api.STATE_ON,
118 self.
_api_api.STATE_IDLE,
128 """List of available fan modes."""
133 """Return the temperature we try to reach."""
140 """Return the minimum supported temperature for the thermostat."""
145 """Return the maximum supported temperature for the thermostat."""
149 """Set new target temperature."""
150 temp = kwargs.get(ATTR_TEMPERATURE)
156 await self.
async_sendasync_send({self.
_api_api.FAN: melissa_fan_mode})
159 """Set operation mode."""
160 if hvac_mode == HVACMode.OFF:
166 {self.
_api_api.MODE: mode, self.
_api_api.STATE: self.
_api_api.STATE_ON}
170 """Send action to service."""
174 except AttributeError:
182 """Get latest data from Melissa."""
184 self.
_data_data = (await self.
_api_api.async_status(cached=
True))[
189 )[
"controller"][
"_relation"][
"command_log"]
191 _LOGGER.warning(
"Unable to update entity %s", self.
entity_identity_id)
194 """Translate Melissa modes to hass states."""
195 if mode == self.
_api_api.MODE_HEAT:
197 if mode == self.
_api_api.MODE_COOL:
199 if mode == self.
_api_api.MODE_DRY:
201 if mode == self.
_api_api.MODE_FAN:
202 return HVACMode.FAN_ONLY
203 _LOGGER.warning(
"Operation mode %s could not be mapped to hass", mode)
207 """Translate Melissa fan modes to hass modes."""
208 if fan == self.
_api_api.FAN_AUTO:
210 if fan == self.
_api_api.FAN_LOW:
212 if fan == self.
_api_api.FAN_MEDIUM:
214 if fan == self.
_api_api.FAN_HIGH:
216 _LOGGER.warning(
"Fan mode %s could not be mapped to hass", fan)
220 """Translate hass states to melissa modes."""
221 if mode == HVACMode.HEAT:
222 return self.
_api_api.MODE_HEAT
223 if mode == HVACMode.COOL:
224 return self.
_api_api.MODE_COOL
225 if mode == HVACMode.DRY:
226 return self.
_api_api.MODE_DRY
227 if mode == HVACMode.FAN_ONLY:
228 return self.
_api_api.MODE_FAN
229 _LOGGER.warning(
"Melissa have no setting for %s mode", mode)
233 """Translate hass fan modes to melissa modes."""
235 return self.
_api_api.FAN_AUTO
237 return self.
_api_api.FAN_LOW
238 if fan == FAN_MEDIUM:
239 return self.
_api_api.FAN_MEDIUM
241 return self.
_api_api.FAN_HIGH
242 _LOGGER.warning(
"Melissa have no setting for %s fan mode", fan)
def current_temperature(self)
def async_send(self, value)
def __init__(self, api, serial_number, init_data)
def hass_mode_to_melissa(self, mode)
def hass_fan_to_melissa(self, fan)
def current_humidity(self)
def target_temperature_step(self)
def melissa_op_to_hass(self, mode)
def target_temperature(self)
None async_set_fan_mode(self, str fan_mode)
def melissa_fan_to_hass(self, fan)
None async_set_temperature(self, **Any kwargs)
None async_set_hvac_mode(self, HVACMode hvac_mode)
IssData update(pyiss.ISS iss)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)