[SOLVED]setting start value to variable value

Posted on
Sat Apr 04, 2015 6:38 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

[SOLVED]setting start value to variable value

As the topic implies I am trying to set a timer start value to the value of a variable. Like a count down clock.

I have tried the following phyton script, but it fails. Any suggestions?

verdi = indigo.variables[1201785696] # "Nedtellingstimer"

tId = "com.perceptiveautomation.indigoplugin.timersandpesters"
timerPlugin = indigo.server.getPlugin(tId)
if timerPlugin.isEnabled():
timerPlugin.executeAction("setTimerStartValue", deviceId=238449231, props={'amount':'verdi', 'amountType':'minutes'})

-----------------------------------------------------------------------------
Timers and Pesters Error Set Timer action failed validation

Håvard

Håvard

Posted on
Sat Apr 04, 2015 7:00 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: setting start value to variable value

Instant response without double checking but try removing the quotes around verdi i.e.:
Code: Select all
timerPlugin.executeAction("setTimerStartValue", deviceId=238449231, props={'amount':verdi, 'amountType':'minutes'})
Putting the quotes around it, turns it into a string with a value 'verdi' whereas you want to access the variable verdi (with no quotes). :)

Posted on
Sat Apr 04, 2015 7:03 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: setting start value to variable value

Also, just spotted this, the statement:
Code: Select all
verdi = indigo.variables[1201785696] # "Nedtellingstimer"
should be
Code: Select all
verdi = indigo.variables[1201785696].value # "Nedtellingstimer"
You need to specify the '.value' to get at the value of the variable.

Posted on
Sat Apr 04, 2015 9:26 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: setting start value to variable value

Thank you. That worked perfectly.
I now have a variable that when updated starts a timer with the value that was entered. When the timer expires a sonos announcement is played.
In other words, a fancy kitchen timer :)

Code: Select all
verdi = indigo.variables[1201785696].value # "Nedtellingstimer"

tId = "com.perceptiveautomation.indigoplugin.timersandpesters"
timerPlugin = indigo.server.getPlugin(tId)
if timerPlugin.isEnabled():
   timerPlugin.executeAction("setTimerStartValue", deviceId=238449231, props={'amount':verdi, 'amountType':'minutes'})
   timerPlugin.executeAction("restartTimer", deviceId= 238449231)


Håvard

Håvard

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests