Use shorthand attributes in Opentherm gateway (#99630)
This commit is contained in:
parent
c567a2c3d4
commit
94aec3e590
3 changed files with 55 additions and 151 deletions
|
@ -70,6 +70,20 @@ class OpenThermClimate(ClimateEntity):
|
|||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
_attr_available = False
|
||||
_attr_hvac_modes = []
|
||||
_attr_preset_modes = []
|
||||
_attr_min_temp = 1
|
||||
_attr_max_temp = 30
|
||||
_hvac_mode = HVACMode.HEAT
|
||||
_current_temperature: float | None = None
|
||||
_new_target_temperature: float | None = None
|
||||
_target_temperature: float | None = None
|
||||
_away_mode_a: int | None = None
|
||||
_away_mode_b: int | None = None
|
||||
_away_state_a = False
|
||||
_away_state_b = False
|
||||
_current_operation: HVACAction | None = None
|
||||
|
||||
def __init__(self, gw_dev, options):
|
||||
"""Initialize the device."""
|
||||
|
@ -78,22 +92,21 @@ class OpenThermClimate(ClimateEntity):
|
|||
ENTITY_ID_FORMAT, gw_dev.gw_id, hass=gw_dev.hass
|
||||
)
|
||||
self.friendly_name = gw_dev.name
|
||||
self._attr_name = self.friendly_name
|
||||
self.floor_temp = options.get(CONF_FLOOR_TEMP, DEFAULT_FLOOR_TEMP)
|
||||
self.temp_read_precision = options.get(CONF_READ_PRECISION)
|
||||
self.temp_set_precision = options.get(CONF_SET_PRECISION)
|
||||
self.temporary_ovrd_mode = options.get(CONF_TEMPORARY_OVRD_MODE, True)
|
||||
self._available = False
|
||||
self._current_operation: HVACAction | None = None
|
||||
self._current_temperature = None
|
||||
self._hvac_mode = HVACMode.HEAT
|
||||
self._new_target_temperature = None
|
||||
self._target_temperature = None
|
||||
self._away_mode_a = None
|
||||
self._away_mode_b = None
|
||||
self._away_state_a = False
|
||||
self._away_state_b = False
|
||||
self._unsub_options = None
|
||||
self._unsub_updates = None
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, gw_dev.gw_id)},
|
||||
manufacturer="Schelte Bron",
|
||||
model="OpenTherm Gateway",
|
||||
name=gw_dev.name,
|
||||
sw_version=gw_dev.gw_version,
|
||||
)
|
||||
self._attr_unique_id = gw_dev.gw_id
|
||||
|
||||
@callback
|
||||
def update_options(self, entry):
|
||||
|
@ -123,7 +136,7 @@ class OpenThermClimate(ClimateEntity):
|
|||
@callback
|
||||
def receive_report(self, status):
|
||||
"""Receive and handle a new report from the Gateway."""
|
||||
self._available = status != gw_vars.DEFAULT_STATUS
|
||||
self._attr_available = status != gw_vars.DEFAULT_STATUS
|
||||
ch_active = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_CH_ACTIVE)
|
||||
flame_on = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_FLAME_ON)
|
||||
cooling_active = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_COOLING_ACTIVE)
|
||||
|
@ -171,32 +184,6 @@ class OpenThermClimate(ClimateEntity):
|
|||
)
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return availability of the sensor."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the friendly name."""
|
||||
return self.friendly_name
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._gateway.gw_id)},
|
||||
manufacturer="Schelte Bron",
|
||||
model="OpenTherm Gateway",
|
||||
name=self._gateway.name,
|
||||
sw_version=self._gateway.gw_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique ID."""
|
||||
return self._gateway.gw_id
|
||||
|
||||
@property
|
||||
def precision(self):
|
||||
"""Return the precision of the system."""
|
||||
|
@ -216,11 +203,6 @@ class OpenThermClimate(ClimateEntity):
|
|||
"""Return current HVAC mode."""
|
||||
return self._hvac_mode
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> list[HVACMode]:
|
||||
"""Return available HVAC modes."""
|
||||
return []
|
||||
|
||||
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set the HVAC mode."""
|
||||
_LOGGER.warning("Changing HVAC mode is not supported")
|
||||
|
@ -259,11 +241,6 @@ class OpenThermClimate(ClimateEntity):
|
|||
return PRESET_AWAY
|
||||
return PRESET_NONE
|
||||
|
||||
@property
|
||||
def preset_modes(self):
|
||||
"""Available preset modes to set."""
|
||||
return []
|
||||
|
||||
def set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Set the preset mode."""
|
||||
_LOGGER.warning("Changing preset mode is not supported")
|
||||
|
@ -278,13 +255,3 @@ class OpenThermClimate(ClimateEntity):
|
|||
temp, self.temporary_ovrd_mode
|
||||
)
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def min_temp(self):
|
||||
"""Return the minimum temperature."""
|
||||
return 1
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
"""Return the maximum temperature."""
|
||||
return 30
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue