philipbasile wrote:Hi,
I need some python help. Im trying to calculate percent elapsed time for a song in the songs plugin.
The current attribute REMAINING actually counts up from 0:00 to the DURATION of the song.
I'd like to move the REMAINING time into a variable called ElapsedTime and then calculate remaining time.
I got started with the following but I'm already getting errors.
varMusicElapsedTime = indigo.variables[1086500855]
varMusicRemainingTime = indigo.variables[1086500892]
varSonos = indigo.devices[1475651238]
varMusicElapsedTime.value = varSonos.Remaining
Indigo is complaining about the attribute REMAINING not existing.
Thanks
Firstly, Indigo variables are stored as strings so you need to convert them to numbers (I assume they're integers here):
- Code: Select all
varMusicElapsedTime = int(indigo.variables[1086500855])
varMusicRemainingTime = int(indigo.variables[1086500892])
varSonos = indigo.devices[1475651238]
varMusicElapsedTime.value = varSonos.Remaining
Secondly, I believe that you're looking for a device state (not a device property), which is referenced like this (note that I also removed the dot from your last variable name):
- Code: Select all
varMusicElapsedTime = int(indigo.variables[1086500855])
varMusicRemainingTime = int(indigo.variables[1086500892])
varSonos = indigo.devices[1475651238]
varMusicElapsedTimeValue = varSonos.states['Remaining']
If you post the dict of your device (be sure to mask any sensitive data) it would help to diagnose your issue.