From aa3e419b93ac17b4a53b8108dfe04983698213ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Strandberg?= Date: Thu, 27 Oct 2022 15:32:19 +0200 Subject: [PATCH 1/2] Add integration_type to manifest --- custom_components/weatherlink/manifest.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/weatherlink/manifest.json b/custom_components/weatherlink/manifest.json index 9ff4e98..63d9b1c 100644 --- a/custom_components/weatherlink/manifest.json +++ b/custom_components/weatherlink/manifest.json @@ -13,5 +13,6 @@ "codeowners": [ "@astrandb" ], - "iot_class": "cloud_polling" -} + "iot_class": "cloud_polling", + "integration_type": "service" +} \ No newline at end of file From 62dca32e680ac79a2f161345f528a7b1f61fe3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Strandberg?= Date: Thu, 27 Oct 2022 16:12:04 +0200 Subject: [PATCH 2/2] Use ned device classes and enums --- custom_components/weatherlink/sensor.py | 35 +++++++++++-------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/custom_components/weatherlink/sensor.py b/custom_components/weatherlink/sensor.py index 87bdc8d..051df9b 100644 --- a/custom_components/weatherlink/sensor.py +++ b/custom_components/weatherlink/sensor.py @@ -12,13 +12,12 @@ ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - LENGTH_MILLIMETERS, PERCENTAGE, - PRECIPITATION_MILLIMETERS_PER_HOUR, - PRESSURE_MBAR, - SPEED_METERS_PER_SECOND, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfLength, + UnitOfPressure, + UnitOfSpeed, + UnitOfTemperature, + UnitOfVolumetricFlux, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -47,7 +46,7 @@ class WLSensorDescription(SensorEntityDescription): tag="temp_c", device_class=SensorDeviceClass.TEMPERATURE, name="Outside temperature", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), WLSensorDescription( @@ -72,18 +71,17 @@ class WLSensorDescription(SensorEntityDescription): tag="pressure_mb", device_class=SensorDeviceClass.PRESSURE, name="Pressure", - native_unit_of_measurement=PRESSURE_MBAR, + native_unit_of_measurement=UnitOfPressure.MBAR, state_class=SensorStateClass.MEASUREMENT, decimals=0, ), WLSensorDescription( key="Wind", tag="wind_mph", - device_class=SensorDeviceClass.SPEED, - icon="mdi:weather-windy", + device_class=SensorDeviceClass.WIND_SPEED, name="Wind", convert=lambda x: x * 1609 / 3600, - native_unit_of_measurement=SPEED_METERS_PER_SECOND, + native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND, state_class=SensorStateClass.MEASUREMENT, ), WLSensorDescription( @@ -99,7 +97,7 @@ class WLSensorDescription(SensorEntityDescription): subtag=SUBTAG_1, device_class=SensorDeviceClass.TEMPERATURE, name="Inside temperature", - native_unit_of_measurement=TEMP_FAHRENHEIT, + native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT, state_class=SensorStateClass.MEASUREMENT, ), WLSensorDescription( @@ -109,7 +107,7 @@ class WLSensorDescription(SensorEntityDescription): icon="mdi:weather-pouring", name="Rain today", device_class=SensorDeviceClass.DISTANCE, - native_unit_of_measurement=LENGTH_MILLIMETERS, + native_unit_of_measurement=UnitOfLength.MILLIMETERS, convert=lambda x: x * 25.4, state_class=SensorStateClass.MEASUREMENT, ), @@ -117,10 +115,9 @@ class WLSensorDescription(SensorEntityDescription): key="RainRate", tag="rain_rate_in_per_hr", subtag=SUBTAG_1, - icon="mdi:weather-pouring", name="Rain rate", - device_class=SensorDeviceClass.SPEED, - native_unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR, + device_class=SensorDeviceClass.PRECIPITATION_INTENSITY, + native_unit_of_measurement=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR, convert=lambda x: x * 25.4, state_class=SensorStateClass.MEASUREMENT, ), @@ -131,7 +128,7 @@ class WLSensorDescription(SensorEntityDescription): icon="mdi:weather-pouring", name="Rain this month", device_class=SensorDeviceClass.DISTANCE, - native_unit_of_measurement=LENGTH_MILLIMETERS, + native_unit_of_measurement=UnitOfLength.MILLIMETERS, convert=lambda x: x * 25.4, state_class=SensorStateClass.MEASUREMENT, ), @@ -142,7 +139,7 @@ class WLSensorDescription(SensorEntityDescription): icon="mdi:weather-pouring", name="Rain this year", device_class=SensorDeviceClass.DISTANCE, - native_unit_of_measurement=LENGTH_MILLIMETERS, + native_unit_of_measurement=UnitOfLength.MILLIMETERS, convert=lambda x: x * 25.4, state_class=SensorStateClass.TOTAL_INCREASING, ), @@ -151,7 +148,7 @@ class WLSensorDescription(SensorEntityDescription): tag="dewpoint_c", name="Dewpoint", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), )