Coder Social home page Coder Social logo

mampfes / ha_epex_spot_sensor Goto Github PK

View Code? Open in Web Editor NEW
45.0 2.0 4.0 89 KB

Provides helper sensors for EPEX Spot integration.

License: MIT License

Python 100.00%
awattar epex epex-spot hacs hacs-integration home-assistant homeassistant smard

ha_epex_spot_sensor's Introduction

EPEX Spot Sensor

This component is an addition to the EPEX Spot integration.

EPEX Spot Sensor add one or more binary sensors which can be configured to turn on at the cheapest or most expensive time interval of the day. The length of the time interval can be configured, as well as whether the interval shall be used contiguously or intermittently.

Helper Sensor

If you like this component, please give it a star on github.

Installation

  1. Ensure that HACS is installed.

  2. Open HACS, then select Integrations.

  3. Select โ‹ฎ and then Custom repositories.

  4. Set Repository to https://github.com/mampfes/ha_epex_spot_sensor
    and Category to Integration.

  5. Install EPEX Spot Sensor integration via HACS:

    Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

    If the button doesn't work: Open HACS > Integrations > Explore & Download Repositories and select integration EPEX Spot Sensor.

  6. Add helper(s) provided by EPEX Spot Sensor to Home Assistant:

    Open your Home Assistant instance and start setting up a new helpers.

    If the button doesn't work: Open Settings > Devices & services > Helpers > Create Helper and select EPEX Spot Sensor.

In case you would like to install manually:

  1. Copy the folder custom_components/epex_spot_sensor to custom_components in your Home Assistant config folder.

  2. Add helper(s) provided by EPEX Spot Sensor to Home Assistant:

    Open your Home Assistant instance and start setting up a new helpers.

    If the button doesn't work: Open Settings > Devices & services > Helpers > Create Helper and select EPEX Spot Sensor.

Configuration Options

  1. Earliest Start Time
    Earliest time to start the appliance.

  2. Latest End Time
    Latest time to end the appliance. Set it to same value as earliest start time to cover 24h. If set to smaller value than earliest start time, it automatically refers to following day.

  3. Duration
    Required duration to complete the appliance.

  4. Remaining Duration Entity
    Optional entity which indicates the remaining duration. If entity is set, it replaces the static duration. If the state of the Remaining Duration Entity changes between Earliest Start Time and Latest End Time, the configured Earliest Start Time will be ignore and the latest change time of the Remaining Duration Entity will the used instead.

  5. Price Mode
    Selects whether the sensor shall react on the cheapest or the most expensive prices between Earliest Start Time and Latest End Time.

  6. Interval Mode
    Selects whether the specified duration shall be completed in a single, contiguous interval or can be split into multiple, not contiguous intervals (intermittend).

Sensor Attributes

  1. Earliest Start Time
    Reflects the configured Earliest Start Time.

  2. Latest End Time
    Reflects the configured Latest End Time.

  3. Duration
    Reflects the used value for duration, which is either the configured duration if the Remaining Duration Entity is not set; or the state of the Remaining Duration Entity.

  4. Remaining Duration Entity
    Optional entity which indicates the remaining duration. If entity is set, it replaces the static duration.

  5. Interval Start Time Reflects the actual start time of the interval, which is either the configured Earliest Start Time or the latest change time of the Remaining Duration Entity if the state of the entity changed between Earliest Start Time and Latest End Time.

  6. Price Mode
    Reflects the configured Price Mode.

  7. Price Mode
    Reflects the configured Interval Mode.

  8. Enabled
    Set to true if current time is between Earliest Start Time and Latest End Time.

  9. Data
    List of calculated intervals to switch sensor on, consisting of start_time, end_time and rank (for Interval Mode intermittend only).

ha_epex_spot_sensor's People

Contributors

mampfes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ha_epex_spot_sensor's Issues

Error while dispatching event for sensor.epex_spot_data_net_price

Logger: homeassistant.helpers.event
Source: helpers/event.py:296
First occurred: 13:54:32 (1 occurrences)
Last logged: 13:54:32

Error while dispatching event for sensor.epex_spot_data_net_price to <Job track state_changed event ['sensor.epex_spot_data_net_price'] HassJobType.Callback <function BinarySensor.init..async_price_sensor_state_listener at 0x7f79aaaca0>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 296, in _async_dispatch_entity_id_event
hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 691, in async_run_hass_job
hassjob.target(*args)
File "/config/custom_components/epex_spot_sensor/binary_sensor.py", line 174, in async_price_sensor_state_listener
_on_price_sensor_state_update()
File "/config/custom_components/epex_spot_sensor/binary_sensor.py", line 167, in _on_price_sensor_state_update
self._update_state()
File "/config/custom_components/epex_spot_sensor/binary_sensor.py", line 241, in _update_state
self._update_state_for_contigous(earliest_start, latest_end, now)
File "/config/custom_components/epex_spot_sensor/binary_sensor.py", line 294, in _update_state_for_contigous
marketdata = get_marketdata_from_sensor_attrs(self._sensor_attributes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot_sensor/util.py", line 51, in get_marketdata_from_sensor_attrs
return [Marketprice(e) for e in data]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot_sensor/util.py", line 51, in
return [Marketprice(e) for e in data]
^^^^^^^^^^^^^^
File "/config/custom_components/epex_spot_sensor/util.py", line 21, in init
raise KeyError()
KeyError

How to use EPEX SPOT SENSOR in an automation?

Hi Steffen,

I was able to install EPEX SPOT SENSOR successfully, and the sensor works fine.

But I struggle when using the sensor in a simple automation with a call service switch toggle on/off for a relay.
The relay turns on/off when the sensor 'Enabled' -attribute changes from 'false' to 'true', instead of following the sensor 'Data' -attributes start and end times.

I don't see what I'm doing wrong.
Would you please help me with this?

Below is the information about the sensor and the automations I made.

Thanks in advance for your help.

Kind regards,
Wim

image

image

image

Feature Request: Support for two different tariffs (Feed-in tariff and purchase tariff)

Hi,
so far your sensor add-on really works great!

Feature request:
I think many people that use your integration will have a pv panel installation. For example I have a different feed-in tariff and purchase tariff and created two helpers for it:

  • sensor.my_gross_purchase_tariff = sensor.epex_spot_data_net_price (configured with an absolute surcharge of 1.2 ct /kWh and Tax 20%).
  • sensor.my_gross_feed_in_tariff = sensor.epex_spot_data_price / 10 * 1.2

(both in ct/kWh)

Now I tried to solve that with a helper that combines both tariffs, that changes if I currently have PV surplus electricity:
sensor.my_gross_combined_price =
{% if states('sensor.mySmartmeter_total_power_togrid') | float > 5 %}
{{ states('sensor.my_gross_feed_in_tariff') }}
{% else %}
{{ states('sensor.my_gross_purchase_tariff') }}
{% endif %}

So the value of the sensor.my_gross_combined_price helper switches from sensor.my_gross_purchase_tariff to sensor.my_gross_feed_in_tarif if I am currently feeding in more than 5 Watts into the grid.

This basically works but unfortunately I can not use my sensor.my_gross_combined_price as a Price Input Sensor for your ha_epex_spot_sensor. The reason is, I guess, that my combined price sensor only contains data about the present and no attributes for the future.

So I guess we need a different approach here. My proposal would be, that you add the following fields to the configuration of your EPEX Spot Binary Sensor:

grafik

Could you implement this?
Or is there a more elegant way to achieve my goal?
thank you very much!

Can not add helper

Hello, I cannot add the helpers with the link.

Does anyone have the same problem ?

(This integration does not support configuration via the UI. If you followed this link from the Home Assistant website, make sure you are running the latest version of Home Assistant.)

No Remaining Duration Entity

Hello, I would like to use an external sensor for the duration of my washing machine's program at the best price. My washing machine provides the value for the running time of the program with this sensor sensor.washer_dryer_remaining_time but unfortunately I cannot select this sensor in the epex spot entity integration. only the following message appears: no matching entities found. Do you have a hint for me to do this correctly?

Another Helper Entity for Start and End-times?

Hey there,

thanks for the addon. i really like the idea and i think it could actually save me a lot of hassle for what i want to do. Though i am not 100% sure if i am able to archive what i want to do with this addon or if i need to think about it differently anyway.

So here it is: i have a simple and dumb home but now with smartmeter and power delivery paid by the hour. i would like to physically display when the next period for the cheapest prices would be. (ESP, MQTT, a nice display. That thing will live on top of my washing machine :) ) i never really found a straight forward way to display the upcoming TIME for the cheapest price.
Your addon makes this possible but only has a binary sensor for internal automations, but i don't think i have any possibility to display the actual TIME when the binary sensor will be set to ON.
Is there a simple way to pull this data from your sensor, or could you maybe add another entity which always displays the next time and date for the cheapest prices?

thanks so much!

Sensor doesnt turn off if input number is changed

