puttyman / hass-amplifi

A home assistant integration for Ubiquiti Amplifi
27 stars 16 forks source link

Make speed sensors support long-term statistics #42

Closed hawksj closed 8 months ago

hawksj commented 8 months ago

Re-created PR #38 with correct branch

Per https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

Changed sensor.py to import extra objects from homeassistant.components.sensor to enable the entity to have SensorStateClass and SensorDeviceClass attributes. This allows for statistics graphs on the dashboard such as this: image image

I have tried to match the style of the original code by defining variables outside the function. Please suggest changes if the formatting is not correct.

hawksj commented 8 months ago

@atudor2 Did you ever get a chance to test these changes?

This code has been running in my HA instance for several weeks since my initial PR so I am confident it is working as expected. Will push if there are no complaints.

atudor2 commented 8 months ago

Hi @hawksj sorry I must admit I forgot - but I refreshed my local HA dev container and tested your change and seems to work as expected my side 👍

hawksj commented 8 months ago

Brilliant thanks @atudor2, I will merge this PR.

I'm planning to merge #39 too which will bring it up to date with the changes in #42, which also bumps the version number, hence not bumping it in this PR.

Do you want to test #39 before I merge? It's such a minor change that it may not be necessary but I'd rather get a second opinion first. Cheers