Use new UPTIME sensor class for Shelly#169088
Conversation
|
Hey there @bieniu, @thecode, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Shelly integration’s “Last restart” sensors to use Home Assistant’s new SensorDeviceClass.UPTIME so core can handle small drift/variance consistently.
Changes:
- Switch Shelly “Last restart” sensors from
SensorDeviceClass.TIMESTAMPtoSensorDeviceClass.UPTIME. - Remove the Shelly-specific uptime drift helper (
get_device_uptime) and itsUPTIME_DEVIATIONconstant. - Update Shelly device snapshots to reflect the new sensor device class.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/shelly/sensor.py |
Uses SensorDeviceClass.UPTIME and computes last restart from utcnow() - timedelta(seconds=uptime) for REST/RPC sensors. |
homeassistant/components/shelly/utils.py |
Removes the no-longer-needed get_device_uptime helper and related imports. |
homeassistant/components/shelly/const.py |
Removes UPTIME_DEVIATION constant since drift handling is now in core’s UPTIME device class normalization. |
tests/components/shelly/test_utils.py |
Drops the unit test for the removed helper and cleans up unused imports. |
tests/components/shelly/snapshots/test_devices.ambr |
Updates snapshot expectations from timestamp to uptime device class. |
|
Should we mark this as a braking change? Users may have templates using the |
I honestly think this one is fine to ship like this 👍 ../Frenck Blogging my personal ramblings at frenck.dev |
Proposed change
Use new UPTIME sensor class for Shelly
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: