puttyman / hass-amplifi

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

Make speed sensors support long-term statistics #38

Closed hawksj closed 8 months ago

hawksj commented 8 months ago

Ignore first PR, I don't regularly work in public repos

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

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

Should have added that I have this code currently running in my HA instance where I sourced the screenshot. I have removed and re-added the integration multiple times in testing and initialization of the sensors hasn't failed.

puttyman commented 8 months ago

Hey @hawksj, thanks for the PR. Please see below before I merge.

Hey @gadgetchnnel @plesetsk @atudor2 ,

Given I do not use an Amplifi router anymore would you please test and confirm this PR would work as expected before merge.

atudor2 commented 8 months ago

Hi @puttyman sure I can give it a test but it can only be next week as I'm away from my HA instance currently

hawksj commented 8 months ago

This PR will have to be re-created, foolishly made this from my master branch and further commits are also now included in this PR.