Incrementing a variable

Posted on
Tue Nov 24, 2020 10:00 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Incrementing a variable

I would like to count how many days the house is occupied, depending on season.
I am unable to count winter occupancy below. - my script is attempting to update the winterCount variable with its revised value.
Suggestions?
Code: Select all
hseStatus = indigo.variables[1568794432].value
season = indigo.variables[325456157].value
winterCount = indigo.variables[255681698].getValue(int)
if hseStatus == "Occupied":
   if season == "winter":
      winterCount += 1
      indigo.variable.updateValue(255681698, winterCount)

Posted on
Wed Nov 25, 2020 7:20 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Incrementing a variable

Without knowing the error that you're getting, I can only presume it's because your last line is trying to update the variable with an integer. Indigo variables can only be strings, so try updating your last line to:

Code: Select all
indigo.variable.updateValue(255681698, str(winterCount))

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Nov 25, 2020 12:54 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Re: Incrementing a variable

There wasn't any error message - you guessed right, it's simply not updating.
Thanks.

Posted on
Wed Nov 25, 2020 3:55 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Incrementing a variable

Did changing the last line to my suggestion solve the problem for you or is it still broken?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Wed Nov 25, 2020 8:07 pm
SMUSEBY offline
Posts: 511
Joined: Sep 16, 2009
Location: California

Re: Incrementing a variable

It did. Very easy change.
Thank you.

Posted on
Wed Nov 25, 2020 9:20 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Incrementing a variable

Good deal.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests