Open ThorAlex87 opened 1 day ago
Not sure what the issue is but you may want to look into using the new sensor: ' Current Percentage in electricity price range' As this sensor can immediately be used to turn on/off some devices using simple automations without complex templates
Thanks for the tip, I'll look into it. Are there any examples of automations for this anywhere?
I'm using automation like this
alias: EV charge on description: At the lowest price during the night or day triggers:
I think it would be helpful for a lot of people to have this documented in the documentation. Using it like that would also be a more robust solution than the template you have because the template you have uses the position of the price to determine what prices belong to today/tomorrow.
I setup a test of the percentage sensor yesterday with a modified version of my water heater automation switching a "dummy" boolean and have already run into a major problem. I set the threshold to 20%, that would give 6 hours of runtime yesterday, but today that will maybe two hours... That is no good for a water heater, I'll need something that gives a reliable minimum runtime every day. So I'll need something like "x number of hours with lowest percentage", and I'm right back to templates like above. Unless there is a really easy way to do that that I'm missing?
Back on topic: All the templates failed again tonight, but recovered after the automatic reboot I set up as a temporary fix.
Turning on your heater can be done when price gets below 20% of the price range of that day
Turning off your heater can be easily done with standard automations:
Only using the price-percentage-in-range to steer your heater would have give you the below in the NL (using 20%-40%)
ps. Of course you can add other conditions in your automation script to limit runtime, set time-of-the-day, net-power-consumption-in-household, etc
Does your sensor always use the full range from 0% to 100% every day? Mine does not, and right now has not been under 20% for almost 30 hours... Seems a bit weird?
The percentage, min, max, avg sensors are dependent on the analysis window (calculation_mode) configured in your device. When you use the sliding mode the analysis window extends from the current hour till the last data fetched. When you use rotation the analysis is based on todays values. In case of publish the analysis is based on all data, including historical.
I suggest top put your calculation_mode on rotation and see what the curve is.
Personally I'm using the mode sliding-12, which is a new functionality in pull request #197. You can install this branch to have the same functionality. See for more details on this in issue #194
To know what data is missing you would need to look at the attributes of the 'sensor.strompriser_entso_e_nettleie_average_electricity_price_today' entity. Copy and paste here a version from when the template is broken and then also a version after reboot when it works again.
Here's the current attribute, while tamplates are working after the auto reboot last night. I'll update tomorrow morning if it's broken again, and I'v turned off the reboot so I can get broken data.
Prices today
@Pluimvee I've changed to rotation and the graph so far looks more promesing! I'll keep experimenting with this, thanks for the help so far!
Hi!
First: Not a programmer or IT guy, can copy/paste code and do minor modifications but that's as far as my understanding of this goes...
Not sure if this is a problem with how my templates are written, or if there is an issue with the integration after the problems lately...
So I have these templates that turn on a sensor during the x number of cheapest hours during the day, that my automations use to choose when to run devices. These worked well for a long time, but after the update to 6.1 they are broken, and despite all being variations of the same they seem to break in a couple off different ways... I've tried the 6.3 beta, seems to make no difference. They all seem to break at midnight, and work again after a restart.
This one just stays at "false" and never becomes true even when it should be. ` - platform: template sensors: billigste_4_timer_entsoe_offpeak: value_template: >- {% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[14:15]|list
This one becomes unavailable at midnight, but becomes available again at 13:00. Seems to work as intended from then and until it breaks again at the next midnight. ` - platform: template sensors: billigste_8_timer_entsoe_offpeak: value_template: >- {% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[14:15]|list
In total I have 8 of these in different variations, they all break in one of those two ways.
I found this in the logs, this is after installing 6.3-beta1:
2024-10-08 00:00:00.446 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 6 when rendering '{% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[14:15]|list + state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[19:29]|list + state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[32:38]|list ) |sort (attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[0].time) and t <= as_datetime(l[0].time) + timedelta(hours = 1)) or (t >= as_datetime(l[1].time) and t <= as_datetime(l[1].time) + timedelta(hours = 1)) or (t >= as_datetime(l[2].time) and t <= as_datetime(l[2].time) + timedelta(hours = 1)) or (t >= as_datetime(l[3].time) and t <= as_datetime(l[3].time) + timedelta(hours = 1)) or (t >= as_datetime(l[4].time) and t <= as_datetime(l[4].time) + timedelta(hours = 1)) or (t >= as_datetime(l[5].time) and t <= as_datetime(l[5].time) + timedelta(hours = 1)) or (t >= as_datetime(l[6].time) and t <= as_datetime(l[6].time) + timedelta(hours = 1)) or (t >= as_datetime(l[7].time) and t <= as_datetime(l[7].time) + timedelta(hours = 1)) }}' 2024-10-08 00:00:00.446 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: list object has no element 6') while processing template 'Template<template=({% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[14:15]|list + state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[19:29]|list + state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[32:38]|list ) |sort (attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[0].time) and t <= as_datetime(l[0].time) + timedelta(hours = 1)) or (t >= as_datetime(l[1].time) and t <= as_datetime(l[1].time) + timedelta(hours = 1)) or (t >= as_datetime(l[2].time) and t <= as_datetime(l[2].time) + timedelta(hours = 1)) or (t >= as_datetime(l[3].time) and t <= as_datetime(l[3].time) + timedelta(hours = 1)) or (t >= as_datetime(l[4].time) and t <= as_datetime(l[4].time) + timedelta(hours = 1)) or (t >= as_datetime(l[5].time) and t <= as_datetime(l[5].time) + timedelta(hours = 1)) or (t >= as_datetime(l[6].time) and t <= as_datetime(l[6].time) + timedelta(hours = 1)) or (t >= as_datetime(l[7].time) and t <= as_datetime(l[7].time) + timedelta(hours = 1)) }}) renders=480>' for attribute '_state' in entity 'binary_sensor.billigste_8_timer_entsoe_offpeak' 2024-10-08 00:00:00.447 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[32:40]|list ) |sort (attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[0].time) and t <= as_datetime(l[0].time) + timedelta(hours = 1)) or (t >= as_datetime(l[1].time) and t <= as_datetime(l[1].time) + timedelta(hours = 1)) }}' 2024-10-08 00:00:00.447 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: list object has no element 0') while processing template 'Template<template=({% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[32:40]|list ) |sort (attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[0].time) and t <= as_datetime(l[0].time) + timedelta(hours = 1)) or (t >= as_datetime(l[1].time) and t <= as_datetime(l[1].time) + timedelta(hours = 1)) }}) renders=480>' for attribute '_state' in entity 'binary_sensor.billigste_2_timer_entsoe_dag' 2024-10-08 00:00:00.447 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[32:40]|list ) |sort (attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[0].time) and t <= as_datetime(l[0].time) + timedelta(hours = 1)) or (t >= as_datetime(l[1].time) and t <= as_datetime(l[1].time) + timedelta(hours = 1)) or (t >= as_datetime(l[2].time) and t <= as_datetime(l[2].time) + timedelta(hours = 1)) or (t >= as_datetime(l[3].time) and t <= as_datetime(l[3].time) + timedelta(hours = 1)) }}' 2024-10-08 00:00:00.447 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: list object has no element 0') while processing template 'Template<template=({% set l= ( state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[32:40]|list ) |sort (attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[0].time) and t <= as_datetime(l[0].time) + timedelta(hours = 1)) or (t >= as_datetime(l[1].time) and t <= as_datetime(l[1].time) + timedelta(hours = 1)) or (t >= as_datetime(l[2].time) and t <= as_datetime(l[2].time) + timedelta(hours = 1)) or (t >= as_datetime(l[3].time) and t <= as_datetime(l[3].time) + timedelta(hours = 1)) }}) renders=480>' for attribute '_state' in entity 'binary_sensor.billigste_4_timer_entsoe_dag' 2024-10-08 00:00:00.448 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 23 when rendering '{% set l=state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[14:38]|sort(attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[23].time) and t <= as_datetime(l[23].time) + timedelta(hours = 1)) or (t >= as_datetime(l[22].time) and t <= as_datetime(l[22].time) + timedelta(hours = 1)) or (t >= as_datetime(l[21].time) and t <= as_datetime(l[21].time) + timedelta(hours = 1)) or (t >= as_datetime(l[20].time) and t <= as_datetime(l[20].time) + timedelta(hours = 1)) }}' 2024-10-08 00:00:00.448 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: list object has no element 23') while processing template 'Template<template=({% set l=state_attr('sensor.strompriser_entso_e_nettleie_average_electricity_price_today', 'prices')[14:38]|sort(attribute='price') %} {% set t = now() %} {{ (t >= as_datetime(l[23].time) and t <= as_datetime(l[23].time) + timedelta(hours = 1)) or (t >= as_datetime(l[22].time) and t <= as_datetime(l[22].time) + timedelta(hours = 1)) or (t >= as_datetime(l[21].time) and t <= as_datetime(l[21].time) + timedelta(hours = 1)) or (t >= as_datetime(l[20].time) and t <= as_datetime(l[20].time) + timedelta(hours = 1)) }}) renders=480>' for attribute '_state' in entity 'binary_sensor.dyreste_4_timer_entsoe'
This is in Norway NO3.
I can't really make sence of this, but hopefully someone can help me fix this!
Edit: Forgot to add, I suspect this might be related to the Belgium issues but I looked at the data and could not f8nd anything off... But I might be missing what to look for.