Comments (4)
Yes, your use case seems to reasonable.
Maybe something like below would suite your needs? That could be used as an automation condition to decide whether to turn on/off heating. You give start time, stop time and desired "rank" X. The code searches for Xth cheapest hour during the desired period and stores the price of that hour to variable "limit". And finally the code checks whether we are in currently in the desired time period and whether the current electricity price is lower than the limit found.
This way you don't need to calculate ranks for each hour and store the results of that. Maybe not the most elegant solution but this should give you needed tools to fulfill your use case. Please test this thoroughly as I just wrote the code quite quickly as an starting point for you.
{% set start = today_at("12:00") %}
{% set stop = start + timedelta(hours=6) %}
{% set rank = 3 %}
{% set limit = (state_attr('sensor.shf_data', 'data') | selectattr("Timestamp", "ge", start | as_timestamp) | selectattr("Timestamp", "lt", stop | as_timestamp) | sort(attribute="TotalPrice"))[rank]["TotalPrice"] %}
{{ now() > start and now() < stop and states('sensor.shf_electricity_price_now') | float < limit }}
from spotprices2ha.
Related Issues (20)
- beginner question HOT 3
- "sensor.shf_electricity_price_now" not working after HA update to 2023.5.0 HOT 14
- Average price Selected period HOT 5
- Negative energy prices + vat HOT 2
- shf_electricity_price_now sensor getting price from one hour ahead HOT 8
- Apexcharts not working HOT 1
- Electricity price in cents instead of euros HOT 16
- Night time price (SHF Price2) not working even though times are set HOT 3
- Ranking the hourly prices is not taking Price1 and Price2 into account HOT 10
- Breaks a lot on background HOT 6
- Yield overhead costs (selling electricity) HOT 3
- Visualization card size HOT 2
- rank-automation.yaml Blueprint fails with "TemplateSyntaxError: unexpected char '\\' at 1930" HOT 3
- UI screenshots in README not up to date(?) HOT 1
- Import blueprint unsupported url HOT 4
- HA 2023.12 re-importing (updating) blueprints HOT 3
- Add sensor for current electricity price without taxes HOT 1
- rank-automation.yaml doesn't work HOT 7
- SHF Control Factor +-1 throws DivisionByZero error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spotprices2ha.