aWATTar binding: Beta and discussion

@Wolfgang1966 I have the issue running with the openHAB docker. This might be the quickest way to be able to reproduce it if you have docker installed. (I just tried this and it reproduced the error)

docker run \
        --name openhab \
        --net=host \
        -v /etc/localtime:/etc/localtime:ro \
        -e "EXTRA_JAVA_OPTS=-Duser.timezone=CET" \
        openhab/openhab:3.4.0.M1

This will run the openHAB UI 3 on http://localhost:8080

Then install the awattar binding and try to install the bridge with the GUI. You will not see it as @martingwb describes.

You can docker cp new version into the container for testing a fix. Let me know if I can help testing or fixing. (I contributed the Renault binding so I might be able to help)

@Wolfgang1966 , @Doug_Culnane - thank you for your hints, I managed to see the current price in a label card and a chart is built under Analyze item.

Is there somehow a way to build a chart not only from the current prices but also including all the known prices for today and tomorrow in OH?
I guess the channels need somehow to be consolidated for that?

Hi @martingwb , the data for such a chart is available with the binding, use the ā€œpricesā€ thing and the channel groups todayXX and tomorrowXX to retrieve them, However, I was not able to get a chart like the one I assume you want (something similar to the chart available on the awattar website), because the charts available in openHAB are all timeseries based and openHAB currently does not allow to set item values in advance to a certain time in the future. I searched for such a function in openHAB, but did not find any. So you can include all data in a sitemap as the example configuration shows, but there seems to be no way to set up a ā€œpredictingā€ graph currently.

We may discuss this as a feature request for the openHAB core API, as it might be useful for weather predictions also, for example to show a temperature forecast graph.

@Wolfgang1966 - Thank you for clarifying. Yes, you guessed what I am looking for. Will integrate matplotlib awattar charts for now to display on the OH web gui.

I also want a future charting option but for now this is my solution: openhab/conf/html/awattarChart.html

<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" href="https://www.awattar.at/static/css/build/awattar.min.css">
</head>
<body class="awattar">
	<div id="wrapper">
		<header hidden="true">
			<div class="navbar-wrapper" />
		</header>
		<div class="container">
			<div class="row">
				<div id="chartTransparencyData"></div>
			</div>
		</div>
	</div>
	<script src="https://www.awattar.at/static/js/build/awattar.min.js"></script>
	<script src="https://www.awattar.at/static/js/switchforms/init.js"></script>
</body>
</html>

openHAB 3 UI page code for embedding in UI.

config:
  label: awattar Chart
  sidebar: true
  order: "0"
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: oh-webframe-card
                      config:
                        src: /static/awattarChart.html
                        height: 480
masonry: null
grid: []
canvas: []
1 Like

I have the same setup like @martingwb . Docker/Synology OH3 3.3.0 stable. I am also do not get the Option to install the bridge as a thing. It does not show whgen you try to add a thing. Do you found in the meantime a solution/ workaround for that problem? Thanx!

@JanTTTTT as a work around you can install the bridge using a thing file as per the documentation: aWATTar - Bindings | openHAB

cat openhab/conf/things/awattar.things

Bridge awattar:bridge:bridge1 "aWATTar Bridge" [ country="DE", vatPercent="19", basePrice="17.22"] {
  
}

Thanx for that! This have worked fine! BTW: Excellent binding!

@Wolfgang1966 I moved the bridge-types.xml bridge definition to the thing-types.xml file and the bridge can be added via the UI. (I do not know why this works but it works). Shall I submit a pull request or do you wish to solve this another way?

This is the change I made.

diff --git a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/bridge-types.xml b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/bridge-types.xml
deleted file mode 100644
index 09b6bedcb6..0000000000
--- a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/bridge-types.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<thing:thing-descriptions bindingId="openweathermap"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
-       xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
-
-
-       <bridge-type id="bridge">
-               <label>aWATTar Bridge</label>
-               <description>Provides price data from the aWATTar API.</description>
-               <config-description-ref uri="bridge-type:awattar:bridge"/>
-       </bridge-type>
-
-</thing:thing-descriptions>
diff --git a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/thing-types.xml
index 939667119d..4b659c087b 100644
--- a/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/thing-types.xml
+++ b/bundles/org.openhab.binding.awattar/src/main/resources/OH-INF/thing/thing-types.xml
@@ -4,6 +4,12 @@
        xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
        xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
 
