Trouble with template sensors from restful sensor

I have some trouble getting some JSON response into a card in my Lovelace

I have the following in my configuration yaml

sensor:
  - platform: rest
    name: totalkredit
    resource: http://cba.today/oilburner/scraping/totalkredit.php    
    json_attributes:
      - OneFive
      - One
      - ZeroFive        
    
sensor:
  - platform: template
    sensors:
      onefive:
        friendly_name: "1.5%"
        entity_id: sensor.totalkredit        
        value_template: "{{ state_attr('sensor.totalkredit', 'OneFive') }}"
      one:
        friendly_name: "1.0%"
        entity_id: sensor.totalkredit        
        value_template: "{{ state_attr('sensor.totalkredit', 'One') }}"
      zerofive:
        friendly_name: "0.5%"
        entity_id: sensor.totalkredit        
        value_template: "{{ state_attr('sensor.totalkredit', 'ZeroFive') }}"

The url in th rest sensor returns the following response:

{"OneFive":"99,1340","One":"94,2230","ZeroFive":"91.8890"}

And when i do not use the template sensor and only have the rest sensor in my config i can get the following from the totalkredit sensor

totalkredit

And as you can see it seems that it does get the attributes, but i just don’t know how to correctly get them out so that i can add them individually to a card :frowning: If i use the above template sensors i get the following

template_sensors

You have duplicate keys of ‘sensor:’

sensor:
  - platform: rest
    name: totalkredit
    resource: http://cba.today/oilburner/scraping/totalkredit.php    
    json_attributes:
      - OneFive
      - One
      - ZeroFive        
 
  - platform: template
    sensors:
      onefive:
        friendly_name: "1.5%"
        entity_id: sensor.totalkredit        
        value_template: "{{ state_attr('sensor.totalkredit', 'OneFive') }}"
      one:
        friendly_name: "1.0%"
        entity_id: sensor.totalkredit        
        value_template: "{{ state_attr('sensor.totalkredit', 'One') }}"
      zerofive:
        friendly_name: "0.5%"
        entity_id: sensor.totalkredit        
        value_template: "{{ state_attr('sensor.totalkredit', 'ZeroFive') }}"

Oh god you are right. I didn’t even notice. Thanks for pointing it out !

1 Like