Bringing electricity information from and into Openhab

Hi somi

The example above does not read the meter reading but the API is the same I think : Swagger UI

Everything in there however is 3 days old. There is no real time readings. Check Jacobs blog for how to do it with a Kamstrup reader.


1 Like

Thanks will take a look! I don’t need real-time reading at the moment as I cannot think what I can use it for especially given the extra cost and complication to set it up. I just want to have all numbers at the same place for now :slight_smile:

Hi @laursen :
I have recently updated to OH 4 and start to see the below errors in my rules:

2023-08-12 09:20:58.151 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'EnergiDataService-1' failed: 'getPrices' is not a member of 'org.openhab.core.thing.binding.ThingActions'; line 27, column 20, length 23 in EnergiDataService

Would like to check with you if the getPrices action been removed in version 4 (it’s still in the document though)? Many thank in advance!

It’s still there, can you share your script?

Edit: sorry I realised this could be related to another issue that I’m fighting with - for some reason after restarting OH 4, it doesn’t load all things configuration and I just saw the energy data service things are not even loaded.

Are you running your installation in Docker? In that case you might want to have a look here:

Indeed, looks like that’s the issue. Cause is unknown but ver deterministic, I have 117 things and restarting shows only 47 of them, I have to change and save each things configuration to make them appear, annoying. Thanks for pointing me to the discussion

Has anybody in Denmark use OpenHab with solar system? I’m scanning the market and try to find a smart solution, but traditional hybrid inverters are not that smart, it basically:

  1. Take all energy from solar panels
  2. Supply the usage
  3. Remaning energy goes to battery
  4. Sell the rest to grid
    It would be truly nice to have a solution that is smart to know the weather forecast and el price, for example if knows tomorrow is cloudy and better to buy cheap el to charge the battery during night. Or grid price is high, sell to grid take priority and charge batter in the afternoon when price is low etc.
    Any suggestion?

Hi Somy,

I don’t have one myself but I have a colleague at work with one of those Chinese Grow ones and he is automating it with rs232. You should check if that is an option on yours and perhaps the Modbus or serial bindings would be an option.


Also post the solution if you find one :wink:

1 Like

Thanks! I’m looking into Huawei inverters and so far looks like there is only way to load data from modbus but not change settings like TOU.
I think something like this for Huawei or other inverters would be great:
Unfortunately Sonnen only has very small inverter (3,68kw).
Another project I found is:

This can potentially be implemented as OH rule (there is already EaseeHome binding).

Hi @laursen
Hope you’re doing well! I’ve run OH 4.0.x for some days and noticed a very tiny issue with EnergiDataService binding, maybe because I don’t fully understand how it works.
I have a simple rule like below:

    Item TotalPrice changed 
    var Number currPrice = TotalPrice.state as Number
    logInfo("EnergiDataService", "Current electricity price is {}kr/kWh", String.format("%.2f", currPrice.doubleValue))

Item definition:

Group:Number:SUM    TotalPrice                    "Current El Total Price [%.2f kr]"            <price>    (gEnergiDataService)
Number              SpotPrice                     "Current El Spot Price [%.2f kr]"             <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#spot-price" [profile="transform:VAT"]}
Number              NetTariff                     "Current El Net Tariff [%.2f kr]"             <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#net-tariff" [profile="transform:VAT"]}
Number              SystemTariff                  "Current El System Tariff [%.2f kr]"          <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#system-tariff" [profile="transform:VAT"]}
Number              ElectricityTax                "Current El Electricity Tax [%.2f kr]"        <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#electricity-tax" [profile="transform:VAT"]}
Number              TransmissionNetTariff         "Current El Transmission Tariff [%.2f kr]"    <price>    (TotalPrice)                    {channel="energidataservice:service:energidataservice:electricity#transmission-net-tariff" [profile="transform:VAT"]}

In the log it looks like for some hours the TotalPrice changes twice, and it happens everyday at 21:00, and also sometimes 17:00, 13:00 and 8:00. The strange thing is only at 21:00 it always get 2 different prices:

