Timer object has no attribute amount in Indigo 7

Posted on
Sat Sep 09, 2017 4:09 am
Turribeach offline
Posts: 226
Joined: Feb 06, 2015
Location: London, UK

Timer object has no attribute amount in Indigo 7

Hi,

This code was working fine in Indigo 6 but now fails in Indigo 7.0.3:

Code: Select all
tId = "com.perceptiveautomation.indigoplugin.timersandpesters"
timerPlugin = indigo.server.getPlugin(tId)
if timerPlugin.isEnabled():
    timer = indigo.devices[1709868748] # "Timer Lights Override"
    timerID = timer.id
    timerAmount = timer.amount


Error is:

Code: Select all
embedded script, line 6, at top level
AttributeError: 'Device' object has no attribute 'amount'


It looks like the Timer object doesn't have an amount attribute anymore. I had a look at the Timers and Pesters wiki page but it hasn't been changed since July 2015.

Any ideas?

Thanks,
Christian

Posted on
Sat Sep 09, 2017 4:35 am
autolog offline
Posts: 2649
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT+0]

Re: Timer object has no attribute amount in Indigo 7

This is a print of a timer device:
address :
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : timer
displayStateId : longStatusString
displayStateImageSel : TimerOff
displayStateValRaw : inactive
displayStateValUi : inactive
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 380178312
globalProps : MetaProps : (dict)
com.perceptiveautomation.indigoplugin.timersandpesters : (dict)
amount : 5 (string)
amountType : minutes (string)
id : 1466619331
lastChanged : 2017-09-09 11:27:54
lastSuccessfulComm : 2017-09-09 11:27:54
model : Timer
name : new device
ownerProps : com.perceptiveautomation.indigoplugin.timersandpesters : (dict)
amount : 5 (string)
amountType : minutes (string)
pluginId : com.perceptiveautomation.indigoplugin.timersandpesters
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
states : States : (dict)

longStatusString : inactive (string)
timeLeftDays : 0 (integer)
timeLeftHours : 0 (integer)
timeLeftMinutes : 0 (integer)
timeLeftSeconds : 0 (integer)
timerStartValueSeconds : 300 (string)
timerStatus : inactive (string)
timerStatus.active : false (bool)
timerStatus.inactive : true (bool)
timerStatus.paused : false (bool)
subModel :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsStatusRequest : False
version : None


The amount is a property for the Action setTimerStartValue. I think you need to be inspecting the device states (in red above)? :)

Can't explain why it used to work and now doesn't. :?

Posted on
Sat Sep 09, 2017 5:01 am
Turribeach offline
Posts: 226
Joined: Feb 06, 2015
Location: London, UK

Re: Timer object has no attribute amount in Indigo 7

Actually you got amount on the list too, but it's not in alpha sorted properly, perhaps that's why it fails?

amount : 5 (string)
amountType : minutes (string)

Posted on
Sat Sep 09, 2017 5:15 am
autolog offline
Posts: 2649
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT+0]

Re: Timer object has no attribute amount in Indigo 7

Well spotted :oops:

Try accessing it using
Code: Select all
 timer.ownerProps["amount"]
It works for me. :)

Posted on
Sat Sep 09, 2017 9:48 am
jay (support) offline
Site Admin
User avatar
Posts: 15152
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Timer object has no attribute amount in Indigo 7

"amount" has always been a config property of the timer device (not a direct device property) so accessing it would have always required getting it from the config dictionary as autolog points out.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Sep 10, 2017 3:41 am
Turribeach offline
Posts: 226
Joined: Feb 06, 2015
Location: London, UK

Re: Timer object has no attribute amount in Indigo 7

It works with ownerProps, many thanks.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests