Hi fellow homeassistant users,
What I’m trying to accomplish might be an easy task for someone out there, unfortunately it is not for me (no programming skills whatsoever). I’ve been struggling for days with this and now it is time to call for help.
I’ve the coinbase integration setup and working. This gives me several sensors for all my crypto’s in HA.
I’ve made an template in configuration.yaml to convert the $ value of my wallet to € using the openexchangerate integration and this works fine.
This is my code for this:
- platform: template
sensors:
coinbase_eth_calc:
# unit_of_measurement: 'EUR' used to display 'EUR' after the amount
friendly_name: "Etherium wallet value in EUR"
value_template: "{{ '€%.1f '|format ( states('sensor.eth_exchange_rate')|float * states('sensor.coinbase_eth_wallet')|float * states('sensor.exchange_rate_sensor')|float|round(3) ) }}"
I’ve got several of these calculations setup for all my wallets and they all display the correct crypto wallet currency in euros, so far so good.
Now what I want to accomplish is, using Node-red, to calculate, basically creating a SUM, of all my wallets and present the total crypto value in euros of all my wallets combined in HA.
I use to have this functionality as a template in configuration.yaml but I want to move away from this because the file is getting to big and harder to maintain.
I’ve been struggeling with Node-red and I just cannot figure out how this can be done, I’m lost.
Here is my current Node-red flow:
[{"id":"7d2c9a3b.9bf0e4","type":"server-state-changed","z":"da17a502.c1aa28","name":"bat","server":"779066dc.805a78","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.coinbase_bat_calc","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":110,"y":2500,"wires":[["3e04d295.88b35e"]]},{"id":"3e04d295.88b35e","type":"change","z":"da17a502.c1aa28","name":"change","rules":[{"t":"change","p":"payload","pt":"msg","from":"€","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":".","fromt":"str","to":",","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":2500,"wires":[["df04dcff.defb3"]]},{"id":"df04dcff.defb3","type":"change","z":"da17a502.c1aa28","name":"","rules":[{"t":"set","p":"val1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":2500,"wires":[["56866998.fbf448"]]},{"id":"56866998.fbf448","type":"function","z":"da17a502.c1aa28","name":"add","func":"var val1 = parseInt(flow.get(\"val1\") || \"0\");\nmsg.payload = parseInt(flow.get(\"val2\") || \"0\") + val1;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":630,"y":2540,"wires":[["d506e47f.3a5a88"]]},{"id":"48a2d1b.0d2f23","type":"change","z":"da17a502.c1aa28","name":"","rules":[{"t":"set","p":"val2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":2560,"wires":[["56866998.fbf448"]]},{"id":"d506e47f.3a5a88","type":"debug","z":"da17a502.c1aa28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":2540,"wires":[]},{"id":"a69171d1.e8704","type":"change","z":"da17a502.c1aa28","name":"change","rules":[{"t":"change","p":"payload","pt":"msg","from":"€","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":".","fromt":"str","to":",","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":2560,"wires":[["48a2d1b.0d2f23"]]},{"id":"cf5ec7b.130ec38","type":"server-state-changed","z":"da17a502.c1aa28","name":"dai","server":"779066dc.805a78","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.coinbase_dai_calc","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":110,"y":2560,"wires":[["a69171d1.e8704"]]},{"id":"779066dc.805a78","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
But this gives me a value of 103, and this is not correct.
What am I doing wrong?