adamoutler / HassOSArgonOneAddon

A Home Assistant Addon for Argon One Fan Control.
247 stars 32 forks source link

Add state_class to allow usage of the "Statistics Graph Card" #51

Open srjlewis opened 1 year ago

srjlewis commented 1 year ago

Could you add state_class: measurement to the reqBody as this would allow uage of the "Statistics Graph Card" for better long term reporting and display.

adamoutler commented 1 year ago

What type?

srjlewis commented 1 year ago

Hi

The type would be measurement

Below is a workaround using a template sensor

template:
      - name: "Argon Fan Speed"
        unit_of_measurement: "%"
        state: '{{ states("sensor.argon_one_addon_fan_speed") }}'
        state_class: measurement
        icon: mdi:fan

I would guess that the following line would need changing from

reqBody='{"state": "'"${fanPercent}"'", "attributes": { "unit_of_measurement": "%", "icon": "'"${icon}"'", "Temperature '"${CorF}"'": "'"${cpuTemp}"'", "friendly_name": "Argon Fan Speed"}}'

to the following, but I am only guessing at the right placement

reqBody='{"state": "'"${fanPercent}"'","state_class": "measurement" , "attributes": { "unit_of_measurement": "%", "icon": "'"${icon}"'", "Temperature '"${CorF}"'": "'"${cpuTemp}"'", "friendly_name": "Argon Fan Speed"}}'

or

reqBody='{"state": "'"${fanPercent}"'" , "attributes": { "unit_of_measurement": "%", "icon": "'"${icon}"'" ,"state_class": "measurement", "Temperature '"${CorF}"'": "'"${cpuTemp}"'", "friendly_name": "Argon Fan Speed"}}'