I am setting up a set of template sensors to do the calculation of hourly power prices including danish fees on top of the nordpool exchange prices fetched using https://github.com/MTrab/energidataservice:
I would love that my primary sensor energy_buy_prices_dkk_kwh would carry the current price as state but state is rendered before attributes and it a single value.
Furthermore I tried to set up attributes of sorted prices and average but learned there is no guarantee of the order the attributes are rendered.
The runtime costly and maintenance nightmare workaround is to split it in multiple sensors or re-render the prices for state and each attributes.
WTH can’t I render variables to be used for both state and all attributes in one go in one place (per sensor)? I should be able to reference pre-rendered {% set variable = ... %} from state and attributes templates or allow attribute templates to reference the set variables in the state template.