ScreenLogic cleanups (#48136)
* ScreenLogic cleanup. Bump screenlogicpy to 0.2.0. Move heating functions from water_heater to climate platform. Address notes from original PR. * Fix temperature attribute * Addressing notes. Bump screenlogicpy to 0.2.1. Made device_types constants. Made (known) equipment flags constants. Used dict.get() in places where None is the default. Return fast with good _last_preset. * Update homeassistant/components/screenlogic/climate.py Let base entity handle state property. Co-authored-by: J. Nick Koston <nick@koston.org> * Patch integration setup functions. * Exception, ATTR_TEMPERATURE notes Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
346a724ac3
commit
fb48fd7d10
12 changed files with 354 additions and 194 deletions
|
@ -1,15 +1,20 @@
|
|||
"""Support for a ScreenLogic Binary Sensor."""
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const import ON_OFF
|
||||
from screenlogicpy.const import DEVICE_TYPE, ON_OFF
|
||||
|
||||
from homeassistant.components.binary_sensor import DEVICE_CLASSES, BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_PROBLEM,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
||||
from . import ScreenlogicEntity
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS = {DEVICE_TYPE.ALARM: DEVICE_CLASS_PROBLEM}
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up entry."""
|
||||
|
@ -19,7 +24,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
|
||||
for binary_sensor in data["devices"]["binary_sensor"]:
|
||||
entities.append(ScreenLogicBinarySensor(coordinator, binary_sensor))
|
||||
async_add_entities(entities, True)
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
class ScreenLogicBinarySensor(ScreenlogicEntity, BinarySensorEntity):
|
||||
|
@ -33,10 +38,8 @@ class ScreenLogicBinarySensor(ScreenlogicEntity, BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class."""
|
||||
device_class = self.sensor.get("hass_type")
|
||||
if device_class in DEVICE_CLASSES:
|
||||
return device_class
|
||||
return None
|
||||
device_class = self.sensor.get("device_type")
|
||||
return SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS.get(device_class)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
@ -46,9 +49,4 @@ class ScreenLogicBinarySensor(ScreenlogicEntity, BinarySensorEntity):
|
|||
@property
|
||||
def sensor(self):
|
||||
"""Shortcut to access the sensor data."""
|
||||
return self.sensor_data[self._data_key]
|
||||
|
||||
@property
|
||||
def sensor_data(self):
|
||||
"""Shortcut to access the sensors data."""
|
||||
return self.coordinator.data["sensors"]
|
||||
return self.coordinator.data["sensors"][self._data_key]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue