1 """Support for OpenTherm Gateway climate devices."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
7 from types
import MappingProxyType
10 from pyotgw
import vars
as gw_vars
16 ClimateEntityDescription,
27 from .
import OpenThermGatewayHub
31 CONF_TEMPORARY_OVRD_MODE,
34 THERMOSTAT_DEVICE_DESCRIPTION,
37 from .entity
import OpenThermEntityDescription, OpenThermStatusEntity
39 _LOGGER = logging.getLogger(__name__)
41 DEFAULT_FLOOR_TEMP =
False
44 @dataclass(frozen=True, kw_only=True)
46 ClimateEntityDescription, OpenThermEntityDescription
48 """Describes an opentherm_gw climate entity."""
53 config_entry: ConfigEntry,
54 async_add_entities: AddEntitiesCallback,
56 """Set up an OpenTherm Gateway climate entity."""
60 hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]],
62 key=
"thermostat_entity",
63 device_description=THERMOSTAT_DEVICE_DESCRIPTION,
73 """Representation of a climate device."""
75 _attr_supported_features = (
76 ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
78 _attr_temperature_unit = UnitOfTemperature.CELSIUS
81 _attr_preset_modes = []
84 _attr_hvac_mode = HVACMode.HEAT
85 _away_mode_a: int |
None =
None
86 _away_mode_b: int |
None =
None
89 _enable_turn_on_off_backwards_compatibility =
False
90 _target_temperature: float |
None =
None
91 _new_target_temperature: float |
None =
None
92 entity_description: OpenThermClimateEntityDescription
96 gw_hub: OpenThermGatewayHub,
97 description: OpenThermClimateEntityDescription,
98 options: MappingProxyType[str, Any],
100 """Initialize the entity."""
101 super().
__init__(gw_hub, description)
102 if CONF_READ_PRECISION
in options:
109 """Update climate entity options."""
110 self.
_attr_precision_attr_precision = entry.options[CONF_READ_PRECISION]
116 """Connect to the OpenTherm Gateway device."""
126 """Receive and handle a new report from the Gateway."""
127 ch_active = status[OpenThermDataSource.BOILER].
get(gw_vars.DATA_SLAVE_CH_ACTIVE)
128 flame_on = status[OpenThermDataSource.BOILER].
get(gw_vars.DATA_SLAVE_FLAME_ON)
129 cooling_active = status[OpenThermDataSource.BOILER].
get(
130 gw_vars.DATA_SLAVE_COOLING_ACTIVE
132 if ch_active
and flame_on:
142 gw_vars.DATA_ROOM_TEMP
144 temp_upd = status[OpenThermDataSource.THERMOSTAT].
get(
145 gw_vars.DATA_ROOM_SETPOINT
154 gpio_a_state = status[OpenThermDataSource.GATEWAY].
get(gw_vars.OTGW_GPIO_A)
155 gpio_b_state = status[OpenThermDataSource.GATEWAY].
get(gw_vars.OTGW_GPIO_B)
156 self.
_away_mode_a_away_mode_a = gpio_a_state - 5
if gpio_a_state
in (5, 6)
else None
157 self.
_away_mode_b_away_mode_b = gpio_b_state - 5
if gpio_b_state
in (5, 6)
else None
160 status[OpenThermDataSource.GATEWAY].
get(gw_vars.OTGW_GPIO_A_STATE)
168 status[OpenThermDataSource.GATEWAY].
get(gw_vars.OTGW_GPIO_B_STATE)
178 """Return the temperature we try to reach."""
183 """Return current preset mode."""
189 """Set the preset mode."""
190 _LOGGER.warning(
"Changing preset mode is not supported")
193 """Set new target temperature."""
194 if ATTR_TEMPERATURE
in kwargs:
195 temp =
float(kwargs[ATTR_TEMPERATURE])
float|None target_temperature(self)
_attr_target_temperature_step
None set_preset_mode(self, str preset_mode)
None async_added_to_hass(self)
def update_options(self, entry)
float|None target_temperature(self)
None async_set_temperature(self, **Any kwargs)
def receive_report(self, dict[OpenThermDataSource, dict] status)
None __init__(self, OpenThermGatewayHub gw_hub, OpenThermClimateEntityDescription description, MappingProxyType[str, Any] options)
_attr_current_temperature
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)