indykoning / PyPi_GrowattServer

MIT License
79 stars 33 forks source link

"Import from grid" is missing on MIN 6000TL-XE #85

Open kapytan88 opened 2 months ago

kapytan88 commented 2 months ago

Hi,

How can I have "Import from grid" value into Home Assistant?

All the sensors I have :

AC frequency All batteries charged today All batteries discharged today Battery 1 charging W Battery 1 discharging W Battery 2 charging W Battery 2 discharging W Energy today Energy Today Input 1 Energy Today Input 2 Energy Today Input 3 Energy Today Input 4 Export to grid today Input 1 Amperage Input 1 voltage Input 1 Wattage Input 2 Amperage Input 2 voltage Input 2 Wattage Input 3 Amperage Input 3 voltage Input 3 Wattage Input 4 Amperage Input 4 voltage Input 4 Wattage Internal wattage Lifetime energy output Lifetime total all batteries charged Lifetime total all batteries discharged Lifetime total battery 1 charged Lifetime total battery 1 discharged Lifetime total battery 2 charged Lifetime total battery 2 discharged Lifetime total energy input 1 Lifetime total energy input 2 Lifetime total energy input 3 Lifetime total energy input 4 Lifetime total export to grid Lifetime total load consumption Lifetime total solar energy Load consumption today Output power Reactive voltage Statement of charge (SoC) Temperature 1 Temperature 2 Temperature 3 Temperature 4 Temperature 5

Somehow I have figured the extract the value using a python script but it's a pain in the ... to update a sensor in home assistant with that value.

here is the python script:

import pip_system_certs.wrapt_requests
import growattServer
import datetime
import getpass
import pprint

user="my_username"
passWord="my_password"

#Utils stuff
def indent_print(to_output, indent):
  indent_string = ""
  for x in range(indent):
    indent_string += " "
  print(indent_string + to_output)

pp = pprint.PrettyPrinter(indent=4)

#Main api call
api = growattServer.GrowattApi(False,'test')
login_response = api.login(user, passWord)
#Get a list of growatt plants.
#print(api.plant_list(login_response['user']['id']))

plant_list = api.plant_list(login_response['user']['id'])
print("***List of plants***")
for plant in plant_list['data']:
  indent_print("ID: %s, Name: %s"%(plant['plantId'], plant['plantName']), 2)
print("")

for plant in plant_list['data']:
  plant_id = plant['plantId']
  plant_name = plant['plantName']
  plant_info=api.plant_info(plant_id)
  #pp.pprint(plant_info)
  print("***Info for Plant %s - %s***"%(plant_id, plant_name))
  #There are more values in plant_info, but these are some of the useful/interesting ones
  indent_print("CO2 Reducion: %s"%(plant_info['Co2Reduction']),2)
  indent_print("Nominal Power (w): %s"%(plant_info['nominal_Power']),2)
  indent_print("Solar Energy Today (kw): %s"%(plant_info['todayEnergy']),2)
  indent_print("Solar Energy Total (kw): %s"%(plant_info['totalEnergy']),2)
  print("")
  indent_print("Devices in plant:",2)
  for device in plant_info['deviceList']:
    device_sn = device['deviceSn']
    device_type = device['deviceType']
    indent_print("- Device - SN: %s, Type: %s"%(device_sn, device_type),4)

dashboard_data = api.dashboard_data(plant_id)
#pp.pprint(dashboard_data)

for device in plant_info['deviceList']:
    device_sn = device['deviceSn']
    device_type = device['deviceType']
    indent_print("**Device - SN: %s, Type: %s**"%(device_sn, device_type),2)
    indent_print("Imported from Grid (kwh) - TRUSTED:", 6)
    indent_print("dashboard_data['etouser']: %s"%(dashboard_data['etouser']), 8)
    print("")

Thank you!

Parisonee commented 1 day ago

Hello,

I have a similar inverter MIN-4200TL-XH i'm experciencing the same issue, i tried out your code and it works. did you manage to solve this issue?

Thanks