script help - "multiply by non-int of type 'float' error"

Posted on
Tue Nov 22, 2022 11:19 pm
dtich offline
Posts: 798
Joined: Sep 24, 2005

script help - "multiply by non-int of type 'float' error"

the below formula is throwing a multiply by non-int error that i can't quite sort out, any help with the syntax or other issue is appreciated! thx

the commented out lines are ref of the original formulas i'm trying to implement. i tried breaking them into summing variables in an effort to help with the multiply by error. i'm pretty sure i'm not handing the indigo variables properly, just can't figure it out... :D

Script Error schedule "weather update every 15min" embedded script error:
Script Error can't multiply sequence by non-int of type 'float'
Script Error Exception Traceback (most recent call shown last):

embedded script, line 76, at top level
TypeError: can't multiply sequence by non-int of type 'float'



Code: Select all
if cnthumid == "- data unavailable -":
   vardew = wthrStation.states['dewPointC']
   vartemp = wthrStation.states['temperatureC']

   import math

   argdew = math.exp((17.625 * vardew)/(243.04 + vardew)). --- THIS IS LINE 76
   argtem = math.exp((17.625 * vartemp)/(243.04 + vartemp))

   cnthumid = round(100 * (argdew / argtem), 2)

   #cnthumid = 100 * {math.exp[17.625 * wthrStation.states['dewPointC']/(243.04 + wthrStation.states['dewPointC'])] / math.exp[17.625 * wthrStation.states['temperatureC']/(243.04 + wthrStation.states['temperatureC'])]}
   #ref RH = 100 × {exp[17.625 × Dp/(243.04 + Dp)]/exp[17.625 × T/(243.04 + T)]}.

   indigo.variable.updateValue(1163325337, "alt")
else:
   indigo.variable.updateValue(1163325337, "")

Posted on
Wed Nov 23, 2022 12:20 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: script help - "multiply by non-int of type 'float' error

Does that line actually have a period (decimal point) at the end? I don’t think that should be there.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Nov 23, 2022 12:26 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: script help - "multiply by non-int of type 'float' error

it doesn't, no. must've hit it while adding the comment. it's not in the code.

thx

Posted on
Wed Nov 23, 2022 12:30 am
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: script help - "multiply by non-int of type 'float' error

i'm realizing it is possible that this error could be thrown if the value of DewpointC is 'unavailable' or similar.. a text str that the station is reporting for whatever reason.. that could scuttle the whole formula. i haven't trapped for all those possibilities... not sure, but.. could be the case.

Posted on
Wed Nov 23, 2022 10:32 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: script help - "multiply by non-int of type 'float' error

dtich wrote:
i'm realizing it is possible that this error could be thrown if the value of DewpointC is 'unavailable' or similar.. a text str that the station is reporting for whatever reason.. that could scuttle the whole formula. i haven't trapped for all those possibilities... not sure, but.. could be the case.


Have you checked the type as a debug method:

Code: Select all
print(type(vardew))
print(type(vartemp))

Posted on
Thu Nov 24, 2022 1:17 pm
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: script help - "multiply by non-int of type 'float' error

thanks ryan.

when i use test strs that are the expected values it works perfectly. i think this must be that the station is reporting another string i haven't seen/caught yet. i guess i'll just keep an eye out.

i have set the states to log when the alt computation method is used (when 'data unavailable' is returned from station the algorithm switches to the raw data and uses the involved dewpoint computation method to derive the rh - this is in fact how the station itself does it... when it works :D )

anyway, thanks for the thought. i think i'm gonna let this throw an error every now an again because i can't seem to keep up with the station's odd reporting at times. either way the system works through the error so it's ok.

Posted on
Thu Nov 24, 2022 1:40 pm
dtich offline
Posts: 798
Joined: Sep 24, 2005

Re: script help - "multiply by non-int of type 'float' error

also i have converted the dew and temp var from float to round and that may solve the other part of this. for some reason the math doesn't want to multiply a number by a float var... rounding it may fix? we'll see.

thx all

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests