Boogaard53
(Rick Boogaard)
January 5, 2023, 7:50pm
1
I want to make a REST Sensor from the json from this link:
https://www.etoro.com/sapi/trade-data-real/live/public/portfolios?format=json&cid=21868134
I want to extract 4.007700 (netprofit) as a sensor in home assistant.
This config (and many many more tries) doesnt work
´´´´´´´´´´´´´´´´´´´´´´´´´´´
sensor:
´´´´´´´´´´´´´´´´´´´´´´´´´´
Ive been searching everywhere including this forum and the subreddit
but i cant find any help or info.
Can any of you help me?
Rofo
(Ro)
January 5, 2023, 8:08pm
2
I do something similar to get my bin collection days from my local council website:-
- platform: rest
name: bin_collection_restful
resource: some website here.
timeout: 15
scan_interval: 86400
json_attributes:
- label
- Results
value_template: 'OK'
- platform: template
sensors:
bin_collection_address:
value_template: '{{ states.sensor.bin_collection_restful.attributes["label"] }}'
recycling_collection_date:
value_template: >-
{% set recycling_date = states.sensor.bin_collection_restful.attributes["Results"].split('<br/>')[1].split('</em>')[0] %}
{{recycling_date}}
friendly_name: "Recycling Collection Date"
The reason I use splits is because the json ‘results’ section is actually a chunk of HTML.
you forgot the value_json part in your value_template
RESTful Sensor - Home Assistant (home-assistant.io)
You need to prepend json_value
to this:
value_template: "{{ json_value.AggregatedMirrors[0].NetProfit }}"
However, I did a quick try of the configuration, and getting an error HTML page as a response saying “You do not have access to www.etoro.com . The site owner may have set restrictions that prevent you from accessing the site.”