Data displayed as ‘non-numerical’ values with different colors, instead of X-Y plot

I am using the following configuration to display weather data:

sensor:
  - platform: rest
    name: Humidity
    resource: https://api.waqi.info/feed/<CITY>/?token=<TOKEN>
    method: GET
    value_template: '{{ value_json.data.iaqi.h.v | round(1) }}'
    headers:
      Accept: application/json
    scan_interval: 300

I noticed that the humidity data is displayed as ‘non-numerical’ values with different colors. I am wondering why it was not displayed in the form of ‘Data vs Time’ X-Y plot? Really appreciate helps!

You need to set your device class and unit of measurement…

sensor:
  - platform: rest
    name: Humidity
    device_class: humidity
    unit_of_measurement: '%'
    resource: https://api.waqi.info/feed/<CITY>/?token=<TOKEN>
    method: GET
    value_template: '{{ value_json.data.iaqi.h.v | round(1) }}'
    headers:
      Accept: application/json
    scan_interval: 300
1 Like

While the classes are a good idea, only the unit_of_measurement is required for a sensor state to be treated as numeric.

1 Like

Thank you for your reply.
I tried to add
unit_of_measurement: %
but got an error message:

Error loading /config/configuration.yaml: while scanning for the next token found character ‘%’ that cannot start any token

It seems the character % needs to be escaped. I tried
unit_of_measurement: "%"
and it is now working.

1 Like