Skip to content

Commit

Permalink
fix (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvinkovic authored Jun 5, 2024
1 parent 2bb36bf commit e5cc490
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ password =
# EU: mqtteu.zen-iot.com
zen_mqtt = mq.zen-iot.com
# likewise for the API endpoint please select the correct one
# Global: https://app.zendure.tech
# Global: https://app.zendure.tech/v2
# EU: https://app.zendure.tech/eu
zen_api = https://app.zendure.tech
zen_api = https://app.zendure.tech/v2

[local]
mqtt_host = 192.168.1.245
Expand Down
2 changes: 1 addition & 1 deletion src/solarflow-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load_config():

ZEN_USER = config.get('zendure', 'login', fallback=None) or os.environ.get('ZEN_USER',None)
ZEN_PASSWD = config.get('zendure', 'password', fallback=None) or os.environ.get('ZEN_PASSWD',None)
ZEN_API = config.get('zendure', 'zen_api', fallback='https://app.zendure.tech') or os.environ.get('ZEN_API','https://app.zendure.tech')
ZEN_API = config.get('zendure', 'zen_api', fallback='https://app.zendure.tech/v2') or os.environ.get('ZEN_API','https://app.zendure.tech/v2')
MQTT_HOST = config.get('local', 'mqtt_host', fallback=None) or os.environ.get('MQTT_HOST',None)
MQTT_PORT = config.getint('local', 'mqtt_port', fallback=1883) or int(os.environ.get('MQTT_PORT',1883))
MQTT_USER = config.get('local', 'mqtt_user', fallback=None) or os.environ.get('MQTT_USER',None)
Expand Down
15 changes: 7 additions & 8 deletions src/zenapi/ZendureAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
log = logging.getLogger(__name__)
PROD_NAME = os.environ.get('PROD_NAME','SolarFlow2.0')

SF_API_URL = "https://app.zendure.tech"
SF_API_VERSION = "v2"
SF_API_BASE_URL = f'{SF_API_URL}/{SF_API_VERSION}'
SF_API_BASE_URL = "https://app.zendure.tech"

class ZendureAPI():
''' An API class to handle communication with the Zendure API '''

def __init__(self, verifySSL=True, zen_api="https://app.zendure.tech", parameters=None):
self.baseUrl = f'{zen_api}/{SF_API_VERSION}'
def __init__(self, verifySSL=True, zen_api="https://app.zendure.tech/v2", parameters=None):
self.baseUrl = f'{SF_API_BASE_URL}'
self.zen_api = zen_api
self.verifySSL = verifySSL
self.parameters = parameters
self.session = None
Expand Down Expand Up @@ -65,7 +64,7 @@ def authenticate(self, username, password):
}

try:
url = f'{SF_API_BASE_URL}{SF_AUTH_PATH}'
url = f'{self.zen_api}{SF_AUTH_PATH}'
log.info("Authenticating with Zendure ...")
response = self.session.post(url=url, json=authBody)
if response.ok:
Expand All @@ -83,7 +82,7 @@ def authenticate(self, username, password):
def get_device_list(self):
SF_DEVICELIST_PATH = "/productModule/device/queryDeviceListByConsumerId"
try:
url = f'{SF_API_BASE_URL}{SF_DEVICELIST_PATH}'
url = f'{self.zen_api}{SF_DEVICELIST_PATH}'
log.info("Getting device list ...")
response = self.session.post(url=url)
if response.ok:
Expand All @@ -110,7 +109,7 @@ def get_device_details(self, deviceId):
SF_DEVICEDETAILS_PATH = "/device/solarFlow/detail"
payload = {"deviceId": deviceId}
try:
url = f'{SF_API_BASE_URL}{SF_DEVICEDETAILS_PATH}'
url = f'{self.zen_api}{SF_DEVICEDETAILS_PATH}'
log.info(f'Getting device details for [{deviceId}] ...')
response = self.session.post(url=url, json=payload)
if response.ok:
Expand Down

0 comments on commit e5cc490

Please sign in to comment.