From 4f20b1574260db73c5e1d2ef5ff8031ecd3c699b Mon Sep 17 00:00:00 2001 From: Kevin Worrel <37058192+dieselrabbit@users.noreply.github.com> Date: Thu, 12 Jan 2023 13:41:07 -0500 Subject: [PATCH] Bump screenlogicpy to 0.6.2 (#85725) fixes undefined --- .../components/screenlogic/__init__.py | 4 +- .../components/screenlogic/binary_sensor.py | 6 ++- .../components/screenlogic/climate.py | 5 ++- .../components/screenlogic/diagnostics.py | 1 + .../components/screenlogic/manifest.json | 2 +- .../components/screenlogic/number.py | 6 ++- .../components/screenlogic/sensor.py | 42 +++++++++++++++++-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 9 files changed, 59 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/screenlogic/__init__.py b/homeassistant/components/screenlogic/__init__.py index 41e0638c634..d698653a3fc 100644 --- a/homeassistant/components/screenlogic/__init__.py +++ b/homeassistant/components/screenlogic/__init__.py @@ -240,10 +240,12 @@ class ScreenlogicEntity(CoordinatorEntity[ScreenlogicDataUpdateCoordinator]): class ScreenLogicCircuitEntity(ScreenlogicEntity): """ScreenLogic circuit entity.""" + _attr_has_entity_name = True + @property def name(self): """Get the name of the switch.""" - return f"{self.gateway_name} {self.circuit['name']}" + return self.circuit["name"] @property def is_on(self) -> bool: diff --git a/homeassistant/components/screenlogic/binary_sensor.py b/homeassistant/components/screenlogic/binary_sensor.py index 73596983cec..61e06490feb 100644 --- a/homeassistant/components/screenlogic/binary_sensor.py +++ b/homeassistant/components/screenlogic/binary_sensor.py @@ -7,6 +7,7 @@ from homeassistant.components.binary_sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import ScreenlogicEntity @@ -64,10 +65,13 @@ async def async_setup_entry( class ScreenLogicBinarySensor(ScreenlogicEntity, BinarySensorEntity): """Representation of the basic ScreenLogic binary sensor entity.""" + _attr_has_entity_name = True + _attr_entity_category = EntityCategory.DIAGNOSTIC + @property def name(self): """Return the sensor name.""" - return f"{self.gateway_name} {self.sensor['name']}" + return self.sensor["name"] @property def device_class(self): diff --git a/homeassistant/components/screenlogic/climate.py b/homeassistant/components/screenlogic/climate.py index 588d6d9a581..093d96a285e 100644 --- a/homeassistant/components/screenlogic/climate.py +++ b/homeassistant/components/screenlogic/climate.py @@ -51,6 +51,8 @@ async def async_setup_entry( class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity): """Represents a ScreenLogic climate entity.""" + _attr_has_entity_name = True + _attr_hvac_modes = SUPPORTED_MODES _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE @@ -71,8 +73,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity): @property def name(self) -> str: """Name of the heater.""" - ent_name = self.body["heat_status"]["name"] - return f"{self.gateway_name} {ent_name}" + return self.body["heat_status"]["name"] @property def min_temp(self) -> float: diff --git a/homeassistant/components/screenlogic/diagnostics.py b/homeassistant/components/screenlogic/diagnostics.py index 63b5c1e61ad..6de916d9514 100644 --- a/homeassistant/components/screenlogic/diagnostics.py +++ b/homeassistant/components/screenlogic/diagnostics.py @@ -20,4 +20,5 @@ async def async_get_config_entry_diagnostics( return { "config_entry": config_entry.as_dict(), "data": coordinator.data, + "debug": coordinator.gateway.get_debug(), } diff --git a/homeassistant/components/screenlogic/manifest.json b/homeassistant/components/screenlogic/manifest.json index 4998b7b507f..3d43d729cdf 100644 --- a/homeassistant/components/screenlogic/manifest.json +++ b/homeassistant/components/screenlogic/manifest.json @@ -3,7 +3,7 @@ "name": "Pentair ScreenLogic", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/screenlogic", - "requirements": ["screenlogicpy==0.5.4"], + "requirements": ["screenlogicpy==0.6.2"], "codeowners": ["@dieselrabbit", "@bdraco"], "dhcp": [ { "registered_devices": true }, diff --git a/homeassistant/components/screenlogic/number.py b/homeassistant/components/screenlogic/number.py index 75dee907cc1..74a7811b590 100644 --- a/homeassistant/components/screenlogic/number.py +++ b/homeassistant/components/screenlogic/number.py @@ -6,6 +6,7 @@ from screenlogicpy.const import BODY_TYPE, DATA as SL_DATA, EQUIPMENT, SCG from homeassistant.components.number import NumberEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import ScreenlogicEntity @@ -42,13 +43,16 @@ async def async_setup_entry( class ScreenLogicNumber(ScreenlogicEntity, NumberEntity): """Class to represent a ScreenLogic Number.""" + _attr_has_entity_name = True + def __init__(self, coordinator, data_key, enabled=True): """Initialize of the entity.""" super().__init__(coordinator, data_key, enabled) self._body_type = SUPPORTED_SCG_NUMBERS.index(self._data_key) self._attr_native_max_value = SCG.LIMIT_FOR_BODY[self._body_type] - self._attr_name = f"{self.gateway_name} {self.sensor['name']}" + self._attr_name = self.sensor["name"] self._attr_native_unit_of_measurement = self.sensor["unit"] + self._attr_entity_category = EntityCategory.CONFIG @property def native_value(self) -> float: diff --git a/homeassistant/components/screenlogic/sensor.py b/homeassistant/components/screenlogic/sensor.py index beab664f448..3f488db98eb 100644 --- a/homeassistant/components/screenlogic/sensor.py +++ b/homeassistant/components/screenlogic/sensor.py @@ -4,6 +4,7 @@ from screenlogicpy.const import ( DATA as SL_DATA, DEVICE_TYPE, EQUIPMENT, + UNIT, ) from homeassistant.components.sensor import ( @@ -12,7 +13,17 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry +from homeassistant.const import ( + CONCENTRATION_PARTS_PER_MILLION, + PERCENTAGE, + REVOLUTIONS_PER_MINUTE, + UnitOfElectricPotential, + UnitOfPower, + UnitOfTemperature, + UnitOfTime, +) from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import ScreenlogicEntity @@ -56,8 +67,23 @@ SUPPORTED_SCG_SENSORS = ( SUPPORTED_PUMP_SENSORS = ("currentWatts", "currentRPM", "currentGPM") SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS = { - DEVICE_TYPE.TEMPERATURE: SensorDeviceClass.TEMPERATURE, + DEVICE_TYPE.DURATION: SensorDeviceClass.DURATION, DEVICE_TYPE.ENERGY: SensorDeviceClass.POWER, + DEVICE_TYPE.POWER: SensorDeviceClass.POWER, + DEVICE_TYPE.TEMPERATURE: SensorDeviceClass.TEMPERATURE, + DEVICE_TYPE.VOLUME: SensorDeviceClass.VOLUME, +} + +SL_UNIT_TO_HA_UNIT = { + UNIT.CELSIUS: UnitOfTemperature.CELSIUS, + UNIT.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT, + UNIT.MILLIVOLT: UnitOfElectricPotential.MILLIVOLT, + UNIT.WATT: UnitOfPower.WATT, + UNIT.HOUR: UnitOfTime.HOURS, + UNIT.SECOND: UnitOfTime.SECONDS, + UNIT.REVOLUTIONS_PER_MINUTE: REVOLUTIONS_PER_MINUTE, + UNIT.PARTS_PER_MILLION: CONCENTRATION_PARTS_PER_MILLION, + UNIT.PERCENT: PERCENTAGE, } @@ -129,15 +155,18 @@ async def async_setup_entry( class ScreenLogicSensor(ScreenlogicEntity, SensorEntity): """Representation of the basic ScreenLogic sensor entity.""" + _attr_has_entity_name = True + @property def name(self): """Name of the sensor.""" - return f"{self.gateway_name} {self.sensor['name']}" + return self.sensor["name"] @property def native_unit_of_measurement(self): """Return the unit of measurement.""" - return self.sensor.get("unit") + sl_unit = self.sensor.get("unit") + return SL_UNIT_TO_HA_UNIT.get(sl_unit, sl_unit) @property def device_class(self): @@ -145,6 +174,13 @@ class ScreenLogicSensor(ScreenlogicEntity, SensorEntity): device_type = self.sensor.get("device_type") return SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS.get(device_type) + @property + def entity_category(self): + """Entity Category of the sensor.""" + return ( + None if self._data_key == "air_temperature" else EntityCategory.DIAGNOSTIC + ) + @property def state_class(self): """Return the state class of the sensor.""" diff --git a/requirements_all.txt b/requirements_all.txt index 9a787abe3f6..dc0eeced03f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2278,7 +2278,7 @@ satel_integra==0.3.7 scapy==2.5.0 # homeassistant.components.screenlogic -screenlogicpy==0.5.4 +screenlogicpy==0.6.2 # homeassistant.components.scsgate scsgate==0.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 0d82b723fa5..114a6bf2ad0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1599,7 +1599,7 @@ samsungtvws[async,encrypted]==2.5.0 scapy==2.5.0 # homeassistant.components.screenlogic -screenlogicpy==0.5.4 +screenlogicpy==0.6.2 # homeassistant.components.backup securetar==2022.2.0