Closed corvus2606 closed 1 year ago
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: @. @.> >
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
if you figure this out, please let me know. Ive actually been trying to get that info all day myself and no closer :)
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
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.
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 :)
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..
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..
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.
I'm going to see if I can use the info and make an improvement by adding a battery state.
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 :)
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.
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.
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)
`
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 }}
`
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.
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.
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)
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: @.***>
Let's wait till they get back online with a new API version and see if the problem persists
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:
I'll try running the test script tomorrow (assuming my battery gets some use!) and see if that value goes negative when discharging...
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:
And here's what it looks like while discharging:
"storageBatteryCurrent": -2.7,
"storageBatteryCurrentStr": "A",
"storageBatteryVoltage": 51.7,
"storageBatteryVoltageStr": "V",
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)
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
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.
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.
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: @.***>
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.
...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?
StationDetail : "batteryPower": -0.093,
InverterDetail ; "batteryPower": -0.093,
And yes ... I'm using SolisCloud :)
Mind blown! 🤯
@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!!
@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.
OOoooh possibly the cause ... you two are using the new logger ... I'm using the older logger.
On Fri, 2 Dec 2022 at 15:23, lynxus @.***> wrote:
@lynxus https://github.com/lynxus & @LucidityCrash https://github.com/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. My install is very new.
I've found so many oddities within the Solis API it's painful.
— Reply to this email directly, view it on GitHub https://github.com/hultenvp/solis-sensor/issues/158#issuecomment-1335411887, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWZJK34JVOEWPV6HYD7AQ3WLIH5NANCNFSM6AAAAAAQOHMLLU . You are receiving this because you were mentioned.Message ID: @.***>
Bingo! That's it then. Although I think from what I've been told/read/investigated, the data from the old logger goes via Solarman first, and there's some information that doesn't get pushed from Solarman to Solis, Eg the battery Over Discharge SOC and Force Charge SOC, and who knows what else is done differently! The new data logger sends the data direct to Solis, but the downside is, it doesn't have a separate server or an open port that can be queried like the old one can. It's therefore not compatible with the SolarmanPV integration. The reason I've had to change the logger is because I want the remote control functionality from the inverter via the Solis App/Portal and that doesn't seem to work with the old data logger.
So seems we've fathomed out why the negative battery figure is showing as positive. Now all I need to do is figure out where to change the code to grab it from the station detail!
@viking2010 : Could you check if inverterDay is, like StationDetail, also signed?
You can test by adding the following lines to the test app:
CanonicalizedResource = "/v1/api/inverterDay"
Body='{"id":"xxxxx","sn":"xxxx","money":"EUR","timezone":0,"time":"' + Date2 +'"}'
I'll take a look later today and let you know.
@hultenvp When running that script I get a NameError Date2 is not defined. There is a "Date" field defined, and when running with that, the output is as follows:
POST /v1/api/inverterDay
Content-MD5: PblYr09bx4mcygX4khzXhw==
Content-Type: application/json
Date: Sun, 04 Dec 2022 11:29:07 GMT
Authorization: API 130xxxxxxxxxxxxxxxxxxxxxxxxxxxx=
Body:{"id":"13xxxxxxx","sn":"16xxxxxxxxx","money":"EUR","timezone":0,"time":"Sun, 04 Dec 2022 11:29:07 GMT"}
{
"code": "1",
"data": null,
"msg": "\u6570\u636e\u5f02\u5e38 \u8bf7\u8054\u7cfb\u7ba1\u7406\u5458",
"success": true
}
I've anonymised the above for obvious reasons lol! Not sure if that's the result you expected or not.
UPDATE: I've just moved the following lines from Inverter detail to Plant Detail in Soliscloud_api.py and all is right with the world once again:
BAT_POWER: ['batteryPower', float, 3],
BAT_POWER_STR: ['batteryPowerStr', str, None]
....of course, if anyone else does this who has the new data logging stick, don't forget to comment them out in the Inverter Detail section.
@hultenvp When running that script I get a NameError Date2 is not defined. There is a "Date" field defined, and when running with that, the output is as follows:
POST /v1/api/inverterDay Content-MD5: PblYr09bx4mcygX4khzXhw== Content-Type: application/json Date: Sun, 04 Dec 2022 11:29:07 GMT Authorization: API 130xxxxxxxxxxxxxxxxxxxxxxxxxxxx= Body:{"id":"13xxxxxxx","sn":"16xxxxxxxxx","money":"EUR","timezone":0,"time":"Sun, 04 Dec 2022 11:29:07 GMT"} { "code": "1", "data": null, "msg": "\u6570\u636e\u5f02\u5e38 \u8bf7\u8054\u7cfb\u7ba1\u7406\u5458", "success": true }
I've anonymised the above for obvious reasons lol! Not sure if that's the result you expected or not.
UPDATE: I've just moved the following lines from Inverter detail to Plant Detail in Soliscloud_api.py and all is right with the world once again:
BAT_POWER: ['batteryPower', float, 3], BAT_POWER_STR: ['batteryPowerStr', str, None]
....of course, if anyone else does this who has the new data logging stick, don't forget to comment them out in the Inverter Detail section.
I have made this change and am now seeing a negative value when my battery is discharging however it's off by a factor of 1000. My Solis app shows 0.238kW but the sensor in Home Assistant shows -0.238W.
@finalbillybong yeah I get the same. Need to alter the units to kWh which you can either do manually from within the entity window.....
or I will look at altering the unit type in the relavent .py file
Just to update, in Const.py, I've updated the section starting "From homeassistant.const import" to include "POWER_KILO_WATT". Then against 'batpower' changed the unit type to POWER_KILO_WATT. That then brings it through as kW (not kWh as I put in the screen shot above!).
Hope that helps. I'm keeping a record of all the changes and may submit them as a pull request.....when I figure out exactly how to do that! lol :-D
@hultenvp When running that script I get a NameError Date2 is not defined. There is a "Date" field defined, and when running with that, the output is as follows:
POST /v1/api/inverterDay Content-MD5: PblYr09bx4mcygX4khzXhw== Content-Type: application/json Date: Sun, 04 Dec 2022 11:29:07 GMT Authorization: API 130xxxxxxxxxxxxxxxxxxxxxxxxxxxx= Body:{"id":"13xxxxxxx","sn":"16xxxxxxxxx","money":"EUR","timezone":0,"time":"Sun, 04 Dec 2022 11:29:07 GMT"} { "code": "1", "data": null, "msg": "\u6570\u636e\u5f02\u5e38 \u8bf7\u8054\u7cfb\u7ba1\u7406\u5458", "success": true }
I've anonymised the above for obvious reasons lol! Not sure if that's the result you expected or not.
@hultenvp I've found why I got no information from the "/v1/api/inverterDay", it was to do with how the date format was coming through in the $body section. I've specified the date explicitly as "2022-12-04" and I now get over 37,000 lines appear! Judging by the Epoch timestamp, it's the data gathered at 5 min intervals throughout the whole of the 4th Dec.
From the unicode it looks like the orignal message was something in Chinese.
@viking2010 Good that you managed to fix it. My idea was that if inverterDay would give back the battery power signed that it might be easy to get it out of that one. StationDetail is signed, but officially it's the sum of all batteries/inverters installed in the station, so will only substitute if you have only one. If you have more than one you need to figure out the sign for each individually installed battery in the station's scope.
@finalbillybong I'll take along the fix in unit.
@hultenvp is it easier to just send you the .py files I've edited rather than do a pull request?
@viking2010 if you send me the changed files, I'll create a pull request from them for you :)
@viking2010 @jmason: Thanks I do have the relevant changes already if needed, but I prefer to use /InverterDay over /StationDetail if it also contains signed values. Can you confirm batteryPower is signed in the inverterDay data?
@hultenvp
The output from InverterDay is below. The date format in the soliscloud_test.py I have is set as Date = now.strftime("%a, %d %b %Y %H:%M:%S GMT")
It didn't like this format and I know the code you originally sent me had Date2 in it, so I presume the format needs to be different as for me I could only get the output with the format of yyyy-mm-dd.
I've found how to sort out a pull request so I can sort that after looking over the info below as I've added a few other entities not discussed here.
POST /v1/api/inverterDay
Content-MD5: LyYuxixka7CEONgWdUkCMQ==
Content-Type: application/json
Date: Tue, 06 Dec 2022 19:37:02 GMT
Authorization: API XXXREMOVEDXXX
Body:{"id":"XXXREMOVEDXXX","sn":"XXXREMOVEDXXX","money":"GBP","timezone":0,"time":"2022-08-04"}
{
"code": "0",
"data": [
{
"acOutputType": 1,
"batteryCapacitySoc": 65.0,
"batteryChargingCurrent": 74.0,
"batteryDischargeLimiting": 74.0,
"batteryHealthSoh": 100.0,
"batteryPower": -377.0,
"batteryTodayChargeEnergy": 0.0,
"batteryTodayDischargeEnergy": 0.4,
"batteryTotalChargeEnergy": 416.0,
"batteryTotalDischargeEnergy": 467.0,
"batteryType": 0.0,
"batteryVoltage": 49.23,
"bstteryCurrent": 6.0,
"bypassAcCurrent": 0.0,
"bypassAcVoltage": 0.0,
"bypassLoadPower": 0.0,
"dataTimestamp": "1659571251000",
"dcBus": 0.0,
"dcBusHalf": 0.0,
"dcInputType": 1,
"eToday": 0.0,
"eTotal": 1975.0,
"epmFailSafe": 0.0,
"fac": 49.96,
"familyLoadPower": 204.0,
"gridPurchasedTodayEnergy": 0.0,
"gridPurchasedTotalEnergy": 0,
"gridSellTodayEnergy": 0.0,
"gridSellTotalEnergy": 0,
"homeLoadTodayEnergy": 0.4,
"homeLoadTotalEnergy": 1242.0,
"iAc1": 2.7,
"iAc2": 0.0,
"iAc3": 0.0,
"iPv1": 0.0,
"iPv10": 0.0,
"iPv11": 0.0,
"iPv12": 0.0,
"iPv13": 0.0,
"iPv14": 0.0,
"iPv15": 0.0,
"iPv16": 0.0,
"iPv17": 0.0,
"iPv18": 0.0,
"iPv19": 0.0,
"iPv2": 0.1,
"iPv20": 0.0,
"iPv21": 0.0,
"iPv22": 0.0,
"iPv23": 0.0,
"iPv24": 0.0,
"iPv25": 0.0,
"iPv26": 0.0,
"iPv27": 0.0,
"iPv28": 0.0,
"iPv29": 0.0,
"iPv3": 0.0,
"iPv30": 0.0,
"iPv31": 0.0,
"iPv32": 0.0,
"iPv4": 0.0,
"iPv5": 0.0,
"iPv6": 0.0,
"iPv7": 0.0,
"iPv8": 0.0,
"iPv9": 0.0,
"inverterTemperature": 30.4,
"llcBusVoltage": 0.0,
"pSum": 18.0,
"pac": 0.0,
"pacPec": "0.001",
"pacStr": "kW",
"pepm": 0.0,
"pepmSet": 0.0,
"pfactorLimitSet": 0.0,
"plimitSet": 0.0,
"powerFactor": 1.0,
"preactiveLimitSet": 0.0,
"socChargingSet": 0.0,
"socDischargeSet": 0.0,
"state": 1,
"storageBatteryCurrent": -7.6,
"storageBatteryVoltage": 49.7,
"time": "08:00:51",
"timeStr": "2022-08-04 00:00:51",
"timeZone": 8,
"uAc1": 242.5,
"uAc2": 0.0,
"uAc3": 0.0,
"uPv1": 2.4,
"uPv10": 0.0,
"uPv11": 0.0,
"uPv12": 0.0,
"uPv13": 0.0,
"uPv14": 0.0,
"uPv15": 0.0,
"uPv16": 0.0,
"uPv17": 0.0,
"uPv18": 0.0,
"uPv19": 0.0,
"uPv2": 3.1,
"uPv20": 0.0,
"uPv21": 0.0,
"uPv22": 0.0,
"uPv23": 0.0,
"uPv24": 0.0,
"uPv25": 0.0,
"uPv26": 0.0,
"uPv27": 0.0,
"uPv28": 0.0,
"uPv29": 0.0,
"uPv3": 0.0,
"uPv30": 0.0,
"uPv31": 0.0,
"uPv32": 0.0,
"uPv4": 0.0,
"uPv5": 0.0,
"uPv6": 0.0,
"uPv7": 0.0,
"uPv8": 0.0,
"uPv9": 0.0,
"uinitGnd": 0.0
},
To add to the above, I figured out the data/time stamp formatting (still learning!!) but I think the only format the InverterDay will accept, (according to the API documentation) is YYYY-MM-DD only. It doesn't accept a time so you can't pull just an individual record out. It produces around 177k's worth of lines of output from an entire 24hrs.
@hultenvp I can confirm it's signed in the inverterDay
output. For example, here's the battery charging:
"storageBatteryCurrent": 3.1,
"storageBatteryVoltage": 53,
"time": "19:50:41",
"timeStr": "2022-12-06 11:50:41",
and here's my battery discharging:
"storageBatteryCurrent": -3.4,
"storageBatteryVoltage": 51.6,
"time": "22:40:41",
"timeStr": "2022-12-06 14:40:41",
I've added those 2 fields (storageBatteryCurrent and storageBatteryVoltage) for SolisCloud in this PR https://github.com/hultenvp/solis-sensor/pull/227
https://github.com/hultenvp/solis-sensor/pull/227/files now contains a fix for this issue.
Fixed in rel 3.2.0
Hello @hultenvp , After the update discharge is now negative and charge is positive. You can see in the graph that during the night it was charging (negative block) and now it is using battery power (after update to 3.2.0) it is discharging (also negative). Is this expected behaviour?
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.