Page 1 of 1

I'm soooooo annoyed! [with myself]

PostPosted: Mon Jan 23, 2023 1:48 pm
by jltnol
So I'm far from a Python Expert, but over the years, I've collected enough snippets of code to get my kindergarten scripts to work for me, but I am just stuck, stuck, stuck.
Below is the code, but I keep getting this error message:
embedded script, line 4, at top level
AttributeError: 'list' object has no attribute 'updateValue'


I've updated variables in Python countless times, but this just isn't working. Just trying to put the device state into the variable fails. I'm also not sure the math part is going to work, but I guess one thing at a time.

Code: Select all
HeatTimer = indigo.devices[397890962]
D0Heat = HeatTimer.states['secondsDay00'] #time in seconds

indigo.variable.updateValue(523352543, D0Heat) #update variable

Minutes = "{:.2f}".format(float(D0Heat) /60.0) #convert seconds to minutes
indigo.variable.updateValue(1392022438, Minutes) #update variable

Re: I'm soooooo annoyed! [with myself]

PostPosted: Mon Jan 23, 2023 4:21 pm
by jltnol
So just a bit more info.

As it turns out, the device state I'm working with is an integer, not a string. Other custom states that are "strings" work just fine, but custom states that are "integers" do not. I'm working looking for the answer but I'm assuming I need to amend the update line in some fashion.....


********************

found this but it also doesn't work anymore. I'm assuming this is from an older version of Python
Code: Select all
myInteger = 1
indigo.variable.updateValue(1234567, value=unicode(myInteger))

returns this error:
embedded script, line 2, at top level
NameError: name 'unicode' is not defined

Re: I'm soooooo annoyed! [with myself]

PostPosted: Mon Jan 23, 2023 5:35 pm
by FlyingDiver
Code: Select all
myInteger = 1
indigo.variable.updateValue(1234567, value=str(myInteger))

Re: I'm soooooo annoyed! [with myself]

PostPosted: Mon Jan 23, 2023 7:05 pm
by jltnol
As ALWAYS... Thank you Joe. The rest I can manage.... it's the little things like this that trip me up all the time.. But thankfully.... people like you are around to always help!