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
Play a song with a 3D printer.

MIDI to GCODE Play a song with a FDM 3D printer. SLA printers don't have motors, so they cannot play music. Warning: Be ready to turn off the 3D print

Patrick 6 Apr 11, 2022
EuroPi: A reprogrammable Eurorack project based on the Raspberry Pi Pico

EuroPi The EuroPi is a fully user reprogrammable module based on the Raspberry Pi Pico, which allows users to process inputs and controls to produce o

Allen Synthesis 218 Jan 01, 2023
Quasi-static control of the centroid of quadruped robot

Quasi-static control of quadruped robot   This is a demo of the quasi-static controller for the centroid of the quadruped robot. The Quadratic Program

Junwen Cui 21 Dec 12, 2022
Universal Xiaomi MIoT integration for Home Assistant

Xiaomi MIoT Raw 简体中文 | English MIoT 协议是小米智能家居从 2018 年起推行的智能设备通信协议规范,此后凡是可接入米家的设备均通过此协议进行通信。此插件按照 MIoT 协议规范与设备通信,实现对设备的状态读取及控制。

1.9k Jan 02, 2023
Python library to interact with the GCE Electronics IPX800 device

A python library to control a GCE-Electronics IPX800 V4 device through its API.

Marc-Aurèle Brothier 2 Oct 20, 2021
Windhager myComfort custom component for Home Assistant

Windhager myComfort custom component for Home Assistant

5 Apr 27, 2022
DIY split-flap display

The goal is to make a low-cost display that's easy to fabricate at home in small/single quantities (e.g. custom materials can be ordered from Ponoko or similar, and other hardware is generally availa

Scott Bezek 2.5k Jan 05, 2023
Terkin is a flexible data logger application for MicroPython and CPython environments.

Terkin Data logging for humans, written in MicroPython. Documentation: https://terkin.org/ Source Code: https://github.com/hiveeyes/terkin-datalogger

hiveeyes 45 Dec 15, 2022
Modi2-firmware-updater - MODI+ Firmware Updater With Python

MODI+ Firmware Updater 실행 준비 python3(파이썬3.9 혹은 그 이상의 버전)를 컴퓨터에 설치 python3 -m pip

LUXROBO 1 Feb 04, 2022
HomeAssistant - Polyaire AirTouch 4 Integration

HomeAssistant - Polyaire AirTouch 4 Integration Custom integration to add an AirTouch 4 AC Controller Installation: Copy contents of custom_components

7 Aug 05, 2022
A python project based on a TV show Wheel of Fortune

Wheel-of-Fortune-using-Python Wheel of Fortune in python this game is the hands-on project in Python 3 Programming Specialization offered By Universit

Eszter Pai 1 Jan 03, 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
Sticklog2heatmap - Draw a heatmap of RC sticks from OpenTX logs or USB HID device

sticklog2heatmap Draw a heatmap of RC sticks from OpenTX logs or USB HID device

2 Feb 02, 2022
A Python script to monitor the latest block on an LCD.

PiHole-Monitoring A Python script to monitor the latest block on a lcd display. The first number represents the dns queries from the last 24h, the sec

Maxi 4 Dec 05, 2022
Sensor of Temperature Feels Like for Home Assistant.

Please ⭐ this repo if you find it useful Sensor of Temperature Feels Like for Home Assistant Installation Install from HACS (recommended) Have HACS in

Andrey 60 Dec 25, 2022
An emulated LED scoreboard for Major League Baseball ⚾

An LED scoreboard for Major League Baseball. Displays a live scoreboard for your team's game on that day.

Tyler Porter 8 Apr 08, 2022
Pure micropython ESP32 SPI driver for sdcard and screen at the same SPI bus

micropython-esp32-spi-sdcard-and-screen-driver Proof of concept of Pure micropython espidf SPI driver for sdcard with screen at the same SPI bus (exam

Thomas Favennec 7 Mar 14, 2022
Bucatini: a soft PIPE PHY for FPGA SerDes

Bucatini: a soft PIPE PHY for FPGA SerDes Bucatini is a noodly gateware layer capable of transforming an FPGA SerDes into a PIPE PHY, allowing you to

Great Scott Gadgets 28 Dec 02, 2022
A python file which I wrote to allow the Dorna Robots API to draw an Image on a 3D plane

Dorna-Robotics-Internship Code In the directory "Code" is a python file which I wrote to allow the Dorna Robots API to draw an Image on a 3D plane. I

Stephen Otto 2 Dec 06, 2021
Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless.

pylorawan Pylorawan is a Micropython wrapper for lorawan devices from RAK Wireless. Tested on a Raspberry PI Pico with a RAK4200(H) Evaluation Board (

Peter Houghton 3 Nov 04, 2022