GithubHelp home page GithubHelp logo

Comments (22)

darek-margas avatar darek-margas commented on August 10, 2024 1

It is not only the above. gridstatus is also required as it makes load signed. From other sections "energeStatisticsCharts" and "energeStatisticsTotals" are useful for energy dash.

Here is my old code modification:

        for key, value in jsonResponseFinal["data"]["inverter"][0]["invert_full"].items():
            if(key is not None and value is not None):
                self._attributes[key] = value
                _LOGGER.debug("Updated attribute %s: %s", key, value)
        for key, value in jsonResponseFinal["data"]["powerflow"].items():
            if(key is not None and value is not None):
                self._attributes[key] = value
                _LOGGER.debug("Updated attribute %s: %s", key, value)
        # if jsonResponseFinal["data"].get('hasEnergeStatisticsCharts') == 'true' :
        #if jsonResponseFinal["data"].get("hasEnergeStatisticsCharts") != "true" :
        for key, value in jsonResponseFinal["data"]["energeStatisticsCharts"].items():
            if(key is not None and value is not None):
                self._attributes[key] = value
                _LOGGER.debug("Updated attribute %s: %s", key, value)

        self._attributes['loadw'] =  self.parseValue(jsonResponseFinal["data"]["powerflow"].get('load'), ' (W) ')
        self._attributes['gridw'] =  self.parseValue(jsonResponseFinal["data"]["powerflow"].get('grid'), ' (W) ')
        self._attributes['outputpower'] =  self.parseValue(jsonResponseFinal["data"]["powerflow"].get('pv'), ' (W) ')
        self._attributes['energyin'] =  jsonResponseFinal["data"]["energeStatisticsTotals"].get('buy')
        self._attributes['energyout'] =  jsonResponseFinal["data"]["energeStatisticsTotals"].get('sell')
        self._attributes['energytotal'] =  jsonResponseFinal["data"]["energeStatisticsTotals"].get('sum')
        if self._attributes['loadStatus'] == -1 :
            self._attributes['PowerFlowDirection'] = 'Export %s' % self._attributes['grid']
        if self._attributes['loadStatus'] == 1 :
            self._attributes['PowerFlowDirection'] = 'Import %s' % self._attributes['grid']
        self._attributes['signedgrid'] = self._attributes['loadStatus'] * self._attributes['gridw']

from goodwe-sems-home-assistant.

TimSoethout avatar TimSoethout commented on August 10, 2024 1

Good work!
It seems you should be able to add similar code to

def extra_state_attributes(self):

I can't really test anything at the moment unfortunately, next to not having GoodWe Home Kit, my panels are removed from the roof due to a renovation. They should be back before end of the year.

from goodwe-sems-home-assistant.

Logzy72 avatar Logzy72 commented on August 10, 2024 1

from goodwe-sems-home-assistant.

darek-margas avatar darek-margas commented on August 10, 2024 1

It is standalone and my inverter has own CT clamp for limiting. However, there is relation defined and reflected in API. As HK provides metrics needed for energy screen I bet best concept would be to make it on this second sensor.

root@zabbix:~# cat myjason | jq .data.equipment
[
{
"type": "5",
"title": "Goodwe here",
"status": 1,
"statusText": null,
"capacity": null,
"actionThreshold": null,
"subordinateEquipment": "",
"powerGeneration": "Power:8.53(kW)",
"eday": "Generation Today: 43.1(kWh)",
"brand": "",
"isStored": false,
"soc": "SOC:100%",
"isChange": false,
"relationId": "some weird string",
"sn": "inverter serial",
"has_tigo": false,
"is_sec": false,
"is_secs": false,
"targetPF": null,
"exportPowerlimit": null
},
{
"type": "1",
"title": "MyHomeKit",
"status": 1,
"statusText": null,
"capacity": null,
"actionThreshold": null,
"subordinateEquipment": "Data Logger: here is serial from HK",
"powerGeneration": null,
"eday": null,
"brand": null,
"isStored": false,
"soc": null,
"isChange": false,
"relationId": "another weird string",
"sn": "here is inverter serial",
"has_tigo": false,
"is_sec": false,
"is_secs": false,
"targetPF": null,
"exportPowerlimit": null
}
]

So, it could extend inverter by matching the above. Maybe they expect several HK sets per site?

from goodwe-sems-home-assistant.

TimSoethout avatar TimSoethout commented on August 10, 2024

Hi, I'm not sure what you want? Home Kit is from Apple, right? I guess that integration is handled by Home Assistant and not this individual plugin?

from goodwe-sems-home-assistant.

darek-margas avatar darek-margas commented on August 10, 2024

https://www.goodwe.com.au/monitoring-system/homekit-299_7.asp
Readable from the same SEMS API. Does report consumption, etc.

from goodwe-sems-home-assistant.

Logzy72 avatar Logzy72 commented on August 10, 2024

I've also got the Goodwe Homekit and would like to see the house consumption etc in HA.
Did you fork this with additional code. If so, where can I find this.?
Specifically it would be great to see consumption, solar gererated and returned to grid.

from goodwe-sems-home-assistant.

TimSoethout avatar TimSoethout commented on August 10, 2024

from goodwe-sems-home-assistant.

Logzy72 avatar Logzy72 commented on August 10, 2024

from goodwe-sems-home-assistant.

TimSoethout avatar TimSoethout commented on August 10, 2024

I see. Well.. Since I don't own a GoodWe HomeKit, I can't integrate it.
You can create a pull request with this?
Or you gave provide me with the JSON from the API and which fields you need specifically added. I don't have much spare time in the coming weeks though. :)

from goodwe-sems-home-assistant.

darek-margas avatar darek-margas commented on August 10, 2024

I've also got the Goodwe Homekit and would like to see the house consumption etc in HA. Did you fork this with additional code. If so, where can I find this.? Specifically it would be great to see consumption, solar gererated and returned to grid.

I did fork it recently but did not write anything yet. I've made working code from version 1 just never made it public as it is mess with no conditions, etc, just assuming homekit is present.

With this newer version I had a few thoughts but got stuck between adding simplest code or, say, trying to discover its presence, matching with inverter, etc.

If someone else has more time and experience I am happy to provide json with description what is what and for what exactly.
SEMS API, however, is not perfect. HK provides another instance of generation plus grid clamp reading. Generation slightly differs compared to inverter reading. For grid clamp API returns just unsigned power and then grid status as 1 or -1 which then can be used to make signed power or two separate values when one is always 0. With accumulated generation/usage values for some reason API winds back values after midnight. Not much but still like 1h usage on average. I didn't find its cause and as this confuses energy dashboard I used Riemann sum calculated from power.

from goodwe-sems-home-assistant.

Logzy72 avatar Logzy72 commented on August 10, 2024

I'm no coder or programmer however I do tinker and try to learn it.
Yes it would be good to see your json with your description of what is what for the Homekit.

from goodwe-sems-home-assistant.

Ads5555 avatar Ads5555 commented on August 10, 2024

Hi, in the data property there are 2 relevant properties, hasPowerflow and powerflow. This contains the homekit data. I think 'home kit' is just the goodwe name for their monitoring add-on, nothing to do with Apple.

        "hasPowerflow": true,
        "powerflow": {
            "pv": "1536(W)",
            "pvStatus": -1,
            "bettery": "0(W)",
            "betteryStatus": 0,
            "betteryStatusStr": null,
            "load": "909(W)",
            "loadStatus": -1,
            "grid": "627(W)",
            "soc": 0,
            "socText": "No battery",
            "hasEquipment": true,
            "gridStatus": 1,
            "isHomKit": true,
            "isBpuAndInverterNoBattery": false,
            "isMoreBettery": false
        },

The properties we would need are pv (what the solar system generates), load (what the house uses) and grid (the excess sent back to the grid).

image

Whilst I am a dev but not a python dev I will look to create a PR but it might take a little bit of time for me. If you have the knowledge to easily add powerflow to the data[sn] property as a child attribute, that would be great.

Full Json: https://pastebin.com/F90mhdqA

from goodwe-sems-home-assistant.

darek-margas avatar darek-margas commented on August 10, 2024

Good work! It seems you should be able to add similar code to

def extra_state_attributes(self):

I can't really test anything at the moment unfortunately, next to not having GoodWe Home Kit, my panels are removed from the roof due to a renovation. They should be back before end of the year.

Yes, I looked at that. I got stuck as you take in api [data][inverter] which is too narrow. Either I need to add two conditions to find if HK is present and if so then add further data to pass to sensor and then, in sensor parse more not just inverters in inverter. Or, the other way round, take [data] and pass to sensor and move logic over. I was unable to decide which way is easier and make less mess :P

from goodwe-sems-home-assistant.

Ads5555 avatar Ads5555 commented on August 10, 2024

I think we might have to return all the data in:

