Nordpool_diff custom integration for Home Assistant

Overview

nordpool_diff custom integration for Home Assistant

Requires https://github.com/custom-components/nordpool

Applies non-causal FIR differentiator1 to Nord Pool SPOT prices, resulting in predictive sensor that:

  • Gives positive output when electricity prices are going to increase in the next few hours
  • Gives negative output when electricity prices are going to decrease in the next few hours
  • Gives ~zero output when electricity prices are going to stay ~constant for the next few hours

The output can be used for e.g. adjusting target temperature of a heater so that it will heat more before prices will go up (to allow heating less when prices are high), and let the temperature go down a bit before prices will go down.

Apart from potentially saving some money, this kind of "temporal shifting of heating" can also save the environment, because expensive peaks are produced by dirtier energy sources.

Installation

  1. Install and configure https://github.com/custom-components/nordpool first.

  2. Copy the nordpool_diff folder to HA /custom_components/nordpool_diff/

  3. Restart HA. (Failing to restart before modifying configuration would give "Integration 'nordpool_diff' not found" error message from the configuration.)

  4. Add the following to your configuration.yaml file:

    sensor:
      - platform: nordpool_diff
        nordpool_entity: sensor.nordpool_kwh_fi_eur_3_095_024
        filter_length: 5

    Modify the nordpool_entity value according to your exact entity value.

    The filter_length value must be an integer, at least 2. Smallest possible value 2 produces FIR [-1, 1]. Value 5 produces FIR [-1, 0.25, 0.25, 0.25, 0.25]. First entry is always -1 and the filter is normalized so that its sum is zero. This way the characteristic output magnitude is independent of the filter length. Values larger than 8 have the problem that prices typically update 8 hours before midnight (in Finland), so at 15:59 you only know prices for the next 8 hours. But the filter algorithm pads missing data by using the last entry, so the result should still be quite reasonable.

  5. Restart HA again to load the configuration. Now you should see nordpool_diff_N sensor, where N corresponds to filter_length. You can set up several nordpool_diff entities, each with different filter_length.

Footnotes

  1. Fancy way of saying that the price for the current hour is subtracted from the average price for the next few hours.

Comments
  • ENTSO-E support

    ENTSO-E support

    Using Nord Pool API is a grey area. Technically it's public and appears to work so far without any tokens, but Nord Pool API documentation states If you are a Nord Pool customer, using our trading APIs is for free. All others must become a customer to use our APIs. which apparently means that almost nobody should be using it.

    Also https://github.com/custom-components/nordpool seems somewhat unmaintained and https://github.com/custom-components/nordpool/issues/125 remains unfixed and is hitting at least me regularly.

    ENTSO-E would be the correct place to fetch the prices from, and now (10/2022) there's also a HASS integration for that: https://github.com/JaccoR/hass-entso-e

    Add support. Then maybe we also need to consider "nordpool_diff" name. Should that be entsoe_diff?

    enhancement 
    opened by jpulakka 9
  • Using nordpool as a backup dosn't seem to work

    Using nordpool as a backup dosn't seem to work

    image

    2022-10-31 14:48:39.622 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.nordpool_diff_rank_10_normalize_max_min fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/nordpool_diff/sensor.py", line 139, in update prices = self._get_next_n_hours(self._filter_length + 1) # +1 to calculate next hour File "/config/custom_components/nordpool_diff/sensor.py", line 148, in _get_next_n_hours prices = _get_next_n_hours_from_entsoe(n, e) File "/config/custom_components/nordpool_diff/sensor.py", line 83, in _get_next_n_hours_from_entsoe if p := e.attributes["prices"]: KeyError: 'prices'

    image

    bug 
    opened by SVH-Powel 3
  • Daylight saving time

    Daylight saving time

    DST is probably not handled correctly right now. We just read "today" and "tomorrow" attributes (which are typically 24-element lists) from nordpool, and assume that there are 24 hours in day and thus dt.now().hour gives index to current hour in "today" list. Too many assumptions there. Possibly there will be 25 elements in the list when moving from summer to winter, and 23 elements in the opposite case.

    If EU gets rid of DST then this issue goes away without changing anything. Need to see to prioritize.

    bug wontfix 
    opened by jpulakka 2
  • Somewhat scale-free normalization

    Somewhat scale-free normalization

    Normalization made in https://github.com/jpulakka/nordpool_diff/issues/15 makes the result "totally scale-free", meaning that (when normalize: max_min is used) the output varies similarly no matter if the input varies between 1-2 cnt/kWh or 100-200 cnt/kWh.

    This works as planned - making the the output magnitude independent of current overall electricity price (variation). But this also doesn't feel quite right. When prices are very cheap, there's no need to optimize targets as heavily as when the prices are very expensive. Real-world nonlinearities (heat pump efficiency, heat leak) could turn unnecessary variation into an anti-optimization.

    Maybe "somewhat scale-free" normalization would be in place. So, the output wouldn't be linearly dependent of input scale, but it would still be somewhat dependent, so that 100-200 cnt/kWh variation would give bigger input than 1-2 cnt/kWh variation, but just not 100x bigger. Something to think about. Logarithmic dependency?

    enhancement 
    opened by jpulakka 1
  • [enhancement] Find next low point

    [enhancement] Find next low point

    Are no good message function in GitHub so writing this as a ticket for now, feel free to close it at any time.

    I was looking for how to find a way to plan electricity usage in the future by nordpool_diff but failed in the HA templates and scripts. But thought it would be easier to do it in native python inside the integration with all the raw data available. Started by forking your repo but soon realized it became an integration of it's own.

    Hope you don't mind me making a rather new integration from your work, I did put a disclaimer in the readme.md top to your integration but let me know if you disapprove.

    It's still seem to be some bugs in the code to resolve but it do seem to work (sometimes) If you like to, have a look at it https://github.com/dala318/nordpool_planner and if you find it useful feel free to include in nordpool_diff (or contribute in mine).

    question 
    opened by dala318 1
  • Added a hacs.json file and added info to the readme

    Added a hacs.json file and added info to the readme

    This makes the use of your plugin easier, especially keeping track of latest versions. Might get you started for #7 If you have other thoughts, don't feel sorry to decline. It's an awesome plugin!

    opened by robsonke 1
  • What happens if there is not enough prices?

    What happens if there is not enough prices?

    If i set it to 20 and there is only 15 ahead prices... What happens then? btw this seems good although i hardly understand it. btw2 i did not know where to wright this

    question 
    opened by flippz 1
  • New filter type: rank

    New filter type: rank

    Problem

    I have set up my water heater to only turn on if nordpool_diff_rectangle_10 > .66. However, on days with low price variation, this never occurs, so the water heater will never turn on.

    Solution

    If I additionally turn on the water heater if the prices is among the 2 lowest of the next 10 hours, it will also turn on when the (absolute) price variation is small.

    There is still a corner case left; when the price is slowly decreasing, so I think I will also have to turn it on if it has stayed off for more than 16 hours (say).

    Even though this new filter type is strictly not a FIR differentiator, the framework of retrieving prices was very handy to reuse for this filter, so I hope it is a welcome addition.

    opened by bnordli 1
  • Could be non-polling

    Could be non-polling

    Currntly we don't override should_poll property with False, and by default HA is polling us continuously. The good thing is that this works robustly, but maybe this isn't quite as beautiful as this could be. We should listen to nordpool state updates, and fire update only when needed, as described in https://developers.home-assistant.io/docs/core/entity/

    enhancement wontfix 
    opened by jpulakka 1
  • Upcoming hour(s) as attribute(s)

    Upcoming hour(s) as attribute(s)

    Just like nordpool offers upcoming data as "today"/"tomorrow" attributes, nordpool_diff could offer not only current hour "principal value", but also upcoming hour value(s).

    At least the next hour could be interesting when we're close to hour boundary and making decisions about turning something on; if it's xx:59, and next hour filter value is below some threshold, and we would like to avoid short "on" cycles, then we shouldn't turn the thing on at xx:59 if we would turn it off only after 1 minute. This can be avoided by taking the upcoming hour value into account.

    enhancement 
    opened by jpulakka 1
  • Triangular filter

    Triangular filter

    Currently the filter is "block-shaped", e.g.

    [-1, 1]
    or
    [-1, 0.5, 0.5]
    

    It's good default, very easy to understand ("price for the current hour is subtracted from the average price for the next few hours").

    Optionally, a triangular filter might be cool, something like

    [-1, 0.67, 0.33]
    or
    [-1, 0.5, 0.33, 0.17]
    

    Either right triangle (which corresponds to average of _diff_2..._diff_N, doesn't it?), or exponentially decaying, or...

    Maybe with this kind of filter we would combine virtues of short and long filters?

    (Could also be arbitrary, user-definable?)

    enhancement 
    opened by jpulakka 1
  • Padding options

    Padding options

    Currently if filter is longer than available data (e.g. filter length 15 and at 14:00 only 10 hours are available), data is padded using the last available element (typically 23-24 price). It might be better to pad using today after midnight data. Or the average between that and 23-24. Make this adjustable.

    enhancement 
    opened by jpulakka 0
Releases(v0.2.2)
  • v0.2.2(Nov 11, 2022)

    Introduced two "somewhat scale-free" normalization options sqrt_max and max_min_sqrt_max, https://github.com/jpulakka/nordpool_diff/issues/20

    Updated hass-entso-e default entity to sensor.average_electricity_price_today which is the only entity providing prices attribute in hass-entso-e v0.1.2+

    Compatible with https://github.com/JaccoR/hass-entso-e/releases/tag/v0.1.3-hotfix

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Oct 31, 2022)

    Improved error handling, using nordpool as entso-e backup works robustly now, https://github.com/jpulakka/nordpool_diff/issues/23

    Updated hass-entso-e default entity name.

    Compatible with https://github.com/JaccoR/hass-entso-e/releases/tag/v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Oct 30, 2022)

    ENTSO-E support https://github.com/jpulakka/nordpool_diff/issues/21 added.

    Compatible with https://github.com/JaccoR/hass-entso-e/releases/tag/v0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.5(Oct 1, 2022)

  • v0.1.4(Sep 17, 2022)

  • v0.1.3(Sep 9, 2022)

  • v0.1.2(Aug 31, 2022)

Owner
Joonas Pulakka
Joonas Pulakka
Repo for the esp32s2 version of the Wi-Fi Nugget

Repo for the esp32s2 version of the Wi-Fi Nugget

HakCat 30 Nov 05, 2022
Volta: A Virtual Assistant which increases your productivity with time as you use it…

Volta Official Documentation Overview & Purpose Volta: A Virtual Assistant which increases your productivity with time as you use it… Volta, developed

Abeer Joshi 1 Jan 14, 2022
🌱 - WebhookHard◞ Fines Educativos ◟

v1.0.0 WebhookHardware ¿Que es WebhookHardware? WebhookHardware se trata de un proyecto tratado para sacar informacion sobre el hardware de tus victim

3 Jun 14, 2021
Intel Realsense t265 into Unreal Engine

t265_UE Intel Realsense t265 into Unreal Engine. Windows only, and Livelink plugin is 4.26.2 only at the moment. Might recompile it for different vers

Bjarke Aagaard 30 Jan 02, 2023
PyTorch implementation of paper "MT-ORL: Multi-Task Occlusion Relationship Learning" (ICCV 2021)

MT-ORL: Multi-Task Occlusion Relationship Learning Official implementation of paper "MT-ORL: Multi-Task Occlusion Relationship Learning" (ICCV 2021) P

Panhe Feng 12 Oct 11, 2022
A python script for Homeassistant that counts down the days to birthdays, anniversaries etc

Date Countdown A python script for Homeassistant that counts down the days to birthdays, anniversaries etc Important note I no longer use homeassistan

Marc Forth 21 Mar 12, 2022
Simple Microservice to control 433Mhz wireless sockets over HTTP, e.g. on a RaspberryPi

REST-light is a simple microservice to control 433Mhz wireless sockets over HTTP, e.g. on a RaspberryPi. The main usage is an easy integration of 433M

Pascal Höhnel 1 Jan 09, 2022
PBA: Pleco Breeding Assistant

A small monitor that reports the external, fishroom and water change parameters to have suitable water parameters and induce breeding. These two features already represent 50% of the "reproductive su

Mirko Mancin 1 Jan 19, 2022
An alternative to Demise-Assistant-Batch made entirely in Python for more capabilities.

Demise-Assistant-Python An alternative to Demise-Assistant-Batch made entirely in Python for more capabilities. IMPORTANT NOTE Demise-Assistant-Batch

SkelOrganisation 1 Nov 24, 2021
CO2Ampel - This RaspberryPi project uses weather data to estimate the share of renewable energy in the power grid

CO2Ampel This RaspberryPi project uses weather data to estimate the share of ren

Felix 4 Jan 19, 2022
KIRI - Keyboard Interception, Remapping, and Injection using Raspberry Pi as an HID Proxy.

KIRI - Keyboard Interception, Remapping and Injection using Raspberry Pi as a HID Proxy. Near limitless abilities for a keyboard warrior. Features Sim

Viggo Falster 10 Dec 23, 2022
ModbusTCP2MQTT - Sungrow & SMA Solar Inverter addon for Home Assistant

ModbusTCP2MQTT Sungrow & SMA Solar Inverter addon for Home Assistant This addon will connect directly to your Inverter using Modbus TCP. Support model

Teny Smart 40 Dec 21, 2022
Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi).

Candy Home Assistant component Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi). This

Olivér Falvai 61 Dec 29, 2022
CircuitPython Driver for Adafruit 24LC32 I2C EEPROM Breakout 32Kbit / 4 KB

Introduction CircuitPython driver for Adafruit 24LC32 I2C EEPROM Breakout Dependencies This driver depends on: Adafruit CircuitPython Bus Device Regis

foamyguy 0 Dec 20, 2021
Connect a TeslaMate instance to Home Assistant, using MQTT

TeslaBuddy Connect a TeslaMate instance to Home Assistant, using MQTT. It allows basic control of your Tesla vehicle via Home Assistant (currently, ju

4 May 23, 2022
HACS gives you a powerful UI to handle downloads of all your custom needs.

HACS (Home Assistant Community Store) Manage (Install, track, upgrade) and discover custom elements for Home Assistant directly from the UI. What? HAC

HACS 3.2k Jan 04, 2023
Raspberry Pi Pico as a Rubber Ducky

Raspberry-Pi-Pico-as-a-Rubber-Ducky Kurulum Raspberry Pi Pico cihazınız için CircuitPython'u indirin. Boot düğmesine basılı tutarken cihazı bir USB ba

Furkan Enes POLATOĞLU 6 Dec 13, 2022
Python information display framework aimed at e-ink devices

My display, using a Raspberry Pi Zero W and Waveshare 6" e-paper hat infodisplay Modular information display framework aimed at e-ink devices. Built u

Niek Blankers 3 Apr 08, 2022
An open source two key macro-pad modeled to look like a cartoony melting popsicle

macropopsicle An open source two key macro-pad modeled to look like a cartoony melting popsicle. Build instructions Parts List -1x Top case half (3D p

17 Aug 18, 2022
Switch predictor for Home Assistant with AppDeamon

Home Assistant AppDeamon - Event predictor WORK IN PROGRESS - CURRENTLY NOT COMPLETE AND NOT WORK This is an idea under development (when I have free

37 Dec 17, 2022