Sonnen Battery Binding

@Heeman2424 Can you check this version? It contains the PowerMeter in the advanced options as well as the API V2 Calls

@corny It should be supported with the version 1.1 provided here in the marketplace

@Christian_Feininger
First big thank you for this binding!
Can you please add the Variable ā€œSystemStatusā€ from /api/v2/status to see if the battery is On or OffGrid (to detect if the battery is in Backup Mode)?

Thank you!

Hello, thank you very much for your commitment. I have a SonnenBatterie sb10p with software version 1.10.7. Your binding basically works, but the value ā€œconsumptionā€ that is most important to me is not evaluated. Only ā€œnullā€ is displayed. Can you help me?

Hey @marrxx
the problems are the ā€œnewā€ units of the different channels. The binding do not support this units. There is already a PR for that, but no one tested this until now: [sonnen] Fix channel types, Energy should be Power by lochmueller Ā· Pull Request #15384 Ā· openhab/openhab-addons Ā· GitHub

This is the ā€œworkarround for meā€. You will get the values via public IP from the battery and can handle the values by yourself. Example with HTTP binding (only get 3 values, but you can use all information out of the JSON):

UID: http:url:sonnen_batterie_http
label: Sonnen Batterie HTTP
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://xxx.xxx.xxx.xxx/api/v2/status
  password:
  delay: 0
  stateMethod: GET
  refresh: 5
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: currentConsumption
    channelTypeUID: http:number
    label: Current consumption
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.Consumption_W
  - id: currentBatteryLevel
    channelTypeUID: http:number
    label: Current battery level
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.USOC
  - id: currentProduction
    channelTypeUID: http:number
    label: Current production
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.Production_W

Regards,
Tim

Hello, that is not correct. The binding is supporting API V2 Here an evidence out of the source code:

Therefore, it should also work for @marrxx, unless something has been changed recently. At least I don’t see anything at sonnen.
@marrxx Please enter the following in your browser http://YourIP/api/v2/status and send me by private message times the output from the browser, then I look if something has changed here.

@iPanic I will include this in the next version of the probably over Christmas arises accordingly.

English please, this is an international community !

I already figured it out myself :wink:

1 Like

@ Christian_Feininger I currently have no option for a private message :confused: The FAQ says nothing about this. Is there another way?

Hello,
just for documentation purpose. The binding also supports SB10P. It was just a wrong setup of the item. @timl You may try this as well. If you go with Number:Power in the item definition for consumption it will work as expected.

Works great, thanks. But the PR is still right, isn’t? So the items are created in the right unit… [sonnen] Fix channel types, Energy should be Power by lochmueller Ā· Pull Request #15384 Ā· openhab/openhab-addons Ā· GitHub

Yes the PR is still right. The Bug is actual only in the description file. Therefore the wrong semantic is suggested.

1 Like

Hello everyone,

I made some enhancements to the sonnen binding. It is now possible to start/stop charging your battery from the grid. This is mainly used if you have a dynamic electricity tarif and you would like to charge your battery during cheap hours. It is available via the marketplace and PR is opened to be merged for OH5.
Enjoy.

1 Like

Hi Christian, many thanks for developing this binding. May I raise to functional requests?

First request, could you please an additional channel for the OnGrid status? It’s interesting in my case as I have an emergency power socket with some devices powered over this power socket. And for this it would be interesting to know if the battery works in OnGrid or in ā€œEmergencyā€ mode.
The information is included in the JSON output of the http://IP:80/api/v2/status call.

{
   ...
   "SystemStatus": "OnGrid",
   ...
}

Second request, could you please add a switch which sets the discharging of the battery to 0, so that the energy in the battery is kept stored without discharging. Use case for this is, that you keep the energy stored in the battery for times with high variable energy prices (ā€œDunkelflauteā€).

So far I realize this with a manual API call http://IP:80/api/v2/setpoint/discharge/0 including auth token in the header - I assume similar to the call you used for the ā€œForce charging from gridā€ functionality.

If you have further questions about my requests, please let me know. If you need someone to test, I’d like to support as well.

Hello,

yes I understand you scenario. I have thought about it myself already. I will add it in the next months as soon as I have time to do so.

1 Like

The API for this looks pretty simple, I could take a look at it if you don’t have time. I just won’t be able to test as I have Tesla here :slight_smile:

You can if you want. In general the requested change is minor. I am pretty sure I can do it in the next 2 months or so.

https://smedley.id.au/tmp/org.openhab.binding.sonnen-5.0.0-SNAPSHOT.jar contains (untested) support for force discharging a battery. Code is at GitHub - psmedley/openhab-addons at sonnenforcecharge

The code is based off off @Christian_Feininger 's work to add support for charging. The code in communication/SonnenJSONCommunication.java could be made much simpler - right now the code differences between the functions to charge and discharge amount to about 2 lines - the URL, the config parameter and the error message.

If anyone can confirm this works, I’ll look to simplify the code and raise a PR.

Note that while the filename says snapshot 5.0, it’s built with Java 17 and OH 4.3 compatability, however, I’m not sure if any of the new tags added in other PRs as part of OH5 will break OH 4.3 compatability.

Hi All,

I updated the code based on some chats with @mstormi in Supporting spot energy pricing - #26 by mstormi. If you can, please test battery charging & discharging. This builds removes the config parameter for the charge rate and adds 2x new channels for charge & discharge rate - so that the charge rate can be set dynamically. https://smedley.id.au/tmp/org.openhab.binding.sonnen-5.2.0-SNAPSHOT.jar

is it still Java 17?
I don’t think going 21 should do harm, it’s supposed to be compatible. Not sure though about runtime dependencies for the opposite, so using 17 for a 5.x binding might not be a good idea.

If definitely java 21, that error rings a bell, I fixed something similar on another binding. Leave it with me to look at tonight after work.