### Install Python Requests Library Source: https://github.com/deyeclouddevelopers/deye-openapi-client-sample-code/blob/master/README.md Install the 'requests' library, version 2.31.0, which is used by the Python samples. This is a prerequisite for running the provided code. ```bash pip install requests ``` -------------------------------- ### Get Device Latest Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Fetch the latest telemetry data for up to 10 devices per batch. Replace the example device serial numbers with your actual device serial numbers. ```python import requests from clientcode import variable url = variable.baseurl + '/device/latest' headers = variable.headers data = { "deviceList": [ "333333", # Replace with your device serial numbers "444444" ] } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"devices": [{"deviceSn": "333333", "SOC": 85, "power": 3500}]} ``` -------------------------------- ### Get Station Devices Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieves device information for a specific list of station IDs. ```python import requests from clientcode import variable url = variable.baseurl + '/station/device' headers = variable.headers data = { "page": 1, "size": 10, "stationIds": [10, 11, 12] # Replace with your station IDs } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"devices": [{"deviceSn": "333333", "type": "INVERTER"}]} ``` -------------------------------- ### Get Device Measure Points Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve available measurement points for a specific device. ```APIDOC ## POST /device/measurePoints ### Description Retrieve available measurement points for a specific device. Use these measure point names when querying device history. ### Method POST ### Endpoint /device/measurePoints ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. ### Request Example ```json { "deviceSn": "333333" } ``` ### Response #### Success Response (200) - **measurePoints** (array of strings) - A list of available measurement points for the device. #### Response Example ```json { "measurePoints": [ "SOC", "batteryPower", "gridPower", "pvPower" ] } ``` ``` -------------------------------- ### Get Station History Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve historical data for a station with configurable granularity. Options include frame, day, month, and year. Specify 'startAt' and 'endAt' dates in the appropriate format based on the chosen granularity. ```python import requests from clientcode import variable url = variable.baseurl + '/station/history' headers = variable.headers # Granularity 1 (frame): startAt format 'yyyy-MM-dd', returns intraday power data # Granularity 2 (day): startAt/endAt format 'yyyy-MM-dd', up to 31 days # Granularity 3 (month): startAt/endAt format 'yyyy-MM', up to 12 months # Granularity 4 (year): startAt/endAt format 'yyyy' data = { "stationId": 10, "granularity": 2, # Daily intervals "startAt": "2024-05-01", "endAt": "2024-05-31" } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"data": [{"date": "2024-05-01", "generation": 25.5, "consumption": 18.2}]} ``` -------------------------------- ### Get Device Latest Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Fetch the latest telemetry data for up to 10 devices per batch. ```APIDOC ## POST /device/latest ### Description Fetch the latest telemetry data for up to 10 devices per batch. ### Method POST ### Endpoint /device/latest ### Parameters #### Request Body - **deviceList** (array of strings) - Required - A list of device serial numbers. ### Request Example ```json { "deviceList": [ "333333", "444444" ] } ``` ### Response #### Success Response (200) - **devices** (array) - A list of device data. - **deviceSn** (string) - The serial number of the device. - **SOC** (integer) - The state of charge of the device. - **power** (integer) - The current power of the device. #### Response Example ```json { "devices": [ { "deviceSn": "333333", "SOC": 85, "power": 3500 } ] } ``` ``` -------------------------------- ### Get Station History Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve historical data for a station with configurable granularity. ```APIDOC ## POST /station/history ### Description Retrieve historical data for a station with configurable granularity. Granularity options: 1=frame (intraday), 2=day, 3=month, 4=year. ### Method POST ### Endpoint /station/history ### Parameters #### Request Body - **stationId** (integer) - Required - The ID of the station. - **granularity** (integer) - Required - The granularity of the data (1: frame, 2: day, 3: month, 4: year). - **startAt** (string) - Required - The start date for the historical data. Format depends on granularity. - **endAt** (string) - Optional - The end date for the historical data. Format depends on granularity. ### Request Example ```json { "stationId": 10, "granularity": 2, "startAt": "2024-05-01", "endAt": "2024-05-31" } ``` ### Response #### Success Response (200) - **data** (array) - An array of historical data points. - **date** (string) - The date of the data point (if granularity is day, month, or year). - **generation** (number) - The generation data. - **consumption** (number) - The consumption data. #### Response Example ```json { "data": [ { "date": "2024-05-01", "generation": 25.5, "consumption": 18.2 } ] } ``` ``` -------------------------------- ### Get Station Latest Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve the most recent telemetry data for a specific station. ```APIDOC ## POST /station/latest ### Description Retrieve the most recent telemetry data for a specific station. ### Method POST ### Endpoint /station/latest ### Parameters #### Request Body - **stationId** (integer) - Required - The ID of the station. ### Request Example ```json { "stationId": 10 } ``` ### Response #### Success Response (200) - **generationPower** (integer) - The current power generation. - **gridPower** (integer) - The current grid power. - **batterySOC** (integer) - The current battery state of charge. #### Response Example ```json { "generationPower": 3500, "gridPower": 1200, "batterySOC": 85 } ``` ``` -------------------------------- ### Get Device Measure Points Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve available measurement points for a specific device. These measure point names are required when querying device history. ```python import requests from clientcode import variable url = variable.baseurl + '/device/measurePoints' headers = variable.headers data = { "deviceSn": "333333" } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"measurePoints": ["SOC", "batteryPower", "gridPower", "pvPower"]} ``` -------------------------------- ### Get Device History Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve historical data for a device at various granularities with specific measure points. Ensure 'measurePoints' are valid for the selected granularity. ```python import requests from clientcode import variable url = variable.baseurl + '/device/history' headers = variable.headers # Granularity 1: startAt='yyyy-MM-dd', requires measurePoints, returns intraday data # Granularity 2: startAt/endAt='yyyy-MM-dd', up to 31 days # Granularity 3: startAt/endAt='yyyy-MM', up to 12 months # Granularity 4: startAt/endAt='yyyy', yearly data data = { "deviceSn": "333333", "granularity": 1, "startAt": "2024-05-20", "endAt": "2024-05-20", "measurePoints": ["SOC", "batteryPower"] } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"data": [{"time": "08:00", "SOC": 45, "batteryPower": 2000}]} ``` -------------------------------- ### Get Device History Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve historical data for a device at various granularities with specific measure points. ```APIDOC ## POST /device/history ### Description Retrieve historical data for a device at various granularities with specific measure points. Granularity options: 1=intraday, 2=day, 3=month, 4=year. ### Method POST ### Endpoint /device/history ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **granularity** (integer) - Required - The granularity of the data (1: intraday, 2: day, 3: month, 4: year). - **startAt** (string) - Required - The start date for the historical data. Format depends on granularity. - **endAt** (string) - Optional - The end date for the historical data. Format depends on granularity. - **measurePoints** (array of strings) - Optional - A list of measure points to retrieve data for. Required for granularity 1. ### Request Example ```json { "deviceSn": "333333", "granularity": 1, "startAt": "2024-05-20", "endAt": "2024-05-20", "measurePoints": [ "SOC", "batteryPower" ] } ``` ### Response #### Success Response (200) - **data** (array) - An array of historical data points. - **time** (string) - The time of the data point (if granularity is intraday). - **date** (string) - The date of the data point (if granularity is day, month, or year). - **[measurePointName]** (any) - The value for the requested measure point. #### Response Example ```json { "data": [ { "time": "08:00", "SOC": 45, "batteryPower": 2000 } ] } ``` ``` -------------------------------- ### Get Station Latest Data Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve the most recent telemetry data for a specific station. Ensure you replace '10' with your actual stationId. ```python import requests from clientcode import variable url = variable.baseurl + '/station/latest' headers = variable.headers data = { "stationId": 10 # Replace with your stationId } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"generationPower": 3500, "gridPower": 1200, "batterySOC": 85} ``` -------------------------------- ### Get Order Status Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Check the execution status of a control command using its order ID. ```APIDOC ## GET /order/{orderId} ### Description Check the execution status of a control command using its order ID. ### Method GET ### Endpoint /order/{orderId} ### Query Parameters - **orderId** (string) - Required - The ID of the order to check. ### Response #### Success Response (200) - **orderId** (string) - The ID of the order. - **status** (integer) - The status of the order. 0=Created, 100=Sending, 666=Success, other=Error. - **analysisResult** (string) - Additional analysis result information. ### Response Example ```json { "orderId": "12345", "status": 666, "analysisResult": "..." } ``` ``` -------------------------------- ### Get Order Status Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve the execution status of a control command using its order ID. The response includes the status code and analysis result. Status codes indicate the command's progress. ```python import requests from clientcode import variable orderId = '12345' # Replace with orderId from previous command url = variable.baseurl + '/order/' + orderId headers = variable.headers response = requests.get(url, headers=headers) print(response.status_code) # 200 print(response.json()) # Status codes: 0=Created, 100=Sending, 666=Success, other=Error # {"orderId": "12345", "status": 666, "analysisResult": "..."} ``` -------------------------------- ### Configuration Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Set up the base URL for your region and configure authentication headers with your access token. ```APIDOC ## Configuration ### Base URL and Authentication Setup Configure the base URL for your region and set up authentication headers with your access token. ```python # variable.py - Configuration for DeyeCloud API # Data center EU's URL: https://eu1-developer.deyecloud.com/v1.0 # Data center US's URL: https://us1-developer.deyecloud.com/v1.0 baseurl = "https://eu1-developer.deyecloud.com/v1.0" token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9' # Replace with your token headers = { 'Content-Type': 'application/json', 'Authorization': 'bearer ' + token } ``` ``` -------------------------------- ### Configure Feed-in to Grid Mode Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Sets the inverter to maximize grid feed-in by selling excess PV and battery power. ```python import requests from clientcode import variable url = variable.baseurl + '/strategy/dynamicControl' headers = variable.headers ratedPower = 5000 # Inverter rated power power = 2000 # Discharge power targetSOC = 15 # Low SOC target for maximum discharge data = { "deviceSn": "333333", "maxSellPower": ratedPower, "maxSolarPower": ratedPower, "solarSellAction": "on", "touAction": "on", "touDays": ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"], "workMode": "SELLING_FIRST", "timeUseSettingItems": [ {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "00:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "04:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "08:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "12:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "16:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "20:30"} ] } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### Configure Time of Use Settings Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Set up to 6 time-of-use intervals for automated energy management. Each interval can define generation and grid charge enablement, power limits, SOC targets, and specific times. ```python import requests from clientcode import variable url = variable.baseurl + '/order/sys/tou/update' headers = variable.headers data = { "deviceSn": "333333", "timeUseSettingItems": [ { "enableGeneration": True, "enableGridCharge": True, "power": 1000, "soc": 20, "time": "02:10" }, { "enableGeneration": True, "enableGridCharge": False, "power": 2000, "soc": 20, "time": "06:00" }, { "enableGeneration": False, "enableGridCharge": True, "power": 3000, "soc": 40, "time": "10:00" }, { "enableGeneration": True, "enableGridCharge": True, "power": 4000, "soc": 50, "time": "14:00" }, { "enableGeneration": False, "enableGridCharge": True, "power": 3000, "soc": 60, "time": "18:00" }, { "enableGeneration": True, "enableGridCharge": False, "power": 1000, "soc": 70, "time": "22:00" } ], "timeoutSeconds": 30 } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### Configure Time of Use Settings Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Set up to 6 time-of-use intervals for automated energy management with specific SOC targets, power limits, and charging preferences. ```APIDOC ## POST /order/sys/tou/update ### Description Set up to 6 time-of-use intervals for automated energy management with specific SOC targets, power limits, and charging preferences. ### Method POST ### Endpoint /order/sys/tou/update ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **timeUseSettingItems** (array) - Required - An array of time-of-use settings. Each item can have the following fields: - **enableGeneration** (boolean) - Required - Whether to enable generation during this interval. - **enableGridCharge** (boolean) - Required - Whether to enable grid charging during this interval. - **power** (integer) - Required - The power limit in watts. - **soc** (integer) - Required - The target State of Charge (SOC) percentage. - **time** (string) - Required - The time for this interval in HH:MM format. - **timeoutSeconds** (integer) - Required - The timeout in seconds for the operation. ### Request Example ```json { "deviceSn": "333333", "timeUseSettingItems": [ { "enableGeneration": true, "enableGridCharge": true, "power": 1000, "soc": 20, "time": "02:10" }, { "enableGeneration": true, "enableGridCharge": false, "power": 2000, "soc": 20, "time": "06:00" }, { "enableGeneration": false, "enableGridCharge": true, "power": 3000, "soc": 40, "time": "10:00" }, { "enableGeneration": true, "enableGridCharge": true, "power": 4000, "soc": 50, "time": "14:00" }, { "enableGeneration": false, "enableGridCharge": true, "power": 3000, "soc": 60, "time": "18:00" }, { "enableGeneration": true, "enableGridCharge": false, "power": 1000, "soc": 70, "time": "22:00" } ], "timeoutSeconds": 30 } ``` ### Response #### Success Response (200) - **orderId** (string) - The ID of the order. - **status** (string) - The status of the operation (e.g., "success"). #### Response Example ```json { "orderId": "12345", "status": "success" } ``` ``` -------------------------------- ### Update Power Settings Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Set maximum sell power or maximum solar power values. Power is specified in watts. ```python import requests from clientcode import variable url = variable.baseurl + '/order/sys/power/update' headers = variable.headers data = { "deviceSn": "333333", "powerType": "MAX_SELL_POWER", # Options: MAX_SELL_POWER, MAX_SOLAR_POWER "value": 5000 # Power in watts } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### Set Energy Pattern Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configure the energy priority pattern between battery and load. Options are BATTERY_FIRST or LOAD_FIRST. ```python import requests from clientcode import variable url = variable.baseurl + '/order/sys/energyPattern/update' headers = variable.headers data = { "deviceSn": "333333", "energyPattern": "BATTERY_FIRST" # Options: BATTERY_FIRST, LOAD_FIRST } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### List Devices Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve a paginated list of all devices for business members. ```APIDOC ## POST /device/list ### Description Retrieve a paginated list of all devices for business members. ### Method POST ### Endpoint /device/list ### Parameters #### Request Body - **page** (integer) - Optional - The page number for pagination. Defaults to 1. - **size** (integer) - Optional - The number of devices per page. Defaults to 20. ### Request Example ```json { "page": 1, "size": 20 } ``` ### Response #### Success Response (200) - **total** (integer) - The total number of devices. - **deviceList** (array) - A list of devices. - **deviceSn** (string) - The serial number of the device. - **type** (string) - The type of the device. #### Response Example ```json { "total": 15, "deviceList": [ { "deviceSn": "333333", "type": "INVERTER" } ] } ``` ``` -------------------------------- ### POST /station/listWithDevice Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Fetch stations along with their associated devices, filtered by device type. Supported device types: INVERTER, MICRO_INVERTER, COLLECTOR, BATTERY, MECD, METER, RELAY_BOX, OPTIMIZER, PV_MODULE. ```APIDOC ## POST /station/listWithDevice ### Description Fetch stations along with their associated devices, filtered by device type. Supported device types: INVERTER, MICRO_INVERTER, COLLECTOR, BATTERY, MECD, METER, RELAY_BOX, OPTIMIZER, PV_MODULE. ### Method POST ### Endpoint /station/listWithDevice ### Parameters #### Request Body - **page** (integer) - Required - The page number for pagination. - **size** (integer) - Required - The number of items per page. - **deviceType** (string) - Optional - The type of device to filter by (e.g., "INVERTER"). ### Request Example ```python import requests from clientcode import variable url = variable.baseurl + '/station/listWithDevice' headers = variable.headers data = { "page": 1, "size": 10, "deviceType": "INVERTER" } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"total": 3, "stationList": [{"stationId": 10, "devices": [...]}]} ``` ### Response #### Success Response (200) - **total** (integer) - The total number of stations matching the filter. - **stationList** (array) - A list of station objects, each containing associated devices. - **stationId** (integer) - The unique identifier for the station. - **devices** (array) - A list of devices associated with the station. #### Response Example ```json { "total": 3, "stationList": [ { "stationId": 10, "devices": [ // Device objects will be listed here ] } ] } ``` ``` -------------------------------- ### Control Solar Sell to Grid Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Enable or disable selling solar energy to the grid. Use 'on' to enable and 'off' to disable. ```python import requests from clientcode import variable url = variable.baseurl + '/order/sys/solarSell/control' headers = variable.headers data = { "deviceSn": "333333", "action": "on" # "on" to enable, "off" to disable } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### Update Power Settings Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Set maximum sell power or maximum solar power values. ```APIDOC ## POST /order/sys/power/update ### Description Set maximum sell power or maximum solar power values. ### Method POST ### Endpoint /order/sys/power/update ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **powerType** (string) - Required - The type of power setting to update. Options: MAX_SELL_POWER, MAX_SOLAR_POWER. - **value** (integer) - Required - The power value in watts. ### Request Example ```json { "deviceSn": "333333", "powerType": "MAX_SELL_POWER", "value": 5000 } ``` ### Response #### Success Response (200) - **orderId** (string) - The ID of the order. - **status** (string) - The status of the operation (e.g., "success"). #### Response Example ```json { "orderId": "12345", "status": "success" } ``` ``` -------------------------------- ### Dynamic Control - Fully Charge Battery Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configure the system to fully charge the battery from both PV and grid. When PV is sufficient, battery charges after supplying the load; when insufficient, grid power supplements. ```APIDOC ## POST /strategy/dynamicControl ### Description Configure the system to fully charge the battery from both PV and grid. When PV is sufficient, battery charges after supplying the load; when insufficient, grid power supplements. ### Method POST ### Endpoint /strategy/dynamicControl ### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **gridChargeAction** (string) - Required - Enable or disable grid charging ('on' or 'off'). - **touAction** (string) - Required - Enable or disable Time-of-Use charging ('on' or 'off'). - **touDays** (array of strings) - Required - Days of the week for Time-of-Use settings (e.g., "SUNDAY", "MONDAY"). - **workMode** (string) - Required - The working mode of the system (e.g., "ZERO_EXPORT_TO_CT"). - **timeUseSettingItems** (array of objects) - Required - List of time-based settings for charging. - **enableGeneration** (boolean) - Whether to enable charging from PV. - **enableGridCharge** (boolean) - Whether to enable charging from the grid. - **soc** (integer) - The target State of Charge (SOC) percentage. - **power** (integer) - The target charging power in Watts. - **time** (string) - The time of day for this setting in HH:MM format. ### Request Example ```json { "deviceSn": "333333", "gridChargeAction": "on", "touAction": "on", "touDays": ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"], "workMode": "ZERO_EXPORT_TO_CT", "timeUseSettingItems": [ {"enableGeneration": true, "enableGridCharge": true, "soc": 90, "power": 4000, "time": "00:10"}, {"enableGeneration": true, "enableGridCharge": true, "soc": 90, "power": 4000, "time": "04:10"}, {"enableGeneration": true, "enableGridCharge": true, "soc": 90, "power": 4000, "time": "08:10"}, {"enableGeneration": true, "enableGridCharge": true, "soc": 90, "power": 4000, "time": "12:10"}, {"enableGeneration": true, "enableGridCharge": true, "soc": 90, "power": 4000, "time": "16:10"}, {"enableGeneration": true, "enableGridCharge": true, "soc": 90, "power": 4000, "time": "20:10"} ] } ``` ### Response #### Success Response (200) - **orderId** (string) - The ID of the order created for the strategy update. - **status** (string) - The status of the operation (e.g., "success"). ### Response Example ```json { "orderId": "12345", "status": "success" } ``` ``` -------------------------------- ### Dynamic Control - Fully Charge Battery Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configure the system to fully charge the battery from PV and grid. This strategy sets a high SOC target and specifies charging power and times, suitable for 'ZERO_EXPORT_TO_CT' work mode. ```python import requests from clientcode import variable url = variable.baseurl + '/strategy/dynamicControl' headers = variable.headers targetSOC = 90 # High SOC target for full charge power = 4000 # Target power (W) data = { "deviceSn": "333333", "gridChargeAction": "on", "touAction": "on", "touDays": ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"], "workMode": "ZERO_EXPORT_TO_CT", "timeUseSettingItems": [ {"enableGeneration": True, "enableGridCharge": True, "soc": targetSOC, "power": power, "time": "00:10"}, {"enableGeneration": True, "enableGridCharge": True, "soc": targetSOC, "power": power, "time": "04:10"}, {"enableGeneration": True, "enableGridCharge": True, "soc": targetSOC, "power": power, "time": "08:10"}, {"enableGeneration": True, "enableGridCharge": True, "soc": targetSOC, "power": power, "time": "12:10"}, {"enableGeneration": True, "enableGridCharge": True, "soc": targetSOC, "power": power, "time": "16:10"}, {"enableGeneration": True, "enableGridCharge": True, "soc": targetSOC, "power": power, "time": "20:10"} ] } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### List Devices Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve a paginated list of all devices for business members. Use 'page' and 'size' parameters to control pagination. ```python import requests from clientcode import variable url = variable.baseurl + '/device/list' headers = variable.headers data = { "page": 1, "size": 20 } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"total": 15, "deviceList": [{"deviceSn": "333333", "type": "INVERTER"}]} ``` -------------------------------- ### Set System Work Mode Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configure the inverter's operating mode for energy flow management. Options include SELLING_FIRST, ZERO_EXPORT_TO_LOAD, and ZERO_EXPORT_TO_CT. ```python import requests from clientcode import variable url = variable.baseurl + '/order/sys/workMode/update' headers = variable.headers data = { "deviceSn": "333333", "workMode": "SELLING_FIRST" # Options: SELLING_FIRST, ZERO_EXPORT_TO_LOAD, ZERO_EXPORT_TO_CT } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### Configure Base URL and Authentication Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Sets the regional base URL and defines the authorization headers required for API requests. ```python # variable.py - Configuration for DeyeCloud API # Data center EU's URL: https://eu1-developer.deyecloud.com/v1.0 # Data center US's URL: https://us1-developer.deyecloud.com/v1.0 baseurl = "https://eu1-developer.deyecloud.com/v1.0" token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9' # Replace with your token headers = { 'Content-Type': 'application/json', 'Authorization': 'bearer ' + token } ``` -------------------------------- ### Configure Self Consumption Mode Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configures the system to prioritize PV for local load and prevents grid export. ```python import requests from clientcode import variable url = variable.baseurl + '/strategy/dynamicControl' headers = variable.headers targetSOC = 15 # Low SOC for self-consumption power = 10000 # High power limit data = { "deviceSn": "333333", "solarSellAction": "on", "touAction": "on", "touDays": ["SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"], "workMode": "ZERO_EXPORT_TO_CT", "timeUseSettingItems": [ {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "02:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "06:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "10:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "14:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "18:30"}, {"enableGeneration": True, "enableGridCharge": True, "power": power, "soc": targetSOC, "time": "22:30"} ] } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"orderId": "12345", "status": "success"} ``` -------------------------------- ### Retrieve Account Information Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Fetches user details and company associations using the configured base URL and headers. ```python import requests from clientcode import variable url = variable.baseurl + '/account/info' headers = variable.headers data = {} response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"userId": 123, "email": "user@example.com", "companyId": "456"} ``` -------------------------------- ### POST /station/list Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve a paginated list of all solar stations associated with your account. ```APIDOC ## POST /station/list ### Description Retrieve a paginated list of all solar stations associated with your account. ### Method POST ### Endpoint /station/list ### Parameters #### Request Body - **page** (integer) - Required - The page number for pagination. - **size** (integer) - Required - The number of items per page. ### Request Example ```python import requests from clientcode import variable url = variable.baseurl + '/station/list' headers = variable.headers data = { "page": 1, "size": 10 } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"total": 5, "stationList": [{"stationId": 10, "name": "Home Solar"}]} ``` ### Response #### Success Response (200) - **total** (integer) - The total number of stations. - **stationList** (array) - A list of station objects. - **stationId** (integer) - The unique identifier for the station. - **name** (string) - The name of the station. #### Response Example ```json { "total": 5, "stationList": [ { "stationId": 10, "name": "Home Solar" } ] } ``` ``` -------------------------------- ### Set Energy Pattern Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configure energy priority pattern between battery and load. ```APIDOC ## POST /order/sys/energyPattern/update ### Description Configure energy priority pattern between battery and load. ### Method POST ### Endpoint /order/sys/energyPattern/update ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **energyPattern** (string) - Required - The energy pattern. Options: BATTERY_FIRST, LOAD_FIRST. ### Request Example ```json { "deviceSn": "333333", "energyPattern": "BATTERY_FIRST" } ``` ### Response #### Success Response (200) - **orderId** (string) - The ID of the order. - **status** (string) - The status of the operation (e.g., "success"). #### Response Example ```json { "orderId": "12345", "status": "success" } ``` ``` -------------------------------- ### List Solar Stations Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieves a paginated list of solar stations associated with the authenticated account. ```python import requests from clientcode import variable url = variable.baseurl + '/station/list' headers = variable.headers data = { "page": 1, "size": 10 } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"total": 5, "stationList": [{"stationId": 10, "name": "Home Solar"}]} ``` -------------------------------- ### POST /station/device Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve all devices associated with specific station IDs. ```APIDOC ## POST /station/device ### Description Retrieve all devices associated with specific station IDs. ### Method POST ### Endpoint /station/device ### Parameters #### Request Body - **page** (integer) - Required - The page number for pagination. - **size** (integer) - Required - The number of items per page. - **stationIds** (array) - Required - A list of station IDs for which to retrieve devices. - **(element)** (integer) - A station ID. ### Request Example ```python import requests from clientcode import variable url = variable.baseurl + '/station/device' headers = variable.headers data = { "page": 1, "size": 10, "stationIds": [10, 11, 12] # Replace with your station IDs } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"devices": [{"deviceSn": "333333", "type": "INVERTER"}]} ``` ### Response #### Success Response (200) - **devices** (array) - A list of device objects. - **deviceSn** (string) - The serial number of the device. - **type** (string) - The type of the device. #### Response Example ```json { "devices": [ { "deviceSn": "333333", "type": "INVERTER" } ] } ``` ``` -------------------------------- ### List Stations with Devices Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Fetches stations filtered by a specific device type, such as INVERTER or BATTERY. ```python import requests from clientcode import variable url = variable.baseurl + '/station/listWithDevice' headers = variable.headers data = { "page": 1, "size": 10, "deviceType": "INVERTER" } response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"total": 3, "stationList": [{"stationId": 10, "devices": [...]}]} ``` -------------------------------- ### POST /account/info Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Retrieve account information including user details and associated company IDs. ```APIDOC ## POST /account/info ### Description Retrieve account information including user details and associated company IDs. ### Method POST ### Endpoint /account/info ### Parameters #### Request Body - **(empty)** - This endpoint does not require a request body. ### Request Example ```python import requests from clientcode import variable url = variable.baseurl + '/account/info' headers = variable.headers data = {} response = requests.post(url, headers=headers, json=data) print(response.status_code) # 200 print(response.json()) # {"userId": 123, "email": "user@example.com", "companyId": "456"} ``` ### Response #### Success Response (200) - **userId** (integer) - The user's unique identifier. - **email** (string) - The user's email address. - **companyId** (string) - The ID of the company associated with the user. #### Response Example ```json { "userId": 123, "email": "user@example.com", "companyId": "456" } ``` ``` -------------------------------- ### Set System Work Mode Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Configure the inverter's operating mode for energy flow management. ```APIDOC ## POST /order/sys/workMode/update ### Description Configure the inverter's operating mode for energy flow management. ### Method POST ### Endpoint /order/sys/workMode/update ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **workMode** (string) - Required - The desired work mode. Options: SELLING_FIRST, ZERO_EXPORT_TO_LOAD, ZERO_EXPORT_TO_CT. ### Request Example ```json { "deviceSn": "333333", "workMode": "SELLING_FIRST" } ``` ### Response #### Success Response (200) - **orderId** (string) - The ID of the order. - **status** (string) - The status of the operation (e.g., "success"). #### Response Example ```json { "orderId": "12345", "status": "success" } ``` ``` -------------------------------- ### Control Solar Sell Source: https://context7.com/deyeclouddevelopers/deye-openapi-client-sample-code/llms.txt Enable or disable selling solar energy to the grid. ```APIDOC ## POST /order/sys/solarSell/control ### Description Enable or disable selling solar energy to the grid. ### Method POST ### Endpoint /order/sys/solarSell/control ### Parameters #### Request Body - **deviceSn** (string) - Required - The serial number of the device. - **action** (string) - Required - The action to perform. Options: "on" to enable, "off" to disable. ### Request Example ```json { "deviceSn": "333333", "action": "on" } ``` ### Response #### Success Response (200) - **orderId** (string) - The ID of the order. - **status** (string) - The status of the operation (e.g., "success"). #### Response Example ```json { "orderId": "12345", "status": "success" } ``` ```