Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/shinephone.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Any methods that may be useful.
| `api.update_noah_settings(serial_number, setting_type, parameters)` | serial_number: String, setting_type: String, parameters: Dict/Array | Apply the provided parameters for the specified setting on the specified Noah device. see: [details](./shinephone/noah_settings.md) |
| `api.update_classic_inverter_setting(default_parameters, parameters)` | default_parameters: Dict, parameters: Dict/Array | Applies settings for specified system based on serial number. This function is only going to work for classic inverters. |
| `api.classic_inverter_info(device_sn)` | device_sn: String | Get classic inverter information (including on/off status) by scraping the inverter settings page. Returns a dict with fields like `onOff`, `deviceModel`, `status`, `fwVersion`, `sn`, `alias`, etc. Note: this works by parsing HTML, not a JSON API. |
| `api.set_classic_inverter_active_power_rate(serial_number, power_rate)` | serial_number: String, power_rate: Int (0-100) | Set the active power rate (output power limit) for a classic inverter. Power rate is a percentage of the inverter's rated capacity (e.g., 50 = 50% output). |
| `api.set_classic_inverter_on_off(serial_number, enabled)` | serial_number: String, enabled: Bool | Turn a classic inverter on (`enabled=True`) or off (`enabled=False`). When off, the inverter stops producing power completely. |

### Variables

Expand Down Expand Up @@ -102,4 +104,4 @@ This is based on the endpoints used on the mobile app and could be changed witho

The settings for the Plant and Inverter have been reverse engineered by using the ShinePhone Android App and the NetCapture SSL application together to inspect the API calls that are made by the application and the parameters that are provided with it.

See: [Reverse Engineered](./shinephone/reverse_engineering.md)
See: [Reverse Engineered](./shinephone/reverse_engineering.md)
29 changes: 16 additions & 13 deletions examples/settings_example_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,22 @@
on_off = inverter_info["onOff"]
print(f"Inverter on/off status: {'on' if on_off == '1' else 'off'}")

# Turn inverter on
# Turn inverter on using the convenience method
print(f"Turning on inverter: {device_sn}")
response = api.set_classic_inverter_on_off(device_sn, enabled=True)
print(response)

# Turn inverter off
print(f"Turning off inverter: {device_sn}")
response = api.set_classic_inverter_on_off(device_sn, enabled=False)
print(response)

# Set active power rate to 50% (limits output power to 50% of rated capacity)
print(f"Setting active power rate to 50% for inverter: {device_sn}")
response = api.set_classic_inverter_active_power_rate(device_sn, power_rate=50)
print(response)

# Set up the default parameters
default_parameters = {
"action": "inverterSet",
"serialNum": device_sn,
}

parameters = {
"paramId": "pv_on_off",
"command_1": "0001", # 0001 to turn on, 0000 to turn off
"command_2": "", # Empty string for command_2 as not used
}
response = api.update_classic_inverter_setting(default_parameters, parameters)
# Set active power rate back to 100% (full power output)
print(f"Setting active power rate to 100% for inverter: {device_sn}")
response = api.set_classic_inverter_active_power_rate(device_sn, power_rate=100)
print(response)
50 changes: 50 additions & 0 deletions growattServer/base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,3 +1402,53 @@ def update_classic_inverter_setting(self, default_parameters, parameters):
params=settings_parameters)

return response.json()

def set_classic_inverter_active_power_rate(self, serial_number, power_rate):
"""
Set the active power rate (output power limit) for a classic inverter.

Args:
serial_number: Inverter serial number.
power_rate: Active power rate as percentage (0-100).

Returns:
dict: Server JSON response.

"""
default_parameters = {
"action": "inverterSet",
"serialNum": serial_number,
}

parameters = {
"paramId": "pv_active_p_rate",
"command_1": str(power_rate),
"command_2": "",
}

return self.update_classic_inverter_setting(default_parameters, parameters)

def set_classic_inverter_on_off(self, serial_number, enabled):
"""
Turn a classic inverter on or off.

Args:
serial_number: Inverter serial number.
enabled: True to turn on, False to turn off.

Returns:
dict: Server JSON response.

"""
default_parameters = {
"action": "inverterSet",
"serialNum": serial_number,
}

parameters = {
"paramId": "pv_on_off",
"command_1": "0001" if enabled else "0000",
"command_2": "",
}

return self.update_classic_inverter_setting(default_parameters, parameters)