Kotty666 / dbus-growatt-shinex

Growatt_Victron_connector
MIT License
15 stars 5 forks source link

3 phase #4

Closed Fc19852008 closed 5 months ago

Fc19852008 commented 1 year ago

Hi. Thanks for your Work. ITS possible to do it with an 3 phase growatt?

Thanks

Kotty666 commented 1 year ago

Hi @Fc19852008, yes it should work with the 3Phase Inverters, but i'm not able to test because i don't own one. The Script reads the Json 124 Version Protocoll implemented in https://github.com/otti/Growatt_ShineWiFi-S and this is able to show the 3Phase system.

Fc19852008 commented 1 year ago

Hi @Kotty666, thanks i try but get a wrong Visualation. In the List its correct, but in VRM an Visualation its Wrong. And i had 2 of them in the list. The other PV inverter (Car) is an opendtu.

Thanks a lot Wrong Right

Fc19852008 commented 1 year ago

right data

Kotty666 commented 1 year ago

@Fc19852008 , this is strange i'll look after that. If you are interrested, i'm also available at the discord from 'Meine Energiewende' ( https://discord.gg/97TrQqVNWX )

gonzo7734 commented 1 year ago

image

The position in the VRM and remote console can be changed by editing the dbus position parameter. it's in / near line 55 in dbus-growatt-shinex.py

take a look at the documentation: https://github.com/victronenergy/venus/wiki/dbus#pv-inverters

gonzo7734 commented 1 year ago

@Kotty666 @Fc19852008 I did some research:

I seems like the growatt's minimum current for all phases (L1, L2, L3) is 0.5A. I never see less in JSON or on display of growatt mod15ktl-x.

here are some pictures of growatt inverter display from today, 18:12 o'clock: MOD15ktl-x - OutputPower MOD15ktl-x - PV1-Power MOD15ktl-x - PV2-Power MOD15ktl-x - Phase L1, L2, L3 - Current

JSON reads at that time: {"InverterStatus":1,"InputPower":13.8,"PV1Voltage":143.4,"PV1InputCurrent":0,"PV1InputPower":0,"PV2Voltage":142.2,"PV2InputCurrent":0,"PV2InputPower":0,"OutputPower":13.6,"GridFrequency":50.01,"L1ThreePhaseGridVoltage":235,"L1ThreePhaseGridOutputCurrent":0.5,"L1ThreePhaseGridOutputPower":117.5,"L2ThreePhaseGridVoltage":238.6,"L2ThreePhaseGridOutputCurrent":0.5,"L2ThreePhaseGridOutputPower":119.3,"L3ThreePhaseGridVoltage":230.2,"L3ThreePhaseGridOutputCurrent":0.5,"L3ThreePhaseGridOutputPower":115.1,"TodayGenerateEnergy":7.1,"TotalGenerateEnergy":297.8,"TWorkTimeTotal":563834.5,"PV1EnergyToday":3.2,"PV1EnergyTotal":173.9,"PV2EnergyToday":2.7,"PV2EnergyTotal":151.8,"PVEnergyTotal":325.7,"InverterTemperature":53.3,"TemperatureInsideIPM":24.8,"BoostTemperature":22.3,"DischargePower":0,"ChargePower":0,"BatteryVoltage":0,"SOC":0,"ACPowerToUser":0,"ACPowerToUserTotal":0,"ACPowerToGrid":0,"ACPowerToGridTotal":0,"INVPowerToLocalLoad":0,"INVPowerToLocalLoadTotal":0,"BatteryTemperature":0,"BatteryState":0,"EnergyToUserToday":0,"EnergyToUserTotal":0,"EnergyToGridToday":0,"EnergyToGridTotal":0,"DischargeEnergyToday":0,"DischargeEnergyTotal":0,"ChargeEnergyToday":0,"ChargeEnergyTotal":0,"LocalLoadEnergyToday":0,"LocalLoadEnergyTotal":0,"Mac":"40:22:D8:XX:XX:XX","Cnt":9392}

Your script pushes this to VenusOS / VRM correctly. Growatt_ShineWiFi-S reads the data correctly, too. VenusOS - MOD15KTL VRM

The solution should be: Get the value of 'OutputPower', divide by count of phases, and provide the mathematical result as L1ThreePhaseGridOutputPower & L2ThreePhaseGridOutputPower & L3ThreePhaseGridOutputPower.

R0Li84 commented 5 months ago

Hi, I have exactly the same issue and could not fix it so far. Did anyone already manage this? If so, can somebody pls provide an upate of this code?

Kotty666 commented 5 months ago

@R0Li84 @gonzo7734 @Fc19852008

Sorry for the delay but i was very busy and there is no Growatt anymore here at my location. I'll try to fix that issue.

Kotty666 commented 5 months ago

@R0Li84 @gonzo7734 @Fc19852008 i've made some changes are you able to test it? Code could be found here: https://github.com/Kotty666/dbus-growatt-shinex/tree/issue4

R0Li84 commented 5 months ago

@Kotty666 - tested it, seems to work for me. (I fixed that for myself upfront with a little different code, however you solution seems to be the better one).

However, there is another bug, maybe you would also able to support here? I noted that (like also shown here in some pics) that even during night the inverter shows a low power supply (about 300W, its not always exactly the same value).

As I understand this issue, the most likely reason is that the inverter shuts of at 0,5A which turns down the WiFi stick? Then most likely the code does not recognize this and the "simulates a running inverter"? When I perform a restart of Venus OS, your code recognizes that the inverter is not running and starts again in the morning.

My Idea was that I could implement a code that checks if the Current is 0.5A (thats the case at my system when the inverter stops working) and that if so, the script restarts (instead of restarting venus OS). However, that did not work out. Maybe you have an idea? (I could also imagine, to only surpress very low currents / voltages by reporting currents <= 0.5 with 0).

#CODE NOT WORKING#
def _update(self):
    try:
        config = self._getConfig()
        phase = config['DEFAULT']['Phase']
        #get data from Shine X

        #send data to DBus
        meter_data = self._getShineXData()
        if meter_data is False:
          logging.info("Did not got valid Json.")
          return True

        # Check if all three phases are sending a constant value of 0.5
        if (meter_data['L1ThreePhaseGridOutputCurrent'] == 0.5 and
            meter_data['L2ThreePhaseGridOutputCurrent'] == 0.5 and
            meter_data['L3ThreePhaseGridOutputCurrent'] == 0.5):
            current_time = time.time()
            # Check if at least 30 minutes have passed since the last restart
            if (current_time - self._lastRestart > 1800):
                logging.info("All three phases are sending a constant value of 0.5, restarting script.")
                self._lastRestart = current_time
                os.execv(sys.executable, ['python'] + sys.argv)  # Restart the script
            else:
                logging.info("All three phases are sending a constant value of 0.5, but restart interval has not passed.")

        # ... rest of the existing code ...

        self._dbusservice['/UpdateIndex'] = (self._dbusservice['/UpdateIndex'] + 1 ) % 256
        self._lastUpdate = time.time()
    except Exception as e:
        logging.critical('Error at %s', '_update', exc_info=e)

    # return true, otherwise add_timeout will be removed from GObject - see docs
    return True
Kotty666 commented 5 months ago

I think the WifiStick is not turned off. I've added some code depending on the PVINput Power - could you try this version? Restarting the Script is not a good Idea i think.

R0Li84 commented 5 months ago

Thanks a lot @Kotty666! Yes: restarting the script is not the best idea for sure, I'm not a programmer (only had some basic training with FORTRAN during my studies 15y ago). Just tried that out because I noticed that a restart of VENUS OS helps.

I'm happy to try your solution. Already updated with the "test for PV-Out" version. It's running well, however I need to check during night time if the issue is gone. I will provide an update tomorrow.

R0Li84 commented 5 months ago

I works now much better. The current goes down to 0 - however, it still shows a minimum power from the inverter.

![Uploading Screenshot 2024-05-16 215827.png…]()

Kotty666 commented 5 months ago

@R0Li84 i'm not able to see the Picture - could you send it and is it possible to get the json output at this time?

R0Li84 commented 5 months ago

Sorry for the delay - i was quite busy today. Here is the picutre. Screenshot 2024-05-17 233644

JSON (not sure if thats the one you are looking for): {"wifi_sta":{"connected":true,"ssid":"WLAN_SSID","ip":"192.168.15.92","rssi":-78},"cloud":{"enabled":true,"connected":true},"mqtt":{"connected":false},"time":"13:27","unixtime":1649680054,"serial":17,"has_update":false,"mac":"84CCA8B15999","cfg_changed_cnt":0,"actions_stats":{"skipped":0},"relays":[{"ison":false,"has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"overpower":false,"is_valid":true,"source":"input"}],"emeters":[{"power":882.47,"reactive":-669.60,"pf":-0.80,"voltage":246.18,"is_valid":true,"total":1233779.9,"total_returned":596.5},{"power":0.00,"reactive":0.00,"pf":0.00,"voltage":246.18,"is_valid":true,"total":0.0,"total_returned":0.0}],"update":{"status":"idle","has_update":false,"new_version":"20220209-094734/v1.11.8-g8c7bb8d","old_version":"20220209-094734/v1.11.8-g8c7bb8d"},"ram_total":50256,"ram_free":27336,"fs_size":233681,"fs_free":157628,"uptime":1056}

Kotty666 commented 5 months ago

@R0Li84 - looks strange :( I mean the json from the growat stick (http:///status) this you've postet seems to be some different

R0Li84 commented 5 months ago

@Kotty666 - below is the JSON log from the inverter. I could not access the inverter during night, so it really seems that the USB stick does not send any signal and that the latest data that has been received is considered as the actual data due to missing updates. After the update, it sometimes shows a very low power (about 27W), but sometimes it can also be up to 400W.

status: {"InverterStatus":1,"InputPower":1344.6,"PV1Voltage":492.3,"PV1InputCurrent":0.4,"PV1InputPower":196.9,"PV2Voltage":347.8,"PV2InputCurrent":3.3,"PV2InputPower":1147.7,"OutputPower":1335.1,"GridFrequency":49.97,"L1ThreePhaseGridVoltage":231.8,"L1ThreePhaseGridOutputCurrent":1.9,"L1ThreePhaseGridOutputPower":440.4,"L2ThreePhaseGridVoltage":231.5,"L2ThreePhaseGridOutputCurrent":2,"L2ThreePhaseGridOutputPower":463,"L3ThreePhaseGridVoltage":232.3,"L3ThreePhaseGridOutputCurrent":2,"L3ThreePhaseGridOutputPower":464.6,"TodayGenerateEnergy":0.3,"TotalGenerateEnergy":3594.4,"TWorkTimeTotal":7633639,"PV1EnergyToday":0,"PV1EnergyTotal":1908,"PV2EnergyToday":0.2,"PV2EnergyTotal":1453.9,"PVEnergyTotal":3361.9,"InverterTemperature":48,"TemperatureInsideIPM":26.8,"BoostTemperature":25.6,"DischargePower":0,"ChargePower":0,"BatteryVoltage":0,"SOC":0,"ACPowerToUser":0,"ACPowerToUserTotal":0,"ACPowerToGrid":0,"ACPowerToGridTotal":0,"INVPowerToLocalLoad":0,"INVPowerToLocalLoadTotal":0,"BatteryTemperature":0,"BatteryState":0,"EnergyToUserToday":0,"EnergyToUserTotal":0,"EnergyToGridToday":0,"EnergyToGridTotal":0,"DischargeEnergyToday":0,"DischargeEnergyTotal":0,"ChargeEnergyToday":0,"ChargeEnergyTotal":0,"LocalLoadEnergyToday":0,"LocalLoadEnergyTotal":0,"ACChargeEnergyToday":0,"ACChargeEnergyTotal":0,"Mac":"3C:E9:0E:C0:80:EC","Cnt":657}

uistatus: {"InverterStatus":[1,"(Normal Operation)",false],"InputPower":[1392.3,"W",true],"OutputPower":[1371.5,"W",true],"TodayGenerateEnergy":[0.4,"kWh",false],"TotalGenerateEnergy":[3594.5,"kWh",false],"InverterTemperature":[48.1,"°C",true],"DischargePower":[0,"W",true],"ChargePower":[0,"W",true],"SOC":[0,"%",true],"INVPowerToLocalLoadTotal":[0,"W",false],"BatteryTemperature":[0,"°C",true],"BatteryState":[0,"",false],"EnergyToUserToday":[0,"kWh",false],"EnergyToUserTotal":[0,"kWh",false],"EnergyToGridToday":[0,"kWh",false],"EnergyToGridTotal":[0,"kWh",false],"DischargeEnergyToday":[0,"kWh",false],"DischargeEnergyTotal":[0,"kWh",false],"ChargeEnergyToday":[0,"kWh",false],"ChargeEnergyTotal":[0,"kWh",false],"LocalLoadEnergyToday":[0,"kWh",false],"LocalLoadEnergyTotal":[0,"kWh",false],"ACChargeEnergyToday":[0,"kWh",false],"ACChargeEnergyTotal":[0,"kWh",false]}

Kotty666 commented 5 months ago

@R0Li84 i've change some stuff you coud try again hopefully the last change :)

R0Li84 commented 5 months ago

Hey, thanks for the update. I have already tried it out, and would need some more days to provide you a final statement.

What I observed so far:

I may not be able to provide an update within the next days, as I will be a week on vacation. But I will monitor the situation and provide you with my findings as soon as I'm back (beginning of June).

Kotty666 commented 5 months ago

@R0Li84 is it still working? And are you able to catch some Log informations at the time where the Inverter reporting 0 and the script reporting more than this?

Kotty666 commented 5 months ago

@R0Li84 i'd also changed some stuff today please try this one. Also the logging was changed so please also pull the install.sh and service/log/run from the branch so the better log mechanism will work