mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use shorthand attributes in Isy994 (#99395)
This commit is contained in:
parent
5e03954e69
commit
2dab9eaf86
@ -421,6 +421,8 @@ class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity):
|
|||||||
class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity, RestoreEntity):
|
class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity, RestoreEntity):
|
||||||
"""Representation of the battery state of an ISY sensor."""
|
"""Representation of the battery state of an ISY sensor."""
|
||||||
|
|
||||||
|
_attr_device_class = BinarySensorDeviceClass.BATTERY
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
node: Node,
|
node: Node,
|
||||||
@ -522,11 +524,6 @@ class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity, RestoreEntity)
|
|||||||
"""
|
"""
|
||||||
return bool(self._computed_state)
|
return bool(self._computed_state)
|
||||||
|
|
||||||
@property
|
|
||||||
def device_class(self) -> BinarySensorDeviceClass:
|
|
||||||
"""Get the class of this device."""
|
|
||||||
return BinarySensorDeviceClass.BATTERY
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Get the state attributes for the device."""
|
"""Get the state attributes for the device."""
|
||||||
|
@ -83,6 +83,8 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||||||
| ClimateEntityFeature.TARGET_TEMPERATURE
|
| ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
| 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:
|
def __init__(self, node: Node, device_info: DeviceInfo | None = None) -> None:
|
||||||
"""Initialize the ISY Thermostat entity."""
|
"""Initialize the ISY Thermostat entity."""
|
||||||
@ -90,13 +92,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||||||
self._uom = self._node.uom
|
self._uom = self._node.uom
|
||||||
if isinstance(self._uom, list):
|
if isinstance(self._uom, list):
|
||||||
self._uom = self._node.uom[0]
|
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
|
@property
|
||||||
def temperature_unit(self) -> str:
|
def temperature_unit(self) -> str:
|
||||||
@ -155,11 +150,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||||||
self._node.status, self._uom, self._node.prec, 1
|
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
|
@property
|
||||||
def target_temperature(self) -> float | None:
|
def target_temperature(self) -> float | None:
|
||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
@ -185,11 +175,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||||||
return None
|
return None
|
||||||
return convert_isy_value_to_hass(target.value, target.uom, target.prec, 1)
|
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
|
@property
|
||||||
def fan_mode(self) -> str:
|
def fan_mode(self) -> str:
|
||||||
"""Return the current fan mode ie. auto, on."""
|
"""Return the current fan mode ie. auto, on."""
|
||||||
@ -210,26 +195,18 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||||||
target_temp_low = target_temp
|
target_temp_low = target_temp
|
||||||
if target_temp_low is not None:
|
if target_temp_low is not None:
|
||||||
await self._node.set_climate_setpoint_heat(int(target_temp_low))
|
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:
|
if target_temp_high is not None:
|
||||||
await self._node.set_climate_setpoint_cool(int(target_temp_high))
|
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()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
_LOGGER.debug("Requested fan mode %s", fan_mode)
|
_LOGGER.debug("Requested fan mode %s", fan_mode)
|
||||||
await self._node.set_fan_mode(HA_FAN_TO_ISY.get(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()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set new target hvac mode."""
|
"""Set new target hvac mode."""
|
||||||
_LOGGER.debug("Requested operation mode %s", hvac_mode)
|
_LOGGER.debug("Requested operation mode %s", hvac_mode)
|
||||||
await self._node.set_climate_mode(HA_HVAC_TO_ISY.get(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()
|
self.async_write_ha_state()
|
||||||
|
@ -112,6 +112,8 @@ class ISYSwitchEntity(ISYNodeEntity, SwitchEntity):
|
|||||||
class ISYSwitchProgramEntity(ISYProgramEntity, SwitchEntity):
|
class ISYSwitchProgramEntity(ISYProgramEntity, SwitchEntity):
|
||||||
"""A representation of an ISY program switch."""
|
"""A representation of an ISY program switch."""
|
||||||
|
|
||||||
|
_attr_icon = "mdi:script-text-outline" # Matches isy program icon
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Get whether the ISY switch program is on."""
|
"""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}"
|
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):
|
class ISYEnableSwitchEntity(ISYAuxControlEntity, SwitchEntity):
|
||||||
"""A representation of an ISY enable/disable switch."""
|
"""A representation of an ISY enable/disable switch."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user