Timer object has no attribute amount in Indigo 7

Discuss the Timers and Pesters plugin.
Turribeach
Posts: 432
Joined: Fri Feb 06, 2015 4:25 pm
Location: London, UK

Timer object has no attribute amount in Indigo 7

Post 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
autolog
Posts: 4000
Joined: Tue Sep 10, 2013 3:07 am
Location: West Sussex, UK [GMT aka UTC]
Contact:

Re: Timer object has no attribute amount in Indigo 7

Post 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. :?
Turribeach
Posts: 432
Joined: Fri Feb 06, 2015 4:25 pm
Location: London, UK

Re: Timer object has no attribute amount in Indigo 7

Post 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)
autolog
Posts: 4000
Joined: Tue Sep 10, 2013 3:07 am
Location: West Sussex, UK [GMT aka UTC]
Contact:

Re: Timer object has no attribute amount in Indigo 7

Post by autolog »

Well spotted :oops:

Try accessing it using

Code: Select all

 timer.ownerProps["amount"]
It works for me. :)
User avatar
jay (support)
Site Admin
Posts: 18420
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Timer object has no attribute amount in Indigo 7

Post 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.
Jay (Indigo Support)
Twitter | Facebook | LinkedIn
Turribeach
Posts: 432
Joined: Fri Feb 06, 2015 4:25 pm
Location: London, UK

Re: Timer object has no attribute amount in Indigo 7

Post by Turribeach »

It works with ownerProps, many thanks.
Post Reply

Return to “Timers and Pesters”