djtimca / hagooglewifi

Home Assistant integration for Google Wifi systems.
Apache License 2.0
79 stars 26 forks source link

add state_class attribute to sensors #83

Closed csanner closed 1 year ago

csanner commented 1 year ago

I cannot graph the download/upload speeds over time because the sensors do not have the state_class attribute. https://developers.home-assistant.io/docs/core/entity/sensor/

I'll attempt to make the changes myself but comparing two different implementations of sensors I am having trouble finding similarites :) I see I'll have a lot to learn

rockwig commented 1 year ago

Is there any work around for this? It would be nice to create charts with the data.

seventor commented 1 year ago

Yes. Create a new template sensor based on the Download Speed sensor from this package. Something like in configuration.yaml:

template:
  - sensor:
      - name: "Internet download speed"
        state_class: measurement
        device_class: data_rate
        state: >-
          {{   states('sensor.google_wifi_system_....._download_speed') }}
csanner commented 1 year ago

okay, you're going to have to give some more detail here. I tried creating this as a sensor with the template platform, I tried loading it in using templates...this is apparently beyond me. state_class is an invalid parameter for a sensor.

csanner commented 1 year ago

which is apparently solved by this: https://community.home-assistant.io/t/state-class-measurement-for-platform-template/331630 I moved them into templates, but I can't find the things...

seventor commented 1 year ago

Yes, it should be under template, as it is a template sensor. Then save the configuration.yaml, and restart Home Assistant. It should show up as a new sensor named sensor.internet_download_speed.

csanner commented 1 year ago

okay...that seems to have worked. thank you!