Device Health Check

Posted on
Fri Oct 24, 2014 3:25 am
wiery offline
Posts: 288
Joined: Jun 02, 2008
Location: Ireland

Device Health Check

I've noticed a number of times, and especially when you have a larger installation, as more devices and easier to miss, that some parameters are not always correctly defined due to issues during the sync. Thinking about it, and its obvious that it is mainly battery operated devices. Would it be possible to add a health check that would be able to report, based on a template for that device for example of expected fields, that could report back where a device is not properly defined ?

Posted on
Sat Oct 25, 2014 6:25 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Device Health Check

This would be very good for the BJ2000 wall switches which some of us struggle to sync.

Peter

Posted on
Tue Oct 28, 2014 8:51 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Device Health Check

Are you referring to Z-Wave modules? Can you elaborate what you mean by some parameters not being correct?

I have seen an issues where, during Z-Wave sync, if there is a communication hiccup Indigo will disable parameter UI (because it wasn't able to extract those parameters). Is that what you are referring to?

Image

Posted on
Wed Oct 29, 2014 3:52 am
wiery offline
Posts: 288
Joined: Jun 02, 2008
Location: Ireland

Re: Device Health Check

Matt, yes that is exactly what I'm talking about. Its mostly battery operated devices. Only have Z-Wave myself now so can only speak for that. However as i'm thinking about it, we probably need some way of alerting that a device is not updating, be it down to dead battery or loss of communication, but i've had some devices that were not updating. Would it be possible to get a notification of a device that had not updated in X amount of time also ?

Posted on
Thu Oct 30, 2014 8:13 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Device Health Check

There is a Last Updated device property that python scripts have access to. So in theory it is possible to write a script that checks all battery operated devices and sets an error state (variable/email/etc) if a module isn't heard from for an extended period of time. Adding that type of logic, as well as more intuitive ways to detect low battery conditions is on our feature request list as well. In the mean time it would have to be handled via a script (or by creating a plugin).

Image

Posted on
Thu Oct 30, 2014 8:25 am
wiery offline
Posts: 288
Joined: Jun 02, 2008
Location: Ireland

Re: Device Health Check

Would you have a sample available Matt that we could run on schedule ?

Posted on
Thu Oct 30, 2014 8:54 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Device Health Check

Don't have one laying around. I can put something together but it will need to wait until I get some high priority things cleared off my plate. :-)

Image

Posted on
Thu Oct 30, 2014 9:05 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Device Health Check

This will print last update date for all your devices into the log file. The variable lUpdate contains the update string date

Code: Select all
for d in indigo.devices:
   try:
      lUpdate= d.states["timeOfLastChange"]
   except:
      lUpdate=" not avaliable"
   indigo.server.log(u"dev: "+ d.name +u", last updated: "+ lUpdate)


hope that helps

Karl

like this:
Code: Select all
 
 Script                          dev: irrmaster pro, last updated:  not avaliable
  Script                          dev: kitchen sink spotlight, last updated:  not avaliable
  Script                          dev: MAC-00:04:A3:AD:A5:CB, last updated: 2014-10-24 07:15:37
 

Posted on
Thu Oct 30, 2014 9:28 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Device Health Check

This makes it look nicer:
Code: Select all
for d in indigo.devices:
   try:
      lUpdate= d.states["timeOfLastChange"]
   except:
      lUpdate=" not avaliable"
   indigo.server.log(u"dev: "+ d.name.ljust(40) +u", last updated: "+ lUpdate)


==>>
Code: Select all
  Script                          dev: garage light                            , last updated:  not avaliable
  Script                          dev: iphone                                  , last updated: 2014-10-30 16:11:37
  Script                          dev: iphone-xyz                              , last updated: 2014-10-30 10:00:44
  Script                          dev: irrmaster pro                           , last updated:  not avaliable
  Script                          dev: kitchen sink spotlight                  , last updated:  not avaliable
  Script                          dev: MAC-00:04:A3:AD:A5:CB                   , last updated: 2014-10-24 07:15:37
  Script                          dev: MAC-00:0E:58:24:C7:DC                   , last updated: 2014-10-24 07:15:37
  Script                          dev: MAC-00:0E:58:25:21:80                   , last updated: 2014-10-24 07:15:37
  Script                          dev: MAC-00:0E:58:32:27:5C                   , last updated: 2014-10-24 07:15:37
  Script                          dev: MAC-00:0E:58:BF:E0:D7                   , last updated: 2014-10-24 07:15:37
  Script                          dev: MAC-00:13:49:BB:20:E7                   , last updated: 2014-10-30 10:00:44

Posted on
Thu Oct 30, 2014 9:31 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Device Health Check

In case you need help with e.g.
if (now - lUpdate) > 3days: ... send email // speak // etc
let me know

Karl

Posted on
Thu Oct 30, 2014 10:07 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Device Health Check

this will print the info if no update in the last 12 hours

Code: Select all
import time
rightNow = time.time()
for d in indigo.devices:
   try:
      lUpdate= d.states["timeOfLastChange"]
      timeSecs = time.mktime(time.strptime(lUpdate,"%Y-%m-%d %H:%M:%S"))
      timeDelta = rightNow - timeSecs
   except:
      lUpdate=" not avaliable"
      timeDelta =0
   if timeDelta > 60*60*12:  ### 60 secs * 60 minutes * 12 hours
      indigo.server.log(u"dev: "+ d.name.ljust(40) +u", last updated: "+ lUpdate + u";  "+ str(timeDelta) +u"seconds since last update")



==>
Code: Select all
 
  Script                          dev: MAC-D8:D1:CB:A0:95:FF                   , last updated: 2014-10-24 17:49:08;  519189.755683seconds since last update
  Script                          dev: MAC-DC:9B:9C:19:49:53                   , last updated: 2014-10-24 09:14:20;  550077.755683seconds since last update
  Script                          dev: MAC-DE:AD:BE:EF:FE:EE                   , last updated: 2014-10-24 07:15:37;  557200.755683seconds since last update
  Script                          dev: MAC-E0:B5:2D:03:53:B3                   , last updated: 2014-10-29 23:28:22;  63235.7556829seconds since last update
  Script                          dev: MAC-E8:2A:EA:A3:72:CB                   , last updated: 2014-10-29 23:28:22;  63235.7556829seconds since last update
  Script                          dev: MAC-E8:AB:FA:16:21:80                   , last updated: 2014-10-24 07:15:37;  557200.755683seconds since last update
  Script                          dev: MAC-EC:CB:30:D8:A5:20                   , last updated: 2014-10-28 08:17:38;  204279.755683seconds since last update
  Script                          dev: MAC-F0:25:B7:B6:C1:27                   , last updated: 2014-10-29 23:28:22;  63235.7556829seconds since last update
 


replace indigo.server.log(...) with the action you like to perform for each device that has not been updated for xx hours ...

Karl

{UPDATE} copy and paste the code into an action group - server - script action. then click on compile and run.

Posted on
Thu Oct 30, 2014 11:30 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Device Health Check

Thanks, Karl. We have the best users. :-)

