Giter Site home page Giter Site logo

Comments (5)

tieskuh avatar tieskuh commented on July 19, 2024 2

The forecast prices are in an attribute of the current_electricity_tariff sensor.
Try this in the template editor:

{% set cheapest = state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') 
                  | selectattr('datetime', '>', utcnow().isoformat())
                  | sort(attribute='price')  
                  | first %}

{{ cheapest.price /10000000 }}
{{ cheapest.datetime }}

image

You can for example create a template sensor for the cheapest upcoming hour:

template:
  - sensor:
    - name: zonneplan_cheapest_hour
      state: >
        {% set cheapest = state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') 
                    | selectattr('datetime', '>', utcnow().isoformat())
                    | sort(attribute='price')  
                    | first %}
        {{ cheapest.datetime }}

Hope this helps.

from home-assistant-zonneplan-one.

rinseringma avatar rinseringma commented on July 19, 2024

Thanks! But somehow the date and price aren't the same as the Zonneplan app. But that has nothing to do with your script.

Two questions;

  1. Is there a way to limit the quantity of forecast hours to the upcoming, let's say, 10 hours instead of 24 hours?
  2. Is it possible to format the datetime stamp to only show the hour? And maybe calculate how many hours that is from the current time?

from home-assistant-zonneplan-one.

tieskuh avatar tieskuh commented on July 19, 2024

The price shown in the app is the lowest price of the current day (not taken in account the prices for the next day). I think that is why it's different.

You can do anything with the data you want.

For example, this will give you the next 10 hours:

{{ (state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') 
                  | selectattr('datetime', '>', utcnow().isoformat())
                  | sort(attribute='datetime'))
                  [:10] }}

Or the cheapest 10 hours:

{{ (state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') 
                  | selectattr('datetime', '>', utcnow().isoformat())
                  | sort(attribute='price'))
                  [:10] }}

And to only get the hour from the datetume you can use time functions: https://www.home-assistant.io/docs/configuration/templating/#time
For the example in my previous comment:

{% set cheapest = state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') 
                  | selectattr('datetime', '>', utcnow().isoformat())
                  | sort(attribute='price')  
                  | first %}

{{ cheapest.price /10000000 }}
{{ as_datetime(cheapest.datetime).hour }}

But I think these questions are not really in the right place. This is not an issue with this integration. I think you will find most answers to these questions in the community or feel free to send me a DM.

from home-assistant-zonneplan-one.

tieskuh avatar tieskuh commented on July 19, 2024

@fsaris Maybe you can enable discussions on your repository for these kind of questions

from home-assistant-zonneplan-one.

fsaris avatar fsaris commented on July 19, 2024

Done https://github.com/fsaris/home-assistant-zonneplan-one/discussions

from home-assistant-zonneplan-one.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.