First, I like the add on of input numbers for duration, before I missed it ๐Ÿ˜‰๐Ÿ‘๐Ÿป
If the duration via input number (interval mode: intermittent) is reduced while the sensor is on, it doesn't Turn off immediately. Even if the cheapest hour is 4 hours ago and I reduce the time to 1, it is not working. If wanted I have to delete the alternative duration entity, then it stops. Thanks for your efforts โ˜บ๏ธ๐ŸŒž

Request - Allow to configure a "pause" between Time Intervals

Hi,

i have a question / feature request and i hope it is understandable.

My problem: I have an water heater in my apartment, which needs about 1-2 hours every 12 hours to completely heat all my water.
What i want to achieve, i want to heat the water dynamically every 6-12 hours for 2 hours with the cheapest price. It does not need to be exactly every 12 hours.

When i configure the sensor for 24 hours (12 AM to 12 AM) it is possible that the 4 hours are Contiguous if they are the cheapest.
If i create 2 different 12h sensors with 2 hours intervals, i would again could end with a 4hour contiguous session. I could limit the time windows more, but then i could miss the cheapest prices.
I think the best way at the moment would be i configure 4* 6hour sensors with 1h intervals. So i could split it in more or less the best way, but i could still end with more expensive prices and it makes the setup more complicated.

Maybe someone have an idea how to configure this or if it would be possible to configure in the plugin.

Helper attributes start & end times are no longer correct

Epex Spot v2.3.5
Epex Spot Sensor v1.2.1
Time zone
(GMT+01:00) Brussels
Country
Belgium

Hi Steffen @mampfes , my helper was in status 'unknown' (after it did a perfect job for several months) and release 1.2.1 indead fixed this issue. However the attributes seems not to be correct any more. See start & end times in the screenshots below.
02/04 21:00 and 03/04 02:00 is not the cheapest time window.
Do you have any idea what could be wrong and how to correct it?

Screenshot 2024-04-02 230041
Screenshot 2024-04-02 225932

Originally posted by @WimDeceuninck in #14 (comment)

Update 04/04: I have deleted the helpers and created a new ones again, but the issue remains. I guess this has something to do with the winter/summer time change of last 31st of March?
Anyway, I don't know how I can fix this. Your help is much appriciated!
Thanks in advance!
Screenshot 2024-04-04 212459
Screenshot 2024-04-04 212434

Feature request: Flexible duration -> flexible start time?

Hi mampfes!

Thanks for #12 !

My use case:
PV charged my home battery to x %. I know, that I need ~y % per hour.
So, I can calculate duration. Let say 15h my battey can last.
Epex Spot sensor gets this 15h to calculate times to discharge the battery (at highest prices starting 15:00 and ending 10:00 next day)
Works as expected.
But, the calculation=duration changes with state of charge because the battery discharges at highest price as expected.
now we have 23:00, duration dropped to 8h. And your sensor calculates new times, but also for already passed times:
image
My expectation is: 8h should be counted from now (and not from 15:00) until 10:00
But now I go sleep, and the SoC will not drop so fast -> duration can increase again, but this will not realy help if the past high prices will be counted.

So, my feature request is: start time can set to "now" if flexible duration is used

EDIT: my heat pump discharged the battey, and now only 6h are "left", but the sensor will get 2h only (7:00 - 9:00):
image

Expectation would be from now on:
23:00-1:59 and 6:00-9:59
image
image

EDIT2: it is morning, 29th of Feb.... 28th doen't help me anymore... hm:
image

Use list of calculated intervals

Hello, I would like to access the information from the sensor that tells me when the most favorable time period is. I want to start my washing machine at the best time and want to know immediately via text to speech when the washing program will be finished. Unfortunately, I can't find the information to read this data from the epex spot sensor anywhere. Can you give me an example of how to use the most favorable time of the current day + time?

Here is a screenshot of the information:

grafik

Spot sensor Status Unknown

I find your addition to EPEX Spot usefull and looking forward to use it.
Issues with Latest End Time setting smaller than earliest start time.

Latest time to end the appliance. Set it to same value as earliest start time to cover 24h. If set to smaller value than earliest start time, it automatically refers to following day.

When doing so, the status becomes unknown.

ps: setting the same time for both only works when both set to 12:00:00 AM.

Wrong entity state change

Hello, I noticed today that the epex spot sensor predicted that 11:23 would be the best time to turn on my washing machine, but the washing machine was not started until 12:00 because the sensor's attribute was not set to true until 12:00. In my opinion, the washing machine should have turned on at 11:23. Have I configured something wrong or is there a mistake in the code?

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.