Hi all,
I want add all the crypto’s into HA so I can use a input_select to get the right crypto to show in a graph.
i have 1 REST sensor that get every minute a JSON from my exchange broker.
Then I created now 220 template sensors like this one:
eur_bnb:
value_template: "ok"
attribute_templates:
buy: >-
{% set item = state_attr('sensor.bitladon_all', 'result') | selectattr('ticker', 'eq', 'BNB') | first %}
{{ item.buy }}
sell: >
{% set item = state_attr('sensor.bitladon_all', 'result') | selectattr('ticker', 'eq', 'BNB') | first %}
{{ item.sell }}
change24h: >-
{% set item = state_attr('sensor.bitladon_all', 'result') | selectattr('ticker', 'eq', 'BNB') | first %}
{{ item.change24h }}
volume24h: >-
{% set item = state_attr('sensor.bitladon_all', 'result') | selectattr('ticker', 'eq', 'BNB') | first %}
{{ item. volume24h }}
But I think this will be a bad performance on HA…
There was no other way to get all the crypto’s correct in HA even with template if scripts.
When you open this link: https://api.bitladon.com/markets/
You get the JSON list.
The sensor that I have contains this output in attributes:
result:
- name: 0x
ticker: ZRX
buy: '1.34213'
sell: '1.28434'
last: '1.30629'
change24h: '-4.94'
change72h: '0.47'
change168h: '-15.03'
volume24h: '13865.5294'
logo: 'https://www.bitladon.com/img/currency/ZRX.png'
eurovolume24h: '18609.34'
graph: 'https://www.bitladon.com/img/graphs/ZRXblue.png?v=1613899946'
- name: 1inch
ticker: 1INCH
buy: '4.41059'
sell: '4.21810'
last: '4.38181'
change24h: '-0.74'
change72h: '3.43'
change168h: '-7.13'
volume24h: '14617.7241'
logo: 'https://www.bitladon.com/img/currency/1INCH.png'
eurovolume24h: '64472.79'
graph: 'https://www.bitladon.com/img/graphs/1INCHblue.png?v=1613899946'
- name: Aave
ticker: AAVE
buy: '373.332'
sell: '357.131'
last: '371.482'
change24h: '-9.80'
change72h: '-5.67'
change168h: '-10.18'
volume24h: '113.3879'
logo: 'https://www.bitladon.com/img/currency/AAVE.png'
eurovolume24h: '42331.33'
graph: 'https://www.bitladon.com/img/graphs/AAVEblue.png?v=1613899946'
Is there a way to make this much efficient?
This card I use now this the many 220 sensors:
type: 'custom:apexcharts-card'
config_templates: bandwidth_chart
header:
title: ADA / EUR - Last 24 hours
series:
- entity: sensor.eur_ada
name: Buy
float_precision: 5
unit: EUR
group_by:
func: avg
duration: 5min
show:
extremas: true
attribute: buy
- entity: sensor.eur_ada
name: Sell
float_precision: 5
unit: EUR
group_by:
func: avg
duration: 5min
show:
extremas: true
attribute: sell