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
How to configure IOMMU device for nested Proxmox hypervisor (PVE) VM - PCIe Passthrough

Configuring PCIe Passthrough for Nested Virtualization on Proxmox Summary: If you are running bare-metal L0 (level 0) Proxmox (PVE) hypervisor with ne

Travis Johnson 6 Aug 30, 2022
Raspberry Pi Pico development platform for PlatformIO

Raspberry Pi Pico development platform for PlatformIO A few words in the beginning Before experimental please Reinstall the platform Version: 1.0.0 Th

Georgi Angelov 160 Dec 23, 2022
I made this so I can control my Tapo L510 light bulb and Govee H6159 light strip using the PyP100 module and the Govee public API

TAPO-And-Govee-Controller I made this so I can control my Tapo L510 light bulb and Govee H6159 light strip using the PyP100 module and the Govee publi

James Westhead 0 Nov 23, 2021
Control the lights of Alienware computers under GNU/Linux systems.

Before requesting support please consider that this software is not actively developed. I created it in 2014 for managing my Alienware M14X-R1 (where

rsm 111 Dec 05, 2022
🎃 Some spooky code samples to hack yourself a pumpkin 👻

🎃 Tech Or Treat 👻 It's spooky season for those who celebrate Halloween, and to get in the spirit (spirit - get it? 👻 ) we thought it would be fun t

Jim Bennett 5 Feb 07, 2022
Baseline model for Augmented Home Assistant

Dataset Preparation Step 1. Rename the Virtual-Home output directory to 'vh.[name]', for example: 'vh.door' Make sure the directory contains 100+ fram

Stanford HCI 1 Aug 24, 2022
Home Assistant custom components MPK-Lodz

MPK Łódź sensor This sensor uses unofficial API provided by MPK Łódź. Configuration options Key Type Required Default Description name string False MP

Piotr Machowski 3 Nov 01, 2022
Doughskript interpreter for converting simple command sequences into executable Arduino C++ code.

Doughskript interpreter for converting simple command sequences into executable Arduino C++ code.

Svjatoslav 2 Jan 11, 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
A ch341dll Wrap is for using in Python 32bits windows to access I2C SPI and MDIO (by GPIO), and Demo with display PC sreen on OLED by i2c or SPI .

ch341dll_wrap_typcal_app A ch341dll Wrap is for using in Python 32bits windows to access I2C SPI and MDIO (by GPIO). In addition, I provided 3 Demo. I

13 Jan 02, 2023
USB Rubber Ducky with the Rasberry Pi pico microcontroller

pico-ducky Install Install and have your USB Rubber Ducky working in less than 5 minutes. Download CircuitPython for the Raspberry Pi Pico. Plug the d

AnOnYmOus001100 3 Oct 08, 2022
从零开始打造一个智能家居系统

SweetHome 从零开始打造智能家居系统的尝试,主要的实现有 可以扫码添加设备并控制设备的Android App 可以控制亮灭的灯,并可以设置在Android App连接到指定Wifi后自动亮起 可以控制开关的窗帘,机械结构部分自己设计并3D打印出来 树莓派主控,实现Http请求接口和ZigBe

金榜 5 May 01, 2022
Designed a system that can efficiently sort recyclables and transfer them to corresponding bins using Python, a Raspberry Pi, and Quanser Labs.

System for Sorting and Recycling Containers - Project 3 Table of contents Overview The challenge Screenshot My process Built with Code snippets What I

Mit Patel 2 Dec 02, 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
Software framework to enable agile robotic assembly applications.

ConnTact Software framework to enable agile robotic assembly applications. (Connect + Tactile) Overview Installation Development of framework was done

Southwest Research Institute Robotics 29 Dec 01, 2022
The main aim of this project is to avoid the accidents in shredding ( Waste Recycling Industry )

shredder-Machine-Hand-Safety The main aim of this project is to avoid the accidents in shredding ( Waste Recycling Industry ) . The Basic function of

Shubham Chaudhari 1 Nov 15, 2021
Modeling and Simulation of Satellite Servicing Manipulators

Modeling and Simulation of Satellite Servicing Manipulators Final Project for the course ENPM662: Introduction to Robot Modeling (Fall 2021). This pro

Adarsh M 1 Jan 24, 2022
Ingeniamotion is a library that works over ingenialink and aims to simplify the interaction with Ingenia's drives.

Ingeniamotion Ingeniamotion is a library that works over ingenialink and aims to simplify the interaction with Ingenia's drives. Requirements Python 3

Ingenia Motion Control 7 Dec 15, 2022
A set of postprocessing scripts and macro to accelerate the gyroid infill print speed with Klipper

A set of postprocessing scripts and macro to accelerate the gyroid infill print speed with Klipper

Jérôme W. 75 Jan 07, 2023
Easyeda2kicad.py - Convert any LCSC components (including EasyEDA) to KiCad library

easyeda2kicad.py A Python script that convert any electronic components from LCSC or EasyEDA to a Kicad library Installation git clone https://github.

uPesy Electronics 150 Jan 06, 2023