Skip to content

Commit 8a192f5

Browse files
committed
apply ruff to pulled changes from master
1 parent 8a645a1 commit 8a192f5

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

examples/settings_example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@
5252
# Get plant settings - This is performed for us inside
5353
# 'update_plant_settings' but you can get ALL of the settings using this
5454
current_settings = api.get_plant_settings(plant_id)
55-
#pp.pprint(current_settings)
5655

57-
#Get mix inverter settings
56+
# Get mix inverter settings
5857
inverter_settings = api.get_mix_inverter_settings(device_sn)
5958
pp.pprint(inverter_settings)
6059

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
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+
29
import getpass
310
import 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+
914
pp = pprint.PrettyPrinter(indent=4)
1015

1116
# Prompt user for username
@@ -14,22 +19,26 @@
1419
# Prompt user to input password
1520
user_pass = getpass.getpass("Enter password:")
1621

17-
api = growattServer.GrowattApi(True, username)
22+
api = growattServer.GrowattApi(add_random_user_id=True, agent_identifier=username)
1823
login_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"]
2734
plant_info = api.plant_info(plant_id)
2835

2936
devices = 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
3544
print("Turning on inverter: %s" % (device_sn))
@@ -42,8 +51,8 @@
4251

4352
parameters = {
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
}
4857
response = api.update_classic_inverter_setting(default_parameters, parameters)
49-
print(response)
58+
print(response)

0 commit comments

Comments
 (0)