def getData(self, powerStationId, renewToken=False, maxTokenRetries=2):

The caller will need to dig into the inverter property to retain existing functionality. From there you could add the other nodes we want to data (e.g. powerflow) and then the extra_state_attributes() method could clean up the data we want (e.g. remove 'W' in pv, load, grid) to add them as attributes.

Final direction probably needs to come from @TimSoethout to since its his code base :)

from goodwe-sems-home-assistant.

darek-margas avatar darek-margas commented on August 10, 2024

ok, so to wrap it up, first there is a way to check (I believe) if that install has homekit and these sections:

root@zabbix:~# cat myjason | jq .data.hasPowerflow
true

then, if the above is true, we have three sections to extract and append in api:
root@zabbix:~# cat myjason | jq .data.powerflow

{
"pv": "8558(W)",
"pvStatus": -1,
"bettery": "0(W)",
"betteryStatus": -1,
"betteryStatusStr": null,
"load": "852(W)",
"loadStatus": -1,
"grid": "7706(W)",
"soc": 0,
"socText": "0%",
"hasEquipment": true,
"gridStatus": 1,
"isHomKit": true,
"isBpuAndInverterNoBattery": false,
"isMoreBettery": false
}
root@zabbix:~# cat myjason | jq .data.energeStatisticsCharts

{
"contributingRate": 0.66,
"selfUseRate": 0.16,
"sum": 42.62,
"buy": 3.67,
"buyPercent": 34.5,
"sell": 35.64,
"sellPercent": 83.6,
"selfUseOfPv": 6.98,
"consumptionOfLoad": 10.65,
"chartsType": 1,
"hasPv": true,
"hasCharge": false,
"charge": 0,
"disCharge": 0
}
root@zabbix:~# cat myjason | jq .data.energeStatisticsCharts

{
"contributingRate": 0.66,
"selfUseRate": 0.16,
"sum": 42.62,
"buy": 3.67,
"buyPercent": 34.5,
"sell": 35.64,
"sellPercent": 83.6,
"selfUseOfPv": 6.98,
"consumptionOfLoad": 10.65,
"chartsType": 1,
"hasPv": true,
"hasCharge": false,
"charge": 0,
"disCharge": 0
}

Then, as it will return more or fewer items to sensor, it would have to find this structure, extract [inverter] regardless of anything else present, and finally find these 3 items and extract into sensors+attributes. Or one sensor, say, sensor.homekit with all these attributes.

Still missing piece for me is how to handle first condition - if is false then data passed to sensor will remain as is but when is true it will get more which had to be split from bigger dictionary.

from goodwe-sems-home-assistant.

Ads5555 avatar Ads5555 commented on August 10, 2024

I think that all the properties need to be added to the dictionary whether 'hasPowerflow` is true or false. For those that do have it the homekit, all the properties would have the actual value but otherwise it would be just a default value (ints would be 0, bools would be false, etc).

The reason I can see that this is necessary is that if the homekit goes on and offline often (since its an independent wifi device to the inverter), we wouldnt want our HA setups throwing errors on missing properties.

from goodwe-sems-home-assistant.

darek-margas avatar darek-margas commented on August 10, 2024

Do we know these sections appear on account not having HK installed?

from goodwe-sems-home-assistant.

Ads5555 avatar Ads5555 commented on August 10, 2024

Cant say. I just had HK installed this morning and didnt look beforehand lol. I would assume they arent present. Thats the worst case scenario.

from goodwe-sems-home-assistant.

TimSoethout avatar TimSoethout commented on August 10, 2024

I guess the design/achitecture decissions comes down to this:

We now have 2 sensors per inverter:

  • 1 sensor for Inverter + attributes
  • 1 extra sensor with total kWh for inverter for HA Energy Dashboard

Is this Home Kit per inverter? Then add to the existing sensor as attributes. Else we need to add a separate sensor for it.
This also guides where we should store the data.

I see @darek-margas proposes something similar. :)

from goodwe-sems-home-assistant.

Ads5555 avatar Ads5555 commented on August 10, 2024

Is this Home Kit per inverter

I am not sure but it doesn't look like it is as the SEMS dashboard allows you to register them separately at a single location suggesting you could add multiple. Not sure how having multiple devices monitoring home power usage against a single PV generation source would work in practice though.

from goodwe-sems-home-assistant.

Ads5555 avatar Ads5555 commented on August 10, 2024

Created this. Let me know what you think, my first attempt at python and HA integration. #58

from goodwe-sems-home-assistant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.