Use shorthand attributes in Isy994 (#99395)
parent
5e03954e69
commit
2dab9eaf86
|
@ -421,6 +421,8 @@ class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity):
|
|||
class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity, RestoreEntity):
|
||||
"""Representation of the battery state of an ISY sensor."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.BATTERY
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
node: Node,
|
||||
|
@ -522,11 +524,6 @@ class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity, RestoreEntity)
|
|||
"""
|
||||
return bool(self._computed_state)
|
||||
|
||||
@property
|
||||
def device_class(self) -> BinarySensorDeviceClass:
|
||||
"""Get the class of this device."""
|
||||
return BinarySensorDeviceClass.BATTERY
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Get the state attributes for the device."""
|
||||
|
|
|
@ -83,6 +83,8 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||
| ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
_attr_target_temperature_step = 1.0
|
||||
_attr_fan_modes = [FAN_AUTO, FAN_ON]
|
||||
|
||||
def __init__(self, node: Node, device_info: DeviceInfo | None = None) -> None:
|
||||
"""Initialize the ISY Thermostat entity."""
|
||||
|
@ -90,13 +92,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||
self._uom = self._node.uom
|
||||
if isinstance(self._uom, list):
|
||||
self._uom = self._node.uom[0]
|
||||
self._hvac_action: str | None = None
|
||||
self._hvac_mode: str | None = None
|
||||
self._fan_mode: str | None = None
|
||||
self._temp_unit = None
|
||||
self._current_humidity = 0
|
||||
self._target_temp_low = 0
|
||||
self._target_temp_high = 0
|
||||
|
||||
@property
|
||||
def temperature_unit(self) -> str:
|
||||
|
@ -155,11 +150,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||
self._node.status, self._uom, self._node.prec, 1
|
||||
)
|
||||
|
||||
@property
|
||||
def target_temperature_step(self) -> float | None:
|
||||
"""Return the supported step of target temperature."""
|
||||
return 1.0
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Return the temperature we try to reach."""
|
||||
|
@ -185,11 +175,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||
return None
|
||||
return convert_isy_value_to_hass(target.value, target.uom, target.prec, 1)
|
||||
|
||||
@property
|
||||
def fan_modes(self) -> list[str]:
|
||||
"""Return the list of available fan modes."""
|
||||
return [FAN_AUTO, FAN_ON]
|
||||
|
||||
@property
|
||||
def fan_mode(self) -> str:
|
||||
"""Return the current fan mode ie. auto, on."""
|
||||
|
@ -210,26 +195,18 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||
target_temp_low = target_temp
|
||||
if target_temp_low is not None:
|
||||
await self._node.set_climate_setpoint_heat(int(target_temp_low))
|
||||
# Presumptive setting--event stream will correct if cmd fails:
|
||||
self._target_temp_low = target_temp_low
|
||||
if target_temp_high is not None:
|
||||
await self._node.set_climate_setpoint_cool(int(target_temp_high))
|
||||
# Presumptive setting--event stream will correct if cmd fails:
|
||||
self._target_temp_high = target_temp_high
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new target fan mode."""
|
||||
_LOGGER.debug("Requested fan mode %s", fan_mode)
|
||||
await self._node.set_fan_mode(HA_FAN_TO_ISY.get(fan_mode))
|
||||
# Presumptive setting--event stream will correct if cmd fails:
|
||||
self._fan_mode = fan_mode
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set new target hvac mode."""
|
||||
_LOGGER.debug("Requested operation mode %s", hvac_mode)
|
||||
await self._node.set_climate_mode(HA_HVAC_TO_ISY.get(hvac_mode))
|
||||
# Presumptive setting--event stream will correct if cmd fails:
|
||||
self._hvac_mode = hvac_mode
|
||||
self.async_write_ha_state()
|
||||
|
|
|
@ -112,6 +112,8 @@ class ISYSwitchEntity(ISYNodeEntity, SwitchEntity):
|
|||
class ISYSwitchProgramEntity(ISYProgramEntity, SwitchEntity):
|
||||
"""A representation of an ISY program switch."""
|
||||
|
||||
_attr_icon = "mdi:script-text-outline" # Matches isy program icon
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Get whether the ISY switch program is on."""
|
||||
|
@ -131,11 +133,6 @@ class ISYSwitchProgramEntity(ISYProgramEntity, SwitchEntity):
|
|||
f"Unable to run 'else' clause on program switch {self._actions.address}"
|
||||
)
|
||||
|
||||
@property
|
||||
def icon(self) -> str:
|
||||
"""Get the icon for programs."""
|
||||
return "mdi:script-text-outline" # Matches isy program icon
|
||||
|
||||
|
||||
class ISYEnableSwitchEntity(ISYAuxControlEntity, SwitchEntity):
|
||||
"""A representation of an ISY enable/disable switch."""
|
||||
|
|
Loading…
Reference in New Issue