Aug-04-2023, 04:29 PM
I'm trying to use a library writen by someone else. Here is a simplified version of my source code:
Thank you - Rowan
import growattServer import datetime import time from datetime import date import getpass import json import sys, getopt import shutil from enum import IntEnum # set up variables user_name = "rowan.bradley" # Server username user_pass = "xxxxx" # Server password outfolder = "/growatt" outPrefix = "growatt-" outSuffix = ".json" api = growattServer.GrowattApi(False, "hue73jhns83je93jed723uj2") login_response = api.login(user_name, user_pass) plantId = login_response['data'][0]['plantId'] plant_info = api.plant_info(plantId) today = date.today() plant_detail = api.plant_detail(plantId, 1, ime.time()) print("plant_detail = ", plant_detail)When I run this (in WIndows 10) I get
Error:D:\XPS_8700 Extended Files\Users\RowanB\Documents\Inetpub\www.sylvesterbradley.org\public_html>python growatt2.py
Traceback (most recent call last):
File "D:\XPS_8700 Extended Files\Users\RowanB\Documents\Inetpub\www.sylvesterbradley.org\public_html\growatt2.py", line 22, in <module>
plant_detail = api.plant_detail(plantId, 1, time.time())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python311\Lib\site-packages\growattServer\__init__.py", line 158, in plant_detail
date_str = self.__get_date_string(timespan, date)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\python311\Lib\site-packages\growattServer\__init__.py", line 49, in __get_date_string
assert timespan in Timespan
^^^^^^^^^^^^^^^^^^^^
File "c:\python311\Lib\enum.py", line 739, in __contains__
raise TypeError(
TypeError: unsupported operand type(s) for 'in': 'int' and 'EnumType'
D:\XPS_8700 Extended Files\Users\RowanB\Documents\Inetpub\www.sylvesterbradley.org\public_html>
I suppose that this possibly means that the 3rd parameter for the function api.plant_detail is the wrong type. How do I find out what type is expected? What might it be (so I can try all possibilities)?Thank you - Rowan