solis-sensor icon indicating copy to clipboard operation
solis-sensor copied to clipboard

Battery power value positive for both charge and discharge

Open corvus2606 opened this issue 2 years ago • 17 comments

I can't see any value in the available sensors for my Solis inverter on the Solis Cloud that indicates the rate at which the battery is charging or discharging.

I can see the inverter_battery_power value, which does show the rate of charge/discharge, but the value is always positive.

corvus2606 avatar Sep 16 '22 11:09 corvus2606

I suspect you would have to combine it with “Battery Status” that indicates Charge / Discharge

From: corvus2606 @.> Sent: 16 September 2022 12:10 To: hultenvp/solis-sensor @.> Cc: Subscribed @.***> Subject: [hultenvp/solis-sensor] Battery power value positive for both charge and discharge (Issue #158)

I can't see any value in the available sensors for my Solis inverter on the Solis Cloud that indicates the rate at which the battery is charging or discharging.

I can see the inverter_battery_power value, which does show the rate of charge/discharge, but the value is always positive.

— Reply to this email directly, view it on GitHub https://github.com/hultenvp/solis-sensor/issues/158 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AYRF45Y5TCVQDD33SRGTNHLV6RIRPANCNFSM6AAAAAAQOHMLLU . You are receiving this because you are subscribed to this thread. https://github.com/notifications/beacon/AYRF452HQE6WVD5AKFVYDTDV6RIRPA5CNFSM6AAAAAAQOHMLLWWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFEAH6WE.gif Message ID: @.*** @.***> >

spetrie13 avatar Sep 16 '22 11:09 spetrie13

unfortunately I only get battery power and remaining capacity as a measurement. I can't see a battery status value in the API documentation either

corvus2606 avatar Sep 16 '22 11:09 corvus2606

if you figure this out, please let me know. Ive actually been trying to get that info all day myself and no closer :)

lynxus avatar Sep 16 '22 13:09 lynxus

I've hacked together a workaround for now until I can find something better. I created a Derivative helper based on my battery remaining charge sensor. Then used that value to determine if the battery power value should be negative with the below template sensor:

template:
  sensor:
    - name: "Battery Rate"
      state: >
            {% if states("sensor.battery_delta") | float <= 0 -%}  
              {{ states("sensor.my_solis_inverter_battery_power") | int }}
            {%- else -%}
              {{ states("sensor.my_solis_inverter_battery_power") | int * -1}}
            {%- endif -%}
      state_class: measurement
      unit_of_measurement: W
      device_class: power

corvus2606 avatar Sep 16 '22 15:09 corvus2606

I don't see anything explicit in the soliscloud API indicating charging or discharging status.

What you could do is check with the test app if battery current might be useful, but I'm afraid it's just like power only absolute.

I don't have an inverter with battery myself, so I'm relying on the community here ;-). If you find how I can recreate battery state on soliscloud then I'm happy to add it.

hultenvp avatar Sep 17 '22 11:09 hultenvp

Yeah, I spent the better part of yesterday going through the API documentation and there's nothing explicit as you say.

Honestly, the derivative sensor with the template is proving pretty good. there's about a 2 minute lag on it, but the solis api isn't realtime anyway.

I'll give the test app a go and try to find anything further that might indicate status... Either way, thank you for your work on this! The total Charged/Discharged is accurate for the power dashboard, the battery flow is just to satisfy my need for instant gratification :)

corvus2606 avatar Sep 17 '22 12:09 corvus2606

So... It looks like the "inverter" endpoint doesnt help much. However the ( "/v1/api/stationDetail" ) endpoint does..

Inverter just gives power.

But the stationDetail gives a negative value when outputting to the house..

image

So, i now use that endpoint to give me the "total" in/out . I guess some math needs to be used if you query and inverter endpoint directly..

lynxus avatar Sep 17 '22 13:09 lynxus

Interesting! So if we know the total of the station then we should be able to figure out whether an individual inverter battery is charging or discharging. Just a matter of making sure the sum adds up.

hultenvp avatar Sep 17 '22 14:09 hultenvp

I'm going to see if I can use the info and make an improvement by adding a battery state.

hultenvp avatar Sep 18 '22 08:09 hultenvp

With @lynxus' comment above seeming to be the answer to where we can get the direction of flow. Is this just a case of moving BAT_POWER: and BAT_POWER_STR: from the INVERTER_DETAIL endpoint into the PLANT_DETAIL one?

all of the other power sensors in hass seem to operate on negative meaning export and positive meaning import, so this would be in-line with general practise so far as I can tell.

I considered trying this, but I am not a python guy and don't have a test instance of hass available to mess with.

Edit: I tried it, of course it wasn't that simple :)

corvus2606 avatar Sep 26 '22 15:09 corvus2606

Haha.

Well, you could exchange the inverter_detail values with the plant details if you only have one inverter/battery in your station. Most people will have that, but stations can have multiple inverters registered and I can only assume that the BAT_POWER is then the sum of all inverters' BAT_POWER. And since they have different precision (see -0.015 vs 0.01) it will be interesting to come up with a generic algorithm to figure out which sum of positive and negative inverter BAT_POWER values makes up the station BAT POWER.

hultenvp avatar Sep 26 '22 17:09 hultenvp

By the way, it should be as simple as to move the lines BAT_POWER and BAT_POWER_STR from INVERTER_DETAIL to PLANT_DETAIL.

hultenvp avatar Sep 26 '22 18:09 hultenvp

I simply created a template sensor for this - whereby if the solar output is greater than the house consumption then it's a positive value (charging), and if the solar output is less than the house consumption then it's a negative value (discharging)

`

Solis battery charge / discharge

  battery_power:
    friendly_name: Battery Power
    unit_of_measurement: W
    value_template: >
      {% if states('sensor.solis_ac_output_total_power')| int > states('sensor.solis_total_consumption_power')| int %}
      {% set battery_power = states('sensor.solis_battery_power')|int %}
      {% elif states('sensor.solis_ac_output_total_power')| int < states('sensor.solis_total_consumption_power')| int %}
      {% set battery_power = states('sensor.solis_battery_power')|int*-1 %}
      {% endif %}
      {{ battery_power }}
      `

liveware-problems avatar Sep 27 '22 15:09 liveware-problems

It is strange that you see a positive value for both the charging and discharging. Could it be something with the integration between your battery system and the inverter?

On my system (pylontech batteries), the solis_battery_power entity is negative when discharging.

image

dhoogfr avatar Sep 27 '22 18:09 dhoogfr

It is strange that you see a positive value for both the charging and discharging. Could it be something with the integration between your battery system and the inverter?

On my system (pylontech batteries), the solis_battery_power entity is negative when discharging.

image

out of curiosity, are you using solis cloud, or the older m.ginlong.com portal? I expect this will only affect you if you're on the solis cloud one. It may be moot at this point, as the solis cloud api is now non-functional as of 4am this morning (hopefully by mistake)

corvus2606 avatar Sep 27 '22 21:09 corvus2606

I raised a ticket some time ago and just received this message to my many questions

So we have an article which shows a way to access API, however we stopped it because of GDPR

It would appear they may have shutdown the API access on GDPR grounds.

On Tue, 27 Sept 2022, 22:36 corvus2606, @.***> wrote:

It is strange that you see a positive value for both the charging and discharging. Could it be something with the integration between your battery system and the inverter?

On my system (pylontech batteries), the solis_battery_power entity is negative when discharging.

[image: image] https://user-images.githubusercontent.com/2979286/192604939-b912026d-45e7-4c8f-947d-95d428349f4e.png

out of curiosity, are you using solis cloud, or the older m.ginlong.com portal? I expect this will only affect you if you're on the solis cloud one. It may be moot at this point, as the solis cloud api is now non-functional as of 4am this morning (hopefully by mistake)

— Reply to this email directly, view it on GitHub https://github.com/hultenvp/solis-sensor/issues/158#issuecomment-1260079970, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYRF4567VQST7OQXBHVRLVLWANSEFANCNFSM6AAAAAAQOHMLLU . You are receiving this because you commented.Message ID: @.***>

spetrie13 avatar Sep 27 '22 21:09 spetrie13

Let's wait till they get back online with a new API version and see if the problem persists

hultenvp avatar Oct 21 '22 09:10 hultenvp

hey folks -- just looking in the current SolisCloud dashboard, on the inverter detail page, and if this is exposed through the API, this value looks like it could give an indication of charging vs discharging:

image

I'll try running the test script tomorrow (assuming my battery gets some use!) and see if that value goes negative when discharging...

jmason avatar Nov 23 '22 00:11 jmason

The battery is currently charging and I can see this in the inverterDetail API response:

    "storageBatteryCurrent": 9.3,
    "storageBatteryCurrentStr": "A",
    "storageBatteryVoltage": 53.4,
    "storageBatteryVoltageStr": "V",

which matches this:

image

jmason avatar Nov 23 '22 11:11 jmason

And here's what it looks like while discharging:

    "storageBatteryCurrent": -2.7,
    "storageBatteryCurrentStr": "A",
    "storageBatteryVoltage": 51.7,
    "storageBatteryVoltageStr": "V",

jmason avatar Nov 23 '22 17:11 jmason

this is really weird ... my battery power is signed (positive for charging and negative for discharging) and always has been as far as I can remember. (using soliscloud)

LucidityCrash avatar Nov 27 '22 02:11 LucidityCrash

Mine is the same @LucidityCrash, negative for discharging and positive for charging. I am looking to create a sensor that says if it's zero, then battery state is idle, if it's -0.1 or lower then it's discharging, if it's greater than 0 then it's charging

viking2010 avatar Nov 27 '22 16:11 viking2010

Yeah that's really weird. solis_battery_power (and the source data, "Battery Power" in the soliscloud.com UI) are always positive for me -- "Battery Current" goes positive/negative.

jmason avatar Nov 28 '22 17:11 jmason

Just checked tonight and weirdly, now I'm getting a positive value for a discharge when it should be a negative one. Bit late for me to start investigating but will update tomorrow. Need to see what the api is spitting out in it's raw form.

viking2010 avatar Nov 29 '22 23:11 viking2010

Curiouser and Curiouser, mine is still negative.

On Tue, 29 Nov 2022, 23:45 viking2010, @.***> wrote:

Just checked tonight and weirdly, now I'm getting a positive value for a discharge when it should be a negative one. Bit late for me to start investigating but will update tomorrow. Need to see what the api is spitting out in it's raw form.

— Reply to this email directly, view it on GitHub https://github.com/hultenvp/solis-sensor/issues/158#issuecomment-1331462675, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWZJKZR37GZR4ZSANZLDYDWK2IQHANCNFSM6AAAAAAQOHMLLU . You are receiving this because you were mentioned.Message ID: @.***>

LucidityCrash avatar Nov 30 '22 21:11 LucidityCrash

ok, so tested today and if I look back at my history for the battery sensor, it clearly shows that it was going negative at one point.

image

...but since sometime on the 28th, that's when it stopped providing the negative number and now shows it as positive when charging or discharging. Looking over the output of the .py test script, the number in there is positive too. As @lynxus mentioned further back in this thread, the Station Detail shows a negative number: "batteryPower": -0.375, whereas the inverter detail shows: "batteryPower": 0.375.

@LucidityCrash, if the inverter detail for you is providing a negative number, do you see the same in the station detail?

I presume we're all using the newer Solis Cloud site and not the original Ginlong one? Could that be the difference?

viking2010 avatar Dec 01 '22 23:12 viking2010

StationDetail : "batteryPower": -0.093,

InverterDetail ; "batteryPower": -0.093,

image

And yes ... I'm using SolisCloud :)

LucidityCrash avatar Dec 02 '22 08:12 LucidityCrash

Mind blown! 🤯

viking2010 avatar Dec 02 '22 09:12 viking2010

@lynxus & @LucidityCrash just another thought, do you have the newer or older style Data Logging stick? I have recently swapped to the new one with the LED's on the front, and it occurred to me that the dates when my stats changed from showing the negative number was on the same day I swapped to the new logger. That's the only other change I can think of that could be why things are different. If not, I give up lol!!

viking2010 avatar Dec 02 '22 15:12 viking2010

@lynxus & @LucidityCrash just another thought, do you have the newer or older style Data Logging stick? I have recently swapped to the new one with the LED's on the front, and it occurred to me that the dates when my stats changed from showing the negative number was on the same day I swapped to the new logger. That's the only other change I can think of that could be why things are different. If not, I give up lol!!

I do have the newer one I guess. LEDs on front. My install is very new.

I've found so many oddities within the Solis API it's painful.

lynxus avatar Dec 02 '22 15:12 lynxus