Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95387

Trouble with template sensors from restful sensor

$
0
0

@Da9L wrote:

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

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>