Templating and stuff with exchange rate for more unsupported currencies ratios

Im sure there is a way to do what i want, i just dont know it yet, but you might!

i use the “open exchange rate” integration, to display the rats for some of the currencies i use daily, however, i am interested in some more “complex” calculation, to display more ratios than the integration gives (to my knowledge), as this integration take USD as base for all currencies ratios.

so… i want to use a template to extract the ratio of some certain rates, do some calculation with basic math, to show the solution of the new equation as a new entity (or new exchange ratio).

example:
the integration shows the state of the EUR to USD as:
‘sensor.open_exchange_rates_usd_eur’ with state of 0.91

and the state of GBP to USD as:
‘sensor.open_exchange_rates_usd_gbp’ with state of 0.78

the following equations will give me the ratio i need directly between the two:

(1/‘sensor.open_exchange_rates_usd_eur’)/(1/‘sensor.open_exchange_rates_usd_gbp’)

or

‘sensor.open_exchange_rates_usd_gbp’/‘sensor.open_exchange_rates_usd_eur’

im sharing my thoughts as i believe more ppl will benefit from them, as we all come from different countries, and might not have local integrations to properly show their home country currency of choice - as in my case.
this will allow everyone who needs it, to properly calculate their currency of choice.

could anyone pls show the proper template for this?
cheers!

ok, i think i got it.

this is the template that works for me:

{{ ((states('sensor.open_exchange_rates_usd_eur')|float) / (states('sensor.open_exchange_rates_usd_gbp')|float)) }}

the rest of the work is just creating a “template helper” and pasting that in.
give it a name, and a “measure” unit. and that it.

hope this help others in my situations

cheers

I think that gives you a reasonable indication, but not one that any bank will provide, because that is not how banks get exchange rates.
You have been using this for a while. Does it meet your expectations? (Have you ever or regularly tested the calculated rates with the ones you can find from your own bank?)

hey
its working fine for me. im not invested in a way that every cent counts, i just wanted some base indication at a glance, to calculate foreign exchange rates for online purchases with different currencies.
never checked the “math” of it against formal bank rates.
hope this helps
cheers