I’ve been searching for how to copy the following sensor and add to its values. The source sensor contains electricity prices for the day and tomorrow in an array each. As the values here do not include energy tax and transfer costs I’d like to make a copy of this sensor that includes these. The energy tax and transfer cost are available in other sensors. This is how the source sensor data looks like. Tomorrow is empty but populates the same way once prices are available.
What I’ve tried to do is to create a Trigger Template Sensor that in the value block copies the attributes and then tries to loop through them to increment. What doesn’t work is that I can’t seem to modify the values. I have played around in the template dev tool and am getting a namespace error along the lines of the variable I’m trying to assign not being a member of the namespace. I think that should not be nescesarry as the variable I want to edit is available there to read already.
Here is a start as a sensor
- trigger:
- platform: state
entity_id: sensor.tibber_prices
sensor:
- name: tibber_prices_with_fees
state: >
{{ trigger.to_state }}
attributes:
Today: >
{% set todays_prices = state_attr('sensor.tibber_prices', 'today') %}
{% for hour in todays_prices %}
{% set hour['total'] += states('sensor.energy_and_tax') %}
{% endfor %}
{{ todays_prices }}
Maybe this will help, I am updating a reference sensor for forecast so I can check how much it deviates throughout the day. It uses the HACS script that you can find on HACS/automations
@vingerha thanks for your reply. I have looked in HACS automations for hass_entities or something matching attributes but came up empty handed. I also do not understand how your sensor has multiple values (array). It seems from the code you posted there is only one entry under the result attribute?
You must use a namespace as in my post above. The inside of the for loop is a different scope to the outside, so your attempt to extend the array fails.
I really like how clean this looks! Very readable. I just got it working by @Troon 's example but I may just refactor and try your solution for how nice it looks. Thanks!
Hi How does your “input_number:el_transfer-cost” looks like , i have as you Tibber and EON, but currently just have various simple Templates, in a simple view. For current and used energy.
I don’t know how often EON changes their “transfer-costs” and subscription-price(which i just added in “Total Cost - Month” ), but been thinking of an “input-entity”
Hi
Not sure what you mean with how the input_number looks. It’s just a helper declared either in the GUI or yaml. I am not getting the fees with any automation if that’s what you mean but enter them manually. I tend to look at the last bill and correct if needed. Of course, then I’m a month off if anything changes, but don’t know any better way currently to figure it out. Maybe the information is available somewhere online and a scraper could be used to fetch it. That’s a future project however. haven’t actually googled to see if there is an easy way already available.
OK, i thought you maybe had an “input_number” with some template(fetching it), and had your subscription cost included also (“divided” in some way, i.e down to per/Kwh level), and yes the info is available on EON’s website
either login: https://www.eon.se/el/elnat/kostnad#/customer
Or download a “general” pdf https://www.eon.se/el/elnat/avgift#elnatsavgifter
In both you’ll informed about the covering period, but who knows how companies like EON act, sometimes they “figure” out that they have to squeeze a little extra out of peoples wallet
( And as i have auto-giro, i never look at my bills )
So actually, half of your equations is a bit over-worked , as the 2 manually input_number.*** , entities, is just 1 sum ( currently 1.1135/for 16A, in area 4) … the rest of the year, cording to EON’s current “ideas/need”
PS: if you are using very little Kwh ( i.e 300 Kwh a month And your monthly subscr-price is 181.25 you could/should add 0.6 per/Kwh(181.25 / 300kwh ), seems to me as an essential “sum” in such a forecast
I.e
electricity price. including fee + tax / per Kwh = 0.25
Transfercost + energy price+ tax / per Kwh = 1.1135
Subscr price for using 300Kwh/M / per Kwh = 0.6
One way to consider could be to use a changedetect.io container to fetch the data. I’m just starting to play with this tool myself but haven’t had enough time to get anything working with HA just yet.
And i hardly mentioned this, before the NEWS presented the “soon coming” increased transfer/energy cost, or was it Subscription cost , they are incredible