Page 1 of 1

Timer object has no attribute amount in Indigo 7

PostPosted: Sat Sep 09, 2017 4:09 am
by Turribeach
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

Re: Timer object has no attribute amount in Indigo 7

PostPosted: Sat Sep 09, 2017 4:35 am
by autolog
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. :?

Re: Timer object has no attribute amount in Indigo 7

PostPosted: Sat Sep 09, 2017 5:01 am
by Turribeach
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)

Re: Timer object has no attribute amount in Indigo 7

PostPosted: Sat Sep 09, 2017 5:15 am
by autolog
Well spotted :oops:

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

Re: Timer object has no attribute amount in Indigo 7

PostPosted: Sat Sep 09, 2017 9:48 am
by jay (support)
"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.

Re: Timer object has no attribute amount in Indigo 7

PostPosted: Sun Sep 10, 2017 3:41 am
by Turribeach
It works with ownerProps, many thanks.