Getting time of last update from RFXCOM device

Posted on
Sat Jan 27, 2018 2:38 am
davinci offline
Posts: 218
Joined: Feb 14, 2015

Getting time of last update from RFXCOM device

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"]

Posted on
Sat Jan 27, 2018 4:40 am
autolog offline
Posts: 2388
Joined: Sep 10, 2013
Location: West Sussex

Re: Getting time of last update from RFXCOM device

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) :)

Posted on
Sat Jan 27, 2018 10:00 am
davinci offline
Posts: 218
Joined: Feb 14, 2015

Re: Getting time of last update from RFXCOM device

Unfortunately it doesn't work either:
AttributeError: 'Dict' object has no attribute 'lastSuccessfulComm'
AttributeError: 'Dict' object has no attribute 'lastChanged'

Posted on
Sat Jan 27, 2018 11:35 am
autolog offline
Posts: 2388
Joined: Sep 10, 2013
Location: West Sussex

Re: Getting time of last update from RFXCOM device

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? :)

Posted on
Sat Jan 27, 2018 11:41 am
autolog offline
Posts: 2388
Joined: Sep 10, 2013
Location: West Sussex

Re: Getting time of last update from RFXCOM device

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. :)

Posted on
Sat Jan 27, 2018 11:51 am
kw123 offline
User avatar
Posts: 5838
Joined: May 12, 2013
Location: Dallas, TX

Re: Getting time of last update from RFXCOM device

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

Posted on
Sat Jan 27, 2018 11:54 am
matt (support) offline
Site Admin
User avatar
Posts: 18618
Joined: Jan 27, 2003
Location: Texas

Re: Getting time of last update from RFXCOM device

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.

Image

Posted on
Sat Jan 27, 2018 12:00 pm
davinci offline
Posts: 218
Joined: Feb 14, 2015

Re: Getting time of last update from RFXCOM device

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?

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest