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
Simple python3 implementation of microKanren with lots of type annotations for clarity

MicroKanren-py This is (yet another) python implementation of microKanren. It's a reasonably 1:1 translation of the code provided in the paper, but ev

Erik Derohanian 3 Dec 10, 2022
Aqara Camera G3 integration for Home Assistant

Aqara Camera G3 integration for Home Assistant ATTENTION: The component only works after enabled telnet. Only supportd stream. Not support still image

14 Dec 18, 2022
Scapy: the Python-based interactive packet manipulation program & library. Supports Python 2 & Python 3.

Scapy Scapy is a powerful Python-based interactive packet manipulation program and library. It is able to forge or decode packets of a wide number of

SecDev 8.3k Jan 08, 2023
Using a raspberry pi, we listen to the coffee machine and count the number of coffee consumption

A typical datarootsian consumes high-quality fresh coffee in their office environment. The board of dataroots had a very critical decision by the end of 2021-Q2 regarding coffee consumption.

dataroots 51 Nov 21, 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
A LiteX project which builds a SoC with DRAM / HDIM output via the GPDI SYZYGY addon.

ButterStick GPDI LiteX demo A LiteX project which builds a SoC with DRAM / HDIM output via the GPDI SYZYGY addon. Getting started Connect GPDI board t

4 Nov 21, 2021
Component for deep integration LedFx from Home Assistant.

LedFX for Home Assistant Component for deep integration LedFx from Home Assistant. Table of Contents FAQ Install Config Performance FAQ Q. What versio

Dmitry Mamontov 28 Dec 13, 2022
Segger Embedded Studio project for building & debugging Flipper Zero firmware.

Segger Embedded Studio project for Flipper Zero firmware Установка Добавить данный репозиторий в качестве сабмодуля в корень локальной копии репозитор

25 Dec 28, 2022
Python script for printing to the Hanshow price-tag

This repository contains Python code for talking to the ATC_TLSR_Paper open-source firmware for the Hanshow e-paper pricetag. Installation # Clone the

12 Oct 06, 2022
BMP180 sensor driver for Home Assistant used in Raspberry Pi

BMP180 sensor driver for Home Assistant used in Raspberry Pi Custom component BMP180 sensor for Home Assistant. Copy the content of this directory to

747Developments 1 Dec 17, 2021
Lego Mindstorms EV3 and Lego Spike Prime

Lego Mindstorms EV3 and Lego Spike Prime What is FLL? The FIRST LEGO League Challenge Robotics Tournament challenges students from 9 to 16 years old t

Danimar Campos da Costa 1 Nov 14, 2021
BoneIO is a compact IO controller for home automation.

Project description BoneIO is a compact IO controller for home automation. Main features of this controller are Compact size (27x11x6)cm - 15 DIN modu

Maciej Krasuski 120 Nov 30, 2022
Implemented robot inverse kinematics.

robot_inverse_kinematics Project setup # put the package in the workspace $ cd ~/catkin_ws/ $ catkin_make $ source devel/setup.bash Description In thi

Jianming Han 2 Dec 08, 2022
A script for performing OTA update over BLE on ESP32

A script for performing OTA update over BLE on ESP32

Felix Biego 18 Dec 15, 2022
LedFx is a network based LED effect controller with support for advanced real-time audio effects

Welcome to LedFx ✨ -Making music come alive! LedFx website: https://ledfx.app/ What is LedFx? What LedFx offers is the ability to take audio input, an

786 Jan 02, 2023
Turn your Raspberry Pi Pico into a USB Rubber Ducky

pico-ducky Turn your Raspberry Pi Pico into a USB Rubber Ducky Install Requirements CircuitPython for the Raspberry Pi Pico adafruit-circuitpython-bun

Konstantinos 5 Nov 08, 2022
Code for the onshape macropad.

Onshape_Macropad Code for the onshape macropad. This is a macropad built using the Pimoroni Keybow and the KPrepublic Enclosure. pimoroni_keybow kprep

Justin Cole 1 Nov 23, 2021
Universal Xiaomi MIoT integration for Home Assistant

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

1.9k Jan 02, 2023
Projet d'integration SRI 3A ROS

projet-integration-sri-2021-2022 Projet d'intégration ROS SRI 2021 2022 Organization: Planification de tâches Perception Saisie: Cédérick Mouliets Sim

AIP Primeca Occitanie 3 Jan 07, 2022
Simples Keylogger para Windows com um autoboot implementado no sistema

MKW Keylogger Keylogger simples para Windos com um autoboot implementado no sistema, o malware irá capturar pressionamentos de tecla e armazená-lo em

3 Jul 03, 2021