Skip to content

Commit

Permalink
🐛 fix warning about invalid suggested_unit_of_measurement
Browse files Browse the repository at this point in the history
Some walkingpad sensors are generating warnings in the logs:

>  <class 'custom_components.king_smith.sensor.WalkingPadSensor'> sets
>  an invalid suggested_unit_of_measurement. Please create a bug
>  report at https://github.com/madmatah/hass-walkingpad/issues. This
>  warning will become an error in Home Assistant Core 2024.5

Since the specified suggested_unit_of_measurements specified in the
sensors definition do not differ from their
native_unit_of_measurements, I don't think that they are very useful.
So I removed them.
  • Loading branch information
madmatah committed Mar 29, 2024
1 parent 1f3798e commit 66c06ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- upgrade homeassistant to 2024.3.3

### Fixed

- warnings about invalid suggested_unit_of_measurement

## [0.1.0] - 2024-03-29

### Added
Expand Down
5 changes: 0 additions & 5 deletions custom_components/king_smith/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class WalkingPadSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfLength.KILOMETERS,
state_class=SensorStateClass.TOTAL_INCREASING,
suggested_display_precision=2,
suggested_unit_of_measurement=UnitOfLength.KILOMETERS,
translation_key="walkingpad_distance",
value_fn=lambda status: status.get("session_distance", 0.0) / 1000,
),
Expand All @@ -59,7 +58,6 @@ class WalkingPadSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTime.MINUTES,
state_class=SensorStateClass.TOTAL_INCREASING,
suggested_display_precision=0,
suggested_unit_of_measurement=UnitOfTime.MINUTES,
translation_key="walkingpad_duration_minutes",
value_fn=lambda status: round(status.get("session_running_time", 0) / 60, 1),
),
Expand All @@ -70,7 +68,6 @@ class WalkingPadSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTime.HOURS,
state_class=SensorStateClass.TOTAL_INCREASING,
suggested_display_precision=1,
suggested_unit_of_measurement=UnitOfTime.HOURS,
translation_key="walkingpad_duration_hours",
value_fn=lambda status: round(status.get("session_running_time", 0) / 3600, 4),
),
Expand All @@ -81,7 +78,6 @@ class WalkingPadSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTime.DAYS,
state_class=SensorStateClass.TOTAL_INCREASING,
suggested_display_precision=1,
suggested_unit_of_measurement=UnitOfTime.DAYS,
translation_key="walkingpad_duration_days",
value_fn=lambda status: round(status.get("session_running_time", 0) / 86400, 6),
),
Expand All @@ -93,7 +89,6 @@ class WalkingPadSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
suggested_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
translation_key="walkingpad_current_speed",
value_fn=lambda status: status.get("speed", 0.0),
),
Expand Down

0 comments on commit 66c06ef

Please sign in to comment.