1 """Support for the Escea Fireplace."""
3 from __future__
import annotations
5 from collections.abc
import Coroutine
9 from pescea
import Controller
27 DATA_DISCOVERY_SERVICE,
28 DISPATCH_CONTROLLER_DISCONNECTED,
29 DISPATCH_CONTROLLER_DISCOVERED,
30 DISPATCH_CONTROLLER_RECONNECTED,
31 DISPATCH_CONTROLLER_UPDATE,
37 _LOGGER = logging.getLogger(__name__)
40 Controller.Fan.FLAME_EFFECT: FAN_LOW,
41 Controller.Fan.FAN_BOOST: FAN_HIGH,
42 Controller.Fan.AUTO: FAN_AUTO,
44 _HA_FAN_TO_ESCEA = {v: k
for k, v
in _ESCEA_FAN_TO_HA.items()}
49 config_entry: ConfigEntry,
50 async_add_entities: AddEntitiesCallback,
52 """Initialize an Escea Controller."""
53 discovery_service = hass.data[DATA_DISCOVERY_SERVICE]
57 """Register the controller device."""
59 _LOGGER.debug(
"Controller UID=%s discovered", ctrl.device_uid)
65 for controller
in discovery_service.controllers.values():
69 config_entry.async_on_unload(
75 """Representation of Escea Controller."""
77 _attr_fan_modes =
list(_HA_FAN_TO_ESCEA)
78 _attr_has_entity_name =
True
80 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
81 _attr_translation_key =
"fireplace"
82 _attr_precision = PRECISION_WHOLE
83 _attr_should_poll =
False
84 _attr_supported_features = (
85 ClimateEntityFeature.TARGET_TEMPERATURE
86 | ClimateEntityFeature.FAN_MODE
87 | ClimateEntityFeature.TURN_OFF
88 | ClimateEntityFeature.TURN_ON
90 _attr_target_temperature_step = PRECISION_WHOLE
91 _attr_temperature_unit = UnitOfTemperature.CELSIUS
92 _enable_turn_on_off_backwards_compatibility =
False
94 def __init__(self, controller: Controller) ->
None:
95 """Initialise ControllerDevice."""
104 unique_id: str = controller.device_uid
107 identifiers={(DOMAIN, unique_id)},
108 manufacturer=ESCEA_MANUFACTURER,
109 name=ESCEA_FIREPLACE,
115 """Call on adding to hass.
117 Registers for connect/disconnect/update events
121 def controller_disconnected(ctrl: Controller, ex: Exception) ->
None:
122 """Disconnected from controller."""
129 self.
hasshass, DISPATCH_CONTROLLER_DISCONNECTED, controller_disconnected
134 def controller_reconnected(ctrl: Controller) ->
None:
135 """Reconnected to controller."""
142 self.
hasshass, DISPATCH_CONTROLLER_RECONNECTED, controller_reconnected
147 def controller_update(ctrl: Controller) ->
None:
148 """Handle controller data updates."""
155 self.
hasshass, DISPATCH_CONTROLLER_UPDATE, controller_update
160 def set_available(self, available: bool, ex: Exception |
None =
None) ->
None:
161 """Set availability for the controller."""
166 _LOGGER.debug(
"Reconnected controller %s ", self.
_controller_controller.device_uid)
169 "Controller %s disconnected due to exception: %s",
179 """Return current operation ie. heat, cool, idle."""
180 return HVACMode.HEAT
if self.
_controller_controller.is_on
else HVACMode.OFF
184 """Return the current temperature."""
189 """Return the temperature we try to reach."""
194 """Return the fan setting."""
195 return _ESCEA_FAN_TO_HA[self.
_controller_controller.fan]
198 """Catch any connection errors and set unavailable."""
201 except ConnectionError
as ex:
207 """Set new target temperature."""
208 temp = kwargs.get(ATTR_TEMPERATURE)
213 """Set new target fan mode."""
217 """Set new target operation mode."""
221 """Turn the entity on."""
225 """Turn the entity off."""
None __init__(self, Controller controller)
None async_set_hvac_mode(self, HVACMode hvac_mode)
float|None current_temperature(self)
None async_added_to_hass(self)
None set_available(self, bool available, Exception|None ex=None)
None async_set_fan_mode(self, str fan_mode)
None wrap_and_catch(self, Coroutine coro)
None async_set_temperature(self, **Any kwargs)
None async_turn_off(self)
float|None target_temperature(self)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
FibaroController init_controller(Mapping[str, Any] data)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)