I have a rest response with an array per “channel” like this:
{% set value_json = {
"channels": [
{
"active": true,
"capacity": "150000",
"local_balance": "10",
"remote_balance": "147120",
"total_satoshis_sent": "0",
"total_satoshis_received": "10",
"local_chan_reserve_sat": "1500",
"peer_alias": "xyz",
},
{
"active": true,
"capacity": "100000",
"local_balance": "99026",
"remote_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"local_chan_reserve_sat": "1000",
"peer_alias": "abc",
}
]
} %}
With a script
{% set ns = namespace(bl=[]) %}
{% for i in value_json['channels'] %}
{% set ns.bl = ns.bl + [{'alias': i['peer_alias'], 'balance': (float(i['local_balance'])/float(i['capacity'])*100) | round(0)
}] %}
{% endfor %}
{{ ns.bl }}
I can get this output:
[
{
"alias": "xyz",
"balance": 0
},
{
"alias": "abc",
"balance": 99
}
]
How can I put that into configuration.yml ? Later on, I want a card to display that values (xyz = 0, abc = 99 and more) as gauge.