**2023-08-26 00:00:00.008 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.22kr/kWh**
**2023-08-26 00:00:00.011 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.22kr/kWh**
2023-08-26 01:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.17kr/kWh
2023-08-26 02:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.15kr/kWh
2023-08-26 03:00:00.007 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.13kr/kWh
2023-08-26 04:00:00.018 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.10kr/kWh
2023-08-26 05:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.07kr/kWh
2023-08-26 06:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.18kr/kWh
2023-08-26 07:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.19kr/kWh
**2023-08-26 08:00:00.007 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.21kr/kWh**
**2023-08-26 08:00:00.008 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.21kr/kWh**
2023-08-26 09:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.16kr/kWh
2023-08-26 10:00:00.022 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.09kr/kWh
2023-08-26 11:00:00.074 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.04kr/kWh
2023-08-26 12:00:00.004 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.92kr/kWh
**2023-08-26 13:00:00.019 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.73kr/kWh**
**2023-08-26 13:00:29.392 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.73kr/kWh**
2023-08-26 14:00:00.012 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 1.67kr/kWh
2023-08-26 15:00:00.009 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.00kr/kWh
2023-08-26 16:00:00.008 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.10kr/kWh
2023-08-26 17:00:00.629 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.63kr/kWh
2023-08-26 18:00:00.004 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.71kr/kWh
2023-08-26 19:00:00.025 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.90kr/kWh
2023-08-26 20:00:00.039 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.98kr/kWh
**2023-08-26 21:00:00.006 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 3.01kr/kWh**
**2023-08-26 21:00:00.012 [INFO ] [.core.model.script.EnergiDataService] - Current electricity price is 2.55kr/kWh**

I have experienced this for a few days in a row, and I think it has something to do with the event:

Item 'NetTariff' changed from 0.73587500 to 0.28300000

So my guess what happened:

  1. At 21:00 it first calculate price based on NetTariff at 20:00
  2. Then the NetTariff has changed to 0,283
  3. It re-calculate total price based on new NetTariff

Hope you can take a look :slight_smile:

You don’t need to log this from a rule, you can simply inspect events.log. I can also see this from time to time, last it happened here:

2023-08-26 17:00:00.057 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EnergiDataService_SpotPrice' changed from 0.80941253625 to 0.88488746625
2023-08-26 17:00:00.072 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'EnergiDataService_TotalPrice' changed from 1.82691253625 to 1.90238746625 through EnergiDataService_NetTariff
2023-08-26 17:00:00.075 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'EnergiDataService_TotalPrice' changed from 1.82691253625 to 1.90238746625 through EnergiDataService_SpotPrice

I’m not sure why the group item was updated though EnergiDataService_NetTariff when EnergiDataService_NetTariff didn’t change. The channel receives an update, but the value is unchanged in this case. I would expect it to happen consistently, i.e. never or always. It might be timing-related.

In any case, this problem is to be found/fixed outside of the binding.

1 Like

Thank you for looking into it!
I now change the rule to check price 1 second after each hour and will report if the workaround is a good one :slight_smile: Have a great evening!

The mentioned pull request is now merged, and I have implemented support for persisted future prices in the Energi Data Service binding. So here’s a small teaser:

Additionally, I have updated the VAT profile to support time series as well:

1 Like

Great thanks! I will wait for the update and if possible can you write some quick instructions on how to use/show the timeseries?

It will be in the documentation. The current PR version is here:

In short, you shouldn’t have to do anything. However, changing persistence strategy to forecast will ensure a cleaner history as only time series will be persisted, not any hourly updates.

The PR was merged yesterday, so you can now find it here:

1 Like

Thank you! Will find some time to give a try and let you know how it goes, appreciated!

Please note that the core feature that it depends upon was merged after 4.1 milestone 3, so it is currently only available in the 4.1 snapshots.

1 Like

I will wait for 4.1.0 release then, thanks