Custom Integration: Sonnenbatterie

No problem. Good luck getting it to work. Happy to help.

Rob
just folowed your explanation thread in the last ten posts. Have you considered compiling this as a user guide with the assistance of David and Mark? There is just so much knowledge sitting here between yourself, David and Mark. Would be easier to see it in a one post read.
Pat

Yes Iā€™ve thought such a thing would be usefull. I can try to document what Iā€™ve done. However, Iā€™m only new to this system so expect there are lessons yet to be learned for me. Also I only use a limited set of features of EMHASS so I would have to focus on my configuration which would suit people with same hardware and electricity supplier. Iā€™ll give it a go.

Hi Rob,

When you put the system into Standby with a charge value of 0, does your system stop charging from the PV?

Yes. With either the charge of discharge commands (POST http://192.168.99.168:80/api/v2/setpoint/discharge or charge/x) the system has to be in manual mode (EM_OperatingMode=1) which stops the battery from doing anything automatically without a command from you. So if you POST a command to charge at 0W then thatā€™s what it does. I also experimented with changing the backup buffer to 100% which should stop the battery from discharging.

I have the Hybrid 9.53 with built-in inverter and its interesting that when I give it the 0W charge command, instead of stopping the battery from charging and sending excess to the grid, it sends all of the PV input to the battery and then draws power from the grid to take care of the houses current requirements. I was hoping the 0 charge would stop the battery charging, power the houses requirements at the time and then export the rest (which then would go to my car charger)

I did ask sonnen if there was a command to put the battery into standby. They rang me back and said there wasnā€™t. But to stop it discharging you could increase backup buffer to 100% which reserve the battery for grid failure. But not sure how to stop it from charging if solar is available.
Might be worth asking them. I emailed the at [email protected]. Took them a while but eventually they rang me back with a responce so include your phone number.

Thanks for that Rob. Iā€™ve had a mixed run with talking to the Sonnen guy in Aus. The last respose I had from a service guy was "Hi Chris,

Thanks for your question. I advise as follows.

The Time of Use can only be set by sonnen or by an accredited installer. Sonnen intends to release an update to the customer portal within the next few months to allow customers to directly change Time of Use.

Access to the sonnen ā€œBackendā€ channel by anyone other than sonnen or an accredited sonnen installer may result in the warranty being invalid.

KInd regards,

John Wilson

What version of the firmware do you have?

1.10.6 I have a feeling it was because I was asking questions that they werenā€™t normally getting and he was trying to dissuade me. My installer had no idea about the api stuff and I guess 99% of customers just get the system donā€™t know all the additional capabilities.

Yes thatā€™s right.
I have version 2.

Yeah, mine is the same too. The Hybrid must work a bit differently with the integrated inverter. I will give the backup buffer setting a go. Never thought of using that to stop it discharging.

My first attempt at setting the battery to standby I set it to charge at 100w. Close enough to 0. You could try that as well.

You are putting it manual mode first before charging at 0. Has to be in manual mode.

1 Like

Hi Robert,

Have you figured out how to pull the API value for state the system is in?
Ive been trying with the Get api for * EM_OperatingMode, ive followed your guide you sent and its worked with everything else but i want to make sure when im swapping from auto to manual and discharging i can see the manual selection and auto selection.

This should do it:

[{"id":"f49b840467d14aca","type":"inject","z":"65840aa926d9c567","name":"trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":1260,"wires":[["4f20c85e38e98c5e"]]},{"id":"4f20c85e38e98c5e","type":"function","z":"65840aa926d9c567","name":"Retrieve mode","func":"msg.headers = {}\nmsg.headers['Auth-Token'] = 'YOUR AUTH TOKEN'\nmsg.headers [\"Content-Type\"] = \"application/x-www-form-urlencoded\"\nmsg.url = \"http://192.168.99.168:80/api/v2/configurations/EM_OperatingMode\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":1260,"wires":[["c23e139112a8dce9"]]},{"id":"c23e139112a8dce9","type":"http request","z":"65840aa926d9c567","name":"get State","method":"GET","ret":"obj","paytoqs":"body","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"bearer","senderr":false,"headers":[],"x":640,"y":1260,"wires":[["478aa36ac804bad5"]]},{"id":"3cf2e6149b60f7de","type":"comment","z":"65840aa926d9c567","name":"GET Operating mode","info":"","x":140,"y":1260,"wires":[]},{"id":"478aa36ac804bad5","type":"function","z":"65840aa926d9c567","name":"Pass mode","func":"var mode = msg.payload.EM_OperatingMode\nvar modeState = \"\"\nif (mode != \"1\") {\n    modeState = \"Autpomatic\";\n}\nelse {\n    modeState = \"Manual\";\n}\nmsg.payload = modeState\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":1260,"wires":[["8f61c2b75be688c8"]]},{"id":"8f61c2b75be688c8","type":"ha-sensor","z":"65840aa926d9c567","name":"","entityConfig":"cdb20193ac7f922c","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":990,"y":1260,"wires":[[]]},{"id":"cdb20193ac7f922c","type":"ha-entity-config","server":"afc27684.cf6ed8","deviceConfig":"","name":"sonnen OperatingMode","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"sonnen OperatingMode"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"afc27684.cf6ed8","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Look for an entity called sensor.sonnen_operatingmode. You need to add it to your flow that changes modes and perhaps a few second delay between the change and this GET to give the battery time to make the change.

Alternativly a webhook but I havenā€™t look at this in the sonnen battery

mine comes up with home assist error,

I also need to figure how to implement to dashboard now,

also looked over you setup and curious how you got the gauge sensors? i cant find them in hacks

Oh you had miss spelt automatic, caused an error haha,

sorted

1 Like

The round one and the battery gauge?
Look for canvas gauge card.

type: custom:card-templater
entities:
  - sensor.sonnenbatterie_XXXXX_state_grid_inout
  - sensor.sonnenbatterie_XXXXX_meter_production_4_1_w_total
  - sensor.sonnenbatterie_XXXXX_consumption_w
card:
  type: custom:canvas-gauge-card
  card_height: 325
  entity: sensor.sonnenbatterie_XXXXX_state_grid_inout
  title_template: >-
    {{
    state_attr('sensor.sonnenbatterie_XXXXX_state_grid_inout','friendly_name')
    }}
  font_size: 1em
  gauge:
    borders: false
    height: 400
    highlights:
      - color: rgba(21,242,27,0.75)
        from: 0
        to_template: >-
          {% if
          states('sensor.sonnenbatterie_XXXXX_meter_production_4_1_w_total')|float(0)
          < 0 %} 0 {% else %} {{
          states('sensor.sonnenbatterie_XXXXX_meter_production_4_1_w_total')|float(0)
          }} {% endif %}
      - color: rgba(245,24,57,0.75)
        to: 0
        from_template: '-{{ states(''sensor.sonnenbatterie_XXXXX_consumption_w'')|float(0)}}'
    majorTicks:
      - '-5000'
      - '-4000'
      - '-3000'
      - '-2000'
      - '-1000'
      - '0'
      - '1000'
      - '2000'
      - '3000'
      - '4000'
      - '5000'
    maxValue: 5000
    minValue: -5000
    minorTicks: 2
    startAngle: 90
    strokeTicks: true
    ticksAngle: 180
    title: Live Solar (W)
    type: radial-gauge
    valueBox: true
    width: 320

Thank you once again, my dashboard is coming together finally haha.

Curious, and noob questions. The entity you pull from say a meter is pinned to that entities and you can choose to add a flow from this point with whatever value,

Can you add this value to another and calculate?

I have a solaredge battery thatā€™s controlling my sonnen thanks to you, so im now trying to add the values of consumption together and minus the batter discharges but no clue how to do this.

So in other words all my flows donā€™t equate what I consume. But if I can use my in out meter on both sonnen and solardsge and add a value then it could show me the true consumption.

And yes before anyone asks, Iā€™ve been searching but nothing shows an add value to make a live reading as such.