Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong type error
#1
I'm trying to use a library writen by someone else. Here is a simplified version of my source code:

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
snippsat write Aug-04-2023, 05:52 PM:
Added code tag in your post,look at BBCode on how to use.
xxxxx out your server password.
Reply


Messages In This Thread
Wrong type error - by rowan_bradley - Aug-04-2023, 04:29 PM
RE: Wrong type error - by deanhystad - Aug-04-2023, 08:42 PM
RE: Wrong type error - by rowan_bradley - Aug-05-2023, 04:32 PM
RE: Wrong type error - by snippsat - Aug-04-2023, 09:51 PM
RE: Wrong type error - by rowan_bradley - Aug-05-2023, 04:44 PM
RE: Wrong type error - by deanhystad - Aug-06-2023, 02:13 AM
RE: Wrong type error - by rowan_bradley - Aug-07-2023, 10:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 2,273 Aug-13-2023, 12:16 AM
Last Post: cubangt
  Type Error: Unsupported Operand jhancock 2 1,344 Jul-22-2023, 11:33 PM
Last Post: jhancock
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,654 Mar-27-2023, 07:38 AM
Last Post: buran
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,692 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  Python Anytree - Is not of type 'NodeMixin' error georgebijum 3 2,158 May-05-2022, 01:43 PM
Last Post: Gribouillis
  Incorrect Type Error milkycow 4 2,991 Jun-25-2021, 06:04 AM
Last Post: milkycow
Star Type Error: 'in' object is not callable nman52 3 3,471 May-01-2021, 11:03 PM
Last Post: nman52
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,144 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  Type Error in Python MarcusB 3 2,640 Mar-30-2021, 06:34 PM
Last Post: buran
  unsupported operand type(s) for /: 'str' and 'int' Error for boxplot soft 1 3,118 Feb-09-2021, 05:40 PM
Last Post: soft

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020