+       <bridge-type id="bridge">
+               <label>aWATTar Bridge</label>
+               <description>Provides price data from the aWATTar API.</description>
+               <config-description-ref uri="bridge-type:awattar:bridge"/>
+       </bridge-type>
+
        <thing-type id="prices">
                <supported-bridge-type-refs>
                        <bridge-type-ref id="bridge"/>

Hi @Doug_Culnane , a deep thank you :bowing_man: for finding the solution!! I was too busy to find time to dig into this myself. I would be glad if you could open a PR; I could not think of any other solution. I already suspected that it might have to do with some problem in the config files.

Thanks for this binding! As being an aWATTar customer myself since recently Iā€™m trying to visualise the data combined with my current power consumption and PV-production.
I used the code from @Doug_Culnane to display the curve which is already quite useful (unfortunately a small issue with the wind turbine icons which donā€™t come through but this is negligible).

One question now: how can I show the lowest rate of the day in a label card? I can show the time frame but I canā€™t get my head around on how to show the rate itself.

Thanks for you help!

Hi @matzR ,

One idea that comes to my mind is using the prices thing which delivers all prices for today and then use the channel groups today00ā€¦today23 to identify the lowest one. I think this could be done with a rule, however, it will be a lengthy one and needs some programming skills (a long row of if statements for example).

I take this as an RFE to add more channels to the bestprice thing: lowest, average and highest price of a bestprice period. However, donā€™t expect me to do this soon, I canā€™t tell when I will find the time to implement it.

I had a similar idea and created this rule now:

// aWATTar - get lowest rate for the day
rule "get lowest rate of the day"
when
	Item aWATTar_BestPrice_HoursList changed
then

	// check which hour has the lowest rate today
	val int lowRateHour = (aWATTar_BestPrice_start.state as DateTimeType).getZonedDateTime.getHour()
	
	// loop through group to get the rate of the identified hour with the lowest rate
	gAWATTAR_dayRates.members.forEach [rate|
		if ( rate.name.contains(String.format("%02d", lowRateHour)))  {
			//logInfo("TEST", "lowRate: " + rate.state.toString)
			aWATTar_BestPrice_price.postUpdate( rate.state )
		}
	]

end

First I thought I could thought take the n-th element of the group based on lowRateHour but I didnā€™t figure out how to do that?

@Wolfgang1966 Iā€™d like to contribute and add a capability to read spot prices from the Entso-E Transparency Platform so that your wonderful binding could be used by folks from other countries and regardless where they are purchasing their electricity from.

I installed the aWATTar Bindingin and had a 10 min look at it and it looks to me that the only thing that would be needed is to enhance this so that there would be another Bridge option which would take the following arguments:

  • Entso-E API token (this is free of charge and can be obtained from Entso-E service desk)
  • Bidding Zone, for example 10YFI-1--------U means Finland
  • VAT multiplier
  • Currency exchange rate so that folks who do not use Euros can see the prices in their own currency

Is my assumption correct that the only thing that is needed is to write this additional Bridge?

Cheers,
Markus

Notes to self (others: feel absolutely free to correct if there I have misunderstood something)

  1. Code can be found here: openhab-addons/bundles/org.openhab.binding.awattar at main Ā· openhab/openhab-addons Ā· GitHub

  2. src/main/resources/OH-INF/addon/addon.xml

  • Needs update if other countries / bidding zones would be supported
  1. openhab-addons/config.xml at main Ā· openhab/openhab-addons Ā· GitHub
  • Add a new bridge type called for example bridge-type:awattar:entsoe-bridge
  1. openhab-addons/awattar.properties at main Ā· openhab/openhab-addons Ā· GitHub
  • Strings seem to go here so that they can be translated
  1. openhab-addons/thing-types.xml at main Ā· openhab/openhab-addons Ā· GitHub
  • Reflect the new entsoe-brigde type also here
  1. openhab-addons/AwattarUtil.java at main Ā· openhab/openhab-addons Ā· GitHub
  • This seems like a good candidate for date helper methods for preparing the date input arguments in the format Entso API expectes them
  1. openhab-addons/AwattarPrice.java at main Ā· openhab/openhab-addons Ā· GitHub
  • No changes should be needed, the Prices that Entso-E provides can be saved to the same data model
  1. openhab-addons/AwattarBridgeConfiguration.java at main Ā· openhab/openhab-addons Ā· GitHub
  • Need to implement same kind of class for Entso-E Bridge configurations
  1. openhab-addons/AwattarHandlerFactory.java at main Ā· openhab/openhab-addons Ā· GitHub
  • Factory class for creating new instances of the Handler classes
  • See next points
  1. openhab-addons/AwattarPriceHandler.java at main Ā· openhab/openhab-addons Ā· GitHub
  • This contains the data refresh logic, will probably require some changes when there will be other Bridges
  1. openhab-addons/AwattarBridgeHandler.java at main Ā· openhab/openhab-addons Ā· GitHub
  • This is where the prices are fetched from the current data source.
  • This class needs some love when there will be another data source as there is also a lot of other logic in this class which should not be duplicated.
  1. openhab-addons/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/dto at main Ā· openhab/openhab-addons Ā· GitHub
  • These are for converting JSON to Java structures
  • Entso-E responses are XML so needs to be handled differently

Please add a parameter for basePrice to the Entso-E Bridge (aWATTar - Bindings | openHAB, aWATTar binding: Beta and discussion - #17 by Wolfgang1966).

If you donā€™t trust your energy supplier to calculate the base price correctly, it gets quite complicated to calculate the base price per kWh in Germany :slight_smile: : Understanding the Tibber price model (Germany)

Hi @masipila ,

I really like your idea and Iā€™m confident that it could work that way, maybe with a few adaptions to the existing code. As the Entso-E API might use a different data model there might also be the need to add additional dtos for the Gson parser of your bridge.

Also, I think about the naming. How do we get the folx that is interested in Entso-E data to have a look at the aWATTar binding for their needs. Renaming the binding would be a breaking change for all users of the current one, but code duplication to a separate Entso-E binding also looks like a bad idea to me. I do not have a good solution at the moment, but maybe somebody reading this has an idea.

So, feel free to start! :+1:

Regarding the naming. I was also thinking about it this morning for the exact reason.

One option which is backwards compatible is to keep the old code as it is but mark it as deprecated. We could then clone it with a new name and all further changes would only go to the new code base.

But letā€™s worry about that latrr when we have first got it working with Entso-E API.

Cheers,
Markus

1 Like

@Wolfgang1966 and @masipila,

As a user of the Awattar binding I would be happy to rename my things to a generic name. The Items I guess can keep the same so it would not be a big problem for me to set this up again. The rules etc use the item names so all I got to do is link them to the right thing channels.

I find the discussion and ideas very good. I think automating electric use, mini smart grids and costing calculations etcā€¦ is really interesting and so any initiative that makes this easier for more people to set up generic solutions is great. I would be happy to test and help.

Currency exchange rate is tricky as this is dynamic. I would not add this to the scope of the binding. I would hope the prices are supplied in the local currency. If not then it is the job of another binding to get the currency rate (or an http binding get)ā€¦ and a rule to calculate the local costā€¦ that is how i would try to solve it.

I do not know enough about energy markets to know if they are all the sameā€¦ I guess the awattar binding model is good for EU Spot market customers and suppliers. There might be other models out there.

I use the binding to soak up the cheapest hour of electricity each day to keep the car topped up and water warm if (the price is lower than the price I get for solar) or (car is very low). This is not very sophisticated but it works well and I have to occasionality manually intervene when not.

What would be cool to to define a target charge level (with a dimmer in the UI so you can slide it depending on future usage needs) and time in the morning to try to achieve this. A rule can calculate the required energy needed and the time that it would take to supply it. Then the energy binding gets a time and an end timestamp. The binding then could supply a switch that would switch on for long enough to supply this (in periods or one period) when the electricity is cheapest. It would be perfect if the time needed could be recalculated so that if the car did not get plugged in till late (or once the sun has gone down) then it would still charge on timeā€¦ just an idea for discussion or ignoringā€¦