Hi I have the following template that calculates the cost of energy used, {{ (states(‘sensor.amicharge_today_s_consumption’) | float(0) * 0.085)}}, Can anyone advise how to replace the fixed 0.085 value with one that varies? The variable is the current rate sensor.octopus_energy_electricity_xxxxxxxx_xxxxxxxx_current_rate. Whatever I seem to do raises an error
{{ states('sensor.amicharge_today_s_consumption') | float(0) * states('sensor.octopus_energy_electricity_xxxxxxxx_xxxxxxxx_current_rate')|float(0) }}
Please format your templates for the forum in future. Saves a lot of time correcting “fancy” quotes.
apologies Tom, is there a guide for formatting? Regards Pete
Yep, this describes one way: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16
The other method is to highlight the config and press the </> button in the post toolbar. Sometimes this button is under the cog menu, like on small mobile displays.
1 Like