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

Add state classes to sensors #228

Merged
merged 1 commit into from
Apr 30, 2024
Merged
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
23 changes: 23 additions & 0 deletions custom_components/pirateweather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"precip_intensity": PirateWeatherSensorEntityDescription(
key="precip_intensity",
name="Precip Intensity",
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
us_unit=UnitOfPrecipitationDepth.INCHES,
ca_unit=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
Expand All @@ -173,6 +174,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"precip_probability": PirateWeatherSensorEntityDescription(
key="precip_probability",
name="Precip Probability",
state_class=SensorStateClass.MEASUREMENT,
si_unit=PERCENTAGE,
us_unit=PERCENTAGE,
ca_unit=PERCENTAGE,
Expand All @@ -186,6 +188,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="precip_accumulation",
name="Precip Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
Expand All @@ -199,6 +202,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="liquid_accumulation",
name="Liquid Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
Expand All @@ -212,6 +216,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="snow_accumulation",
name="Snow Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
Expand All @@ -225,6 +230,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="ice_accumulation",
name="Ice Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
Expand Down Expand Up @@ -277,6 +283,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="wind_speed",
name="Wind Speed",
device_class=SensorDeviceClass.WIND_SPEED,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfSpeed.METERS_PER_SECOND,
us_unit=UnitOfSpeed.MILES_PER_HOUR,
ca_unit=UnitOfSpeed.KILOMETERS_PER_HOUR,
Expand All @@ -289,6 +296,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"wind_bearing": PirateWeatherSensorEntityDescription(
key="wind_bearing",
name="Wind Bearing",
state_class=SensorStateClass.MEASUREMENT,
si_unit=DEGREE,
us_unit=DEGREE,
ca_unit=DEGREE,
Expand All @@ -302,6 +310,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="wind_gust",
name="Wind Gust",
device_class=SensorDeviceClass.WIND_SPEED,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfSpeed.METERS_PER_SECOND,
us_unit=UnitOfSpeed.MILES_PER_HOUR,
ca_unit=UnitOfSpeed.KILOMETERS_PER_HOUR,
Expand All @@ -314,6 +323,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"cloud_cover": PirateWeatherSensorEntityDescription(
key="cloud_cover",
name="Cloud Coverage",
state_class=SensorStateClass.MEASUREMENT,
si_unit=PERCENTAGE,
us_unit=PERCENTAGE,
ca_unit=PERCENTAGE,
Expand Down Expand Up @@ -352,6 +362,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"visibility": PirateWeatherSensorEntityDescription(
key="visibility",
name="Visibility",
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.KILOMETERS,
us_unit=UnitOfLength.MILES,
ca_unit=UnitOfLength.KILOMETERS,
Expand Down Expand Up @@ -393,6 +404,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="smoke",
name="Smoke",
device_class=SensorDeviceClass.PM25,
state_class=SensorStateClass.MEASUREMENT,
si_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
us_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
ca_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
Expand All @@ -406,6 +418,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="smoke_max",
name="Smoke Max",
device_class=SensorDeviceClass.PM25,
state_class=SensorStateClass.MEASUREMENT,
si_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
us_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
ca_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
Expand All @@ -419,6 +432,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="apparent_temperature_max",
name="Daily High Apparent Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -431,6 +445,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="apparent_temperature_high",
name="Daytime High Apparent Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -443,6 +458,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="apparent_temperature_min",
name="Daily Low Apparent Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -455,6 +471,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="apparent_temperature_low",
name="Overnight Low Apparent Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -467,6 +484,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="temperature_max",
name="Daily High Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -479,6 +497,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="temperature_high",
name="Daytime High Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -491,6 +510,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="temperature_min",
name="Daily Low Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -503,6 +523,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
key="temperature_low",
name="Overnight Low Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfTemperature.CELSIUS,
us_unit=UnitOfTemperature.FAHRENHEIT,
ca_unit=UnitOfTemperature.CELSIUS,
Expand All @@ -514,6 +535,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"precip_intensity_max": PirateWeatherSensorEntityDescription(
key="precip_intensity_max",
name="Daily Max Precip Intensity",
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
us_unit=UnitOfPrecipitationDepth.INCHES,
ca_unit=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
Expand All @@ -526,6 +548,7 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
"uv_index": PirateWeatherSensorEntityDescription(
key="uv_index",
name="UV Index",
state_class=SensorStateClass.MEASUREMENT,
si_unit=UV_INDEX,
us_unit=UV_INDEX,
ca_unit=UV_INDEX,
Expand Down