-
-
Notifications
You must be signed in to change notification settings - Fork 37k
Fix rain count sensors' state class of Ecowitt #158204
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
Changes from 6 commits
4943275
ed20026
0bb5c1d
5f3040a
000c9ff
c5755e7
620e29c
5d8a17c
a825a5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,19 @@ | |
| ) | ||
|
|
||
|
|
||
| # Hourly and 24h rain count sensors are rolling window sensors | ||
| _ROLLING_WINDOW_RAIN_COUNT_SENSORS = { | ||
|
||
| "hourlyrainin", | ||
| "hourlyrainmm", | ||
| "hrain_piezo", | ||
| "hrain_piezomm", | ||
| "last24hrainin", | ||
| "last24hrainmm", | ||
| "last24hrain_piezo", | ||
| "last24hrain_piezomm", | ||
| } | ||
|
|
||
|
|
||
| ECOWITT_SENSORS_MAPPING: Final = { | ||
| EcoWittSensorTypes.HUMIDITY: SensorEntityDescription( | ||
| key="HUMIDITY", | ||
|
|
@@ -151,12 +164,14 @@ | |
| key="RAIN_COUNT_MM", | ||
| native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, | ||
| device_class=SensorDeviceClass.PRECIPITATION, | ||
| state_class=SensorStateClass.TOTAL_INCREASING, | ||
upsuper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| suggested_display_precision=1, | ||
| ), | ||
| EcoWittSensorTypes.RAIN_COUNT_INCHES: SensorEntityDescription( | ||
| key="RAIN_COUNT_INCHES", | ||
| native_unit_of_measurement=UnitOfPrecipitationDepth.INCHES, | ||
| device_class=SensorDeviceClass.PRECIPITATION, | ||
| state_class=SensorStateClass.TOTAL_INCREASING, | ||
upsuper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| suggested_display_precision=2, | ||
| ), | ||
| EcoWittSensorTypes.RAIN_RATE_MM: SensorEntityDescription( | ||
|
|
@@ -285,15 +300,8 @@ def _new_sensor(sensor: EcoWittSensor) -> None: | |
| name=sensor.name, | ||
| ) | ||
|
|
||
| # Only total rain needs state class for long-term statistics | ||
| if sensor.key in ( | ||
| "totalrainin", | ||
| "totalrainmm", | ||
| ): | ||
| description = dataclasses.replace( | ||
| description, | ||
| state_class=SensorStateClass.TOTAL_INCREASING, | ||
| ) | ||
| if sensor.key in _ROLLING_WINDOW_RAIN_COUNT_SENSORS: | ||
| description = dataclasses.replace(description, state_class=None) | ||
upsuper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| async_add_entities([EcowittSensorEntity(sensor, description)]) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.