Page 1 of 1

Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 2:38 am
by davinci
I have a temperature sensor (new KaKu) that I included by RFXCOM. On the device in Indigo I see the time when last updated. How can I get this time in Python?

This doesn't seem to work since the term is not in dict...
Code: Select all
time= sensor.states["timeOfLastChange"]

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 4:40 am
by autolog
Try the following:
Code: Select all
time = indigo.devices[12345678].lastChanged
# or
time = indigo.devices[12345678].lastSuccessfulComm
where 12345678 is your device Id (change as appropriate) :)

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 10:00 am
by davinci
Unfortunately it doesn't work either:
AttributeError: 'Dict' object has no attribute 'lastSuccessfulComm'
AttributeError: 'Dict' object has no attribute 'lastChanged'

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 11:35 am
by autolog
That's odd :?

Can you post the code before and after the failing statement so I can get a view of what you are doing? :)

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 11:41 am
by autolog
Even better could you post the results of running the following embedded python script:
Code: Select all
indigo.server.log(u'RFXCOM Device: {}'.format(indigo.devices[12345678]))
where 12345678 is your device Id (change as appropriate).

This will give a view of your device that will confirm what the command should be. :)

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 11:51 am
by kw123
this works for me:
Code: Select all
dev =indigo.devices[719674580]
indigo.server.log(unicode(dev.lastChanged))

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 11:54 am
by matt (support)
davinci wrote:
Unfortunately it doesn't work either:
AttributeError: 'Dict' object has no attribute 'lastSuccessfulComm'
AttributeError: 'Dict' object has no attribute 'lastChanged'

I don't think you are using the code exactly as autolog pasted it above. It looks like you are trying to access the device's state Dict, but he is referencing properties that are built into the device instance.

Re: Getting time of last update from RFXCOM device

PostPosted: Sat Jan 27, 2018 12:00 pm
by davinci
Thank you all!

This works:

Code: Select all
dev =indigo.devices[719674580]
indigo.server.log(unicode(dev.lastChanged))



I'm not sure anymore what code I had before but with dev it works. What is the difference by the way?