Image

Posted on
Thu Oct 30, 2014 2:05 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Device Health Check

to send one email for all non communicating devices:

replace the email address "emailaddress@company.com" with your email

put this code into a server script action schedule that runs once a day:

Code: Select all
import time
eMessage =""
rightNow = time.time()
for d in indigo.devices:
   try:
      lUpdate= d.states["timeOfLastChange"]
      timeSecs = time.mktime(time.strptime(lUpdate,"%Y-%m-%d %H:%M:%S"))
      timeDelta = rightNow - timeSecs
   except:
      lUpdate=" not available"
      timeDelta =0
   if timeDelta > 60*60*12:  ### 60 secs * 60 minutes * 12 hours
      eMessage +=  u"dev: "+ d.name.ljust(40) +u", last updated: "+ lUpdate + u";  "+ str(timeDelta) +u" seconds since last update\n"

# send one email for all devices found
if eMessage !="":  indigo.server.sendEmailTo("emailaddress@company.com", subject="devices not alive..", body=eMessage)


Posted on
Thu Oct 30, 2014 3:14 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Device Health Check

Nice!

We do have the best users...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Mar 04, 2015 9:46 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Device Health Check

Hi!

I get "not avaliable" for all my devices w/ states["timeOfLastChange"] ;/

Best regards, L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Who is online

Users browsing this forum: No registered users and 8 guests