1- import growattServer
1+ """
2+ Example script for interfacing with classic inverter configuration settings.
3+
4+ This script demonstrates how to interface with the configuration settings of a
5+ plant and its classic inverters. It uses the `update_classic_inverter_setting`
6+ function to apply settings to a classic inverter.
7+ """
8+
29import getpass
310import pprint
411
5- """
6- This script demonstrates how to interface with the configuration settings of a plant and its classic inverters.
7- It uses the `update_classic_inverter_setting` function to apply settings to a classic inverter.
8- """
12+ import growattServer
13+
914pp = pprint .PrettyPrinter (indent = 4 )
1015
1116# Prompt user for username
1419# Prompt user to input password
1520user_pass = getpass .getpass ("Enter password:" )
1621
17- api = growattServer .GrowattApi (True , username )
22+ api = growattServer .GrowattApi (add_random_user_id = True , agent_identifier = username )
1823login_response = api .login (username , user_pass )
1924
20- plant_list = api .plant_list (login_response [' user' ][ 'id' ])
25+ plant_list = api .plant_list (login_response [" user" ][ "id" ])
2126
2227# Simple logic to just get the first inverter from the first plant
2328# Expand this using a for-loop to perform for more systems
24- plant = plant_list ['data' ][0 ] # This is an array - we just take the first - would need a for-loop for more systems
25- plant_id = plant ['plantId' ]
26- plant_name = plant ['plantName' ]
29+ # This is an array - we just take the first - would need a for-loop for
30+ # more systems
31+ plant = plant_list ["data" ][0 ]
32+ plant_id = plant ["plantId" ]
33+ plant_name = plant ["plantName" ]
2734plant_info = api .plant_info (plant_id )
2835
2936devices = api .device_list (plant_id )
30- device = devices [0 ] # This is an array - we just take the first - would need a for-loop for more systems
31- device_sn = device ['deviceSn' ]
32- device_type = device ['deviceType' ]
37+ device = devices [
38+ 0
39+ ] # This is an array - we just take the first - would need a for-loop for more systems
40+ device_sn = device ["deviceSn" ]
41+ device_type = device ["deviceType" ]
3342
3443# Turn inverter on
3544print ("Turning on inverter: %s" % (device_sn ))
4251
4352parameters = {
4453 "paramId" : "pv_on_off" ,
45- "command_1" : "0001" , # 0001 to turn on, 0000 to turn off
54+ "command_1" : "0001" , # 0001 to turn on, 0000 to turn off
4655 "command_2" : "" , # Empty string for command_2 as not used
4756}
4857response = api .update_classic_inverter_setting (default_parameters , parameters )
49- print (response )
58+ print (response )
0 commit comments