Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new device class and enums #16

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions custom_components/weatherlink/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"codeowners": [
"@astrandb"
],
"iot_class": "cloud_polling"
}
"iot_class": "cloud_polling",
"integration_type": "service"
}
35 changes: 16 additions & 19 deletions custom_components/weatherlink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -109,18 +107,17 @@ 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,
),
WLSensorDescription(
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,
),
Expand All @@ -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,
),
Expand All @@ -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,
),
Expand All @@ -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,
),
)
Expand Down