Sonnen Battery Binding

Sonnen binding

The binding for sonnen communicates with a sonnen battery. More information about the sonnen battery can be found here: https://sonnen.de/
In general the sonne API can be also read with the standard http binding. However I decided to create this binding to make it easier for normal user to integrate it in their openhab instance.

The following channels are yet supported:

Channel Type Access Description
batteryChargingState Switch read Indicates if the Battery is charging at that moment
batteryDischargingState Switch read Indicates if the Battery is discharging at that moment
batteryFeedIn Number:Energy read Indicates the actual charging current of the Battery in watt
batteryDischarging Number:Energy read Indicates the actual current discharging the Battery in watt
consumption Number:Energy read Indicates the actual consumption of the consumer in watt
gridFeedIn Number:Energy read Indicates the actual current feeding to the Grid in watt.0 if nothing is feeded
gridConsumption Number:Energy read Indicates the actual current consumption from the Grid in watt.0 if nothing is received
solarProduction Number:Energy read Indicates the actual production of the Solar system in watt
batteryLevel Number read Indicates the actual Battery Level in % from 0 - 100
flowConsumptionBatteryState Switch read Indicates if there is a current flow from Battery towards Consumption
flowConsumptionGridState Switch read Indicates if there is a current flow from Grid towards Consumption
flowConsumptionProductionState Switch read Indicates if there is a current flow from Solar Production towards Consumption
flowGridBatteryState Switch read Indicates if there is a current flow from Grid towards Battery
flowProductionBatteryState Switch read Indicates if there is a current flow from Production towards Battery
flowProductionGridState Switch read Indicates if there is a current flow from Production towards Grid

Changelog

Version 0.1

  • initial release

Version 0.2

  • Refactoring code
  • Adding new Channels batteryFeedIn, batteryDispense and gridReceive on user request. gridFeedIn shows now only positive values.

Version 1.0

  • Refactoring code
  • Changing Channel descriptions
  • Same Code basis as merged to the next offical release of openhab

Resources

Latest Release JAR:
[https://github.com/chingon007/openhab-addons/raw/release/bundles/org.openhab.binding.sonnen/release/org.openhab.binding.sonnen-3.3.0-SNAPSHOT_V1.0.jar)

Source Code is merged here (pull request created):
Github repository

Author

This binding was developed by @Christian_Feininger .

3 Likes

Will integrate it as soon as my Sonnen battery will go live

1 Like

This post was flagged by the community and is temporarily hidden.

I dont think your post is related to this thread, is it?

Love this Binding. The first usage went fine.

I used two items for channel js-transformations to get everytime positive numbers of Grid activities (FeedIn / Receive) - cut at 0. You may think to add two additional channels to automate it.

I would like to request a channel for Battery-Activity (FeedIn/Usage) [ -/+ nnnn W]. By then my tracking would be complete.

I published V0.2 which incorporate your requested changes. Have a look

Thnx. Going to investigate. I’ve updated the binding via Client mode.

Not sure, what went wrong, but the old thing reports now HANDLER_MISSING_ERROR
A new created thin is showing correct functionality.
However, I have to recreate all items… based on new channels.

Not sure, by when this is finished.

Furthermore I recognized (beside to your binding), tha I see troubles in the sonnen-API (is also not working in the SonnenAPP (Android) on my end - the live view is not showing the correct values). However the Summary vew (second tab) shows the “correct” graphs based on other values. Do you face a similar issue? Started ~ by 3rd JAN.

This binding is now part of official openHAB distribution, starting at snapshot 2686.

This beta version will have to be unpublished from the marketplace when openHAB 3.3M1 is released.

Entry will be removed after the next milestone from openhab is published

@felso HANDLER_MISSING_ERROR is normal as you have removed the old JAR when you installed the new version. This will happen now again if you migrate now to the latest and final version 1.0.

Besides that, my values of the binding matching with the Live View. However you have to distinguish that the Live View over the webpage from sonnen is always some seconds behind then maybe the binding as the binding is taking the local number directly from your battery and the for the sonnen portal the numbers are getting processed over the cloud and not have a constant refresh.

Thanks for your efforts and keeping me up to date. Today Sonnen solved my problem regarding the live view and from this moment I receice also data from your binding.

However: it was now the second time that the defined thing went into a communication error:
2022-01-07 16:01:35.572 [WARN ] [.MqttBrokerConnectionServiceInstance] - MqttBroker connection configuration faulty: ID segment ‘ddd.ddd.ddd.ddd’ contains invalid characters. Each segment of the ID must match the pattern [\w-]*.
at org.eclipse.jetty.server.HttpConnection.onClose(HttpConnection.java:519) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.ssl.SslConnection.onClose(SslConnection.java:378) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.SelectorManager.connectionClosed(SelectorManager.java:345) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.server.HttpConnection.onClose(HttpConnection.java:519) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.ssl.SslConnection.onClose(SslConnection.java:378) ~[bundleFile:9.4.43.v20210629]
at org.eclipse.jetty.io.SelectorManager.connectionClosed(SelectorManager.java:345) ~[bundleFile:9.4.43.v20210629]
2022-01-10 23:17:48.746 [WARN ] [b.binding.mqtt.handler.BrokerHandler] - Trying to dispose handler mqtt:broker:c59cc558d5 but connection is already null. Most likely this is a bug.
2022-01-10 23:17:48.747 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Trying to dispose handler mqtt:broker:c59cc558d5 but connection is already null. Most likely this is a bug.
at org.openhab.binding.sonnen.communication.SonnenJSONCommunication.refreshBatteryConnection(SonnenJSONCommunication.java:65) ~[?:?]
at org.openhab.binding.sonnen.internal.SonnenHandler.updatebatteryData(SonnenHandler.java:110) ~[?:?]
at org.openhab.binding.sonnen.internal.SonnenHandler.refreshChannels(SonnenHandler.java:165) ~[?:?]
at org.openhab.binding.sonnen.communication.SonnenJSONCommunication.refreshBatteryConnection(SonnenJSONCommunication.java:65) ~[?:?]
at org.openhab.binding.sonnen.internal.SonnenHandler.updatebatteryData(SonnenHandler.java:110) ~[?:?]
at org.openhab.binding.sonnen.internal.SonnenHandler.refreshChannels(SonnenHandler.java:165) ~[?:?]

I replaced my local IP address. After pausing and resuming the binding went to ONLINE again. Not sure if you are able to think about an automatic reconnect feature - if not already given.

3.3M1 has been released.
Time to unpublish this beta version from the marketplace.

Works great for me