Notify device from interface on startup?

HouseBot Plugin Development Discussions.
Post Reply
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Notify device from interface on startup?

Post by dlmorgan999 »

In my HAI plugin I want to be able to query the security status every time HouseBot starts up. This is because the security status may have changed while HouseBot was not running and it will also help "resync" HB when it crashes while attempting to execute an HAI command.



I tried several different things and none of them worked. I then came to what I believe is a correct conclusion but if so I'm not sure what to do about it.



Here is what I think is happening. When HouseBot starts it starts all the hardware interfaces and then it starts the various devices. I am assuming that my hardware interface *is* getting the updated security status and sending a notification. However, since the corresponding device module is not yet started it's not listening for notifications.



Typically I wouldn't need to do a periodic poll for security mode although just because it was easy I added to an hourly poll that grabs a few other bits of data. This poll works just fine to update the security status.



So I have two questions:

- does my hypothesis seem correct?

- if so can someone suggest how I might solve this issue?



-- Dave
spike5884
Senior Member
Posts: 129
Joined: Thu Aug 26, 2004 8:08 am
Location: WI

Post by spike5884 »

Don't have an answer for the first question, but here is a possible answer to the second question.

http://www.meedio.com/forum/about22896.html
What’s new in Version 2.22:
There have been many minor bug fixes (not all of them listed below) and several feature enhancements that have been added since version 2.20. The following list gives brief description of some of the changes. Please see the included help file for more details.

Meedio HouseBot Server Changes:

* Added feature to execute an 'autoexec' Task on startup (and terminate).
Would that help in anyway? You could have the start-up task do the initial check for you. Not sure where that option is located though.

Found it in the help:
Startup and ShutDown Tasks


Startup and ShutDown Tasks are two special types of Tasks that are executed automatically by the system. The Startup Task is executed automatically when HouseBot is first started. The ShutDown Task is executed automatically when HouseBot is terminated normally.



The system identifies the Tasks by their name. Any Task named Startup will be executed when the system is started. Any Task named Shutdown will be executed when HouseBot is exited.
Thanks,
Scott J
aka spike5884
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Post by dlmorgan999 »

Hi Scott,



Thanks for the quick response. I'm already using the startup feature for several tasks - it's quite useful :) . Unfortunately I can't think of a way to use this to help solve this problem because it's something that needs to be done via the hardware interface.



I suppose I could create a function in the interface (triggered by a property change) that would let me request a status update "on demand" and then call that from the task. If no one has a better I idea I may do that.



-- Dave
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Dave,



Your theory is probably correct. My suggestions are:
  1. Delay for a short while in the Hardware Interface thread when initializing so the Devices get a chance to load. Then do the check and send the notifications. Not the best solution because its using an arbitrary delay, but really easy to do.
  2. When the Device is initializing, call QueryHardwareInstance() on the Device object and use a query string that the Interface will recognize in its Query() export to return the info the Device needs. The downside of this is that if there are many devices, the Interface will be answering the same query over and over on initialization.
Scott
dlmorgan999
HouseBot Special Member
Posts: 409
Joined: Tue Jul 13, 2004 9:13 am
Location: Tigard, OR

Post by dlmorgan999 »

Hi Scott,



I think option #2 sounds like a great solution! And since the information only applies to the actual Omni controller device and there only needs to be one of those devices in a system there's no repetitive query either. Thanks for the tip! :D



-- Dave
Post Reply