REST / JSON attribute type

Helo,

Can you please advise how to tell HA JSON attribute is numeric ?

Generally all works well I can use custom cards component to draw charts etc but I believe HA thinks ‘Ballance’ attribute is string - not numeric

Why Im thinking so ? Because if Im clicking history it doesnt show graph line but just state-like boxes (see below)

I’ve added to config file REST sensor definition + template sensor - as follow:

sensor:
  - platform: rest
    name: BF
    resource: http://192.168.101.240:8000
    method: GET
    scan_interval: 600 
    value_template: 'OK'
    json_attributes:
    - Instruments_Count
    - Ballance
    - Avaiable
    - Margin
    - TS


template:
  - sensor:
    - name: "BF Ballance"
      state: '{{ states.sensor.bf.attributes["Ballance"]|float }}'

JASON :

{ "Instruments_Count": 7, "Ballance": -11607, "Avaiable": 160020, "Margin": 69862, "TS": "04-08-2022 18:10:08" } 

States in debug Tools:

My history looks like that:

All states are strings. What you are missing in your template sensor is to define unit_of_measurement which makes Home Assistant treat this as continuous values instead of discrete values.

1 Like

Thanks a lot - added it and now works as expected

obraz

1 Like