Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A home-specific CML driver for security/control
#1
I've been getting the itch more and more to write a dedicated driver, specific to my house, to handle such events as notification when doors open and close, alerts about various issues, etc.

The current system of triggers and actions and such works...but when I start to think about moving it to the *next* level...I just lose the desire to take it there. Here's an example:

I have notification (via TTS at the moment) when, say, the front door opens. From then on, at 15 second intervals, I am reminded the front door is open, until it no longer is.

That works just fine as is. It involves triggers on the door boolean field, a countdown timer, a trigger on the countdown timer field, and two triggered actions (the door opens, and the countdown timer reaches zero).

Then I start to have issues where I open the front door ("Front door"), change my mind for a second, closing the door...and then decide to go out anyway and open it again ("Front door"). So, I have "Front Door" twice within the span, of, say, 5 seconds. Ya, it's minor...but I'd like to make it smart enough to know hey, I just SAID front door, so I don't need to do that again for x seconds, no matter how many times the front door opens or closes.

Now, this same scenario repeats itself for each other door I have, including countdown timers and triggers and such. Now, I don't have a big house, but already with just 2 doors up and running, it kind of is a mess in the triggered events screen. If I have multiple doors open, I don't want it to list every door that's open, I'd probably just be happy if it said "Doors are open".

Then I also have some TTS for if the smoke alarms are going off (TTS says which one is). Right now, I dont have any logic that says to choose the smoke alarm TTS annoucement *over* the door TTS annoucement. There's clearly an issue of priority there...but I don't have the logic in and I'm not looking forward to trying that.

Which is why I'm leaning towards a CML driver to handle all this stuff. Some advantages I see are:

1) Maintain a string list of "Recent events", door openings, alarms going off, HVAC turning on, etc.
2) Simpler control of multiple timers going on...just check the current time when Poll gets called, and compare it to any saved times.
3) Less reliance on setting triggers on fields to handle stuff, as I am constantly having to remove and reinstall drivers and that gets wiped out and I usually don't realize it's not working until weeks later.
4) Program in a "home health" functionality to monitor stuff like how long lights have been on, or when the last time the lift pump ran, etc.

There's probably other I can't remember just now.

Some of the disadvantages are that it's kind of circumventing how CQC is meant to operate. It *could* also be hard to maintain, since any new door or CHANGE in door name would have to be programmed in, recompiled and reloaded by CQC (which is painful to do right now). I also don't know if it would be a performance drag on the system, given that I'll be polling some fields, especially like doors until their values change.

Given that, it starts to become an issue of implementation, and that's kind of where I'm stuck. So let's take the first example again:

The front door opens.

Now, I want to be notified that it happens (via TTS), I want to log that it happened in the string list, and I want to start a timer to know when it's been open for 15 seconds.

So what I'm unsure of is whether to still use triggers to tell my Home Control driver that a door has changed, or to have my driver just poll all the doors in the house. With polling, I'm concerned about the lag between the door opening and me noticing that. I'd have to poll faster than ever 500 msec most likely, and that's when Id begin getting concerned about overall system performance. Every 250 msec would be more likely to be responsive.

If I use triggers, that's probably the fastest way to know a door has opened.

So, let's say I decide to use triggers to notify the Home Control driver that a door has opened. I again have options on how to implement this:

I could use the logic server to create a boolean field for "DoorOpen", and if *any* door opens, that will turn true. I then put a trigger on that, and I don't have to worry about triggers on all the individual door fields. This appeals a lot, especially when having to deal with things like windows. That's a lot of triggers. The problem here, though, is that even once I notify the Home Control driver that a door has opened...how does the home control know which one it is? I could have it poll all doors at that point to find out which one has opened.

One problem with this implementation, though, is that if a door is open, and then another door opens...that won't get noticed by the logic server, and so won't notify the Home Control software. I'd probably have to keep polling *all* doors in the home control driver while any door was open, to notice if any new doors opened. Then, when all doors are closed, I could go back to not polling any doors until I get notified again.

Anyway, this is just an initial post with thoughts and ideas. I'm again trying to figure out the implementation....something that would be robust enough to handle changes to the system with relative ease, and would not be a big drag on system performance.

Any thoughts?
Reply
#2
Quote:It *could* also be hard to maintain, since any new door or CHANGE in door name would have to be programmed in, recompiled and reloaded by CQC (which is painful to do right now).
For higher level control drivers like this any configuration would best be done via a configuration file/db so adding elements and reconfiguring should be relatively easy if done properly. Although CQC doesn't support writing out to XML it is relatively easy to do via custom methods so name changes and other state data even including changing the moniker.field for a given door could all be configured via the driver field interface.

Quote:With polling, I'm concerned about the lag between the door opening and me noticing that. I'd have to poll faster than ever 500 msec most likely, and that's when Id begin getting concerned about overall system performance. Every 250 msec would be more likely to be responsive.
Do you really need to know within 500ms that a door has opened? For something like door openings you could probably get by with a 1 second sample rate or better. And you wouldn't have to worry about missing events as you would be hard pressed to open and close a door faster than 500ms without trying to do it intentionally and even at that nothing was likely to get in or out. While not real efficient, the simple field client isn't too bad for polling fields. You could create scan classes for polling and announcments and assign various doors to a given scan class for each. High priority doors like exterior doors (and the dungeon) get polled more frequently and announced more frequently than say interior doors.

The way I would handle keeping track of individual doors would be to use a card or boolean vector to keep track if a door is open or closed. For the timer I would use a card8 vector that has the timestamp of the next announcement/action if open. That would make for some pretty straight forward logic without a lot of wasted movments. For a whole house door open I would probably use a stringlist that just has a 0/1 at each position for the current door state. Then to determine if any door is open you only need to do a If(DoorList.FindString("1",Index)..
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#3
Good input, all. Thanks.

jrlewis Wrote:Although CQC doesn't support writing out to XML

Ya, I had thought about the config file method. A better solution than hard-coding, even if this is only for my house. Anything that doesn't require a recompile would be best.

Why would it need to write out, though? You mean to save any changes I make to how the driver is running? Save its settings, as it were?

Quote:Do you really need to know within 500ms that a door has opened?

Well, when you put it that way.... :-) Ya, you're probably right. Early on, before I got my Ocelot, I was using my Datanab for door detection. And it was *slow*. To the point where you could easily open and close the door without it noticing. Now I only use the datanab for my garage doors, since they're unlikely to be able to do that! But I think I just got in the habit of wanting instant door detection. But for practical purposes, ya I'd say a second is still quick enough.

So given that, then you're suggesting just complete polling of all affected doors? So in other words, don't worry about triggering off the door field at all, just poll all doors all the time for changes in their state?

It's probably well within CQC's capabilities. But it seems like using the logic server to at least tell me when a *single* door (or more importantly, window) is open, and then I can actively poll all of them, until no more are open.

Quote: You could create scan classes for polling and announcments and assign various doors to a given scan class for each. High priority doors like exterior doors (and the dungeon) get polled more frequently and announced more frequently than say interior doors.

Ya, thats true...and again one of the benefits of doing this all in a CML driver...lots of flexibility to how I treat and handle different things that need monitorign.

Quote: For a whole house door open I would probably use a stringlist that just has a 0/1 at each position for the current door state. Then to determine if any door is open you only need to do a If(DoorList.FindString("1",Index)..

Not sure I understand this. By whole-house door open, do you mean just the indication? Id think the logic server was well suited to that. Or do you mean monitoring of every door individually? So, a string list, one string for each door...and when I poll, I'd just go to each door, chech its status, and then save that status in the string list? And then, just check the string list for 1's, and those are how many doors I have open?
Reply
#4
If you create scan classes then you just poll each scan class at a given interval. Scan classes can also be used in normal drivers if you have a large number of fields that would require polling on a frequent basis. You have several scan classes with the same sampling rate, but you stagger them so you aren't trying to read too many fields at once.

The stringlist was in reference to having a field that is a global indicator if any door is open. If you are going to be polling the fields you may as well just use that information. At intialization you would create a StringList that has a "0" for every item of interest. Then when you poll you just use a SetAt to flip it on or off. After a poll round all you need to do is check if there is a 1 present in the stringlist. I suppose you could do it with a string as well. That would only be as accurate as your slowest polling class. If you were only polling a class every 10 seconds and one of those were open it would take until the next poll cycle for that flag to be set back to off.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#5
You keep mentioning scan classes...so I feel I should know what those are. :oops: Do you mean creating a new CML object?
Reply
#6
Actually its not a formal class or anything. It really just means a group. So any member of the group is sampled/updated at the same rate.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#7
Ok. I was afraid it was some new technology coding mechanism that has crept up on me. It's hard to keep up with you kids... :tounge

Why use XML for the configuration file? I know the world has a love affair with XML like it's some new technology that defies all preconceptions....I just see it as a text file that can be a pain to manually edit. I suppose the advantage is being able to group things as sets or something?
Reply
#8
Using a structured format like XML allows for accessing the configuration as structured data. A CSV file is structured data as well, but there aren't any built in classes in CML to deal with it in an ordered unless you set it up as a data source and use ODBC. I guess it is just a personal preference....go with what you know.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply
#9
jrlewis Wrote:go with what you know.

Heh..if I did just that, I wouldn't get very far. Ok, structured input that has built-in CML reading capabilty makes sense. And it would also be a good warm up, as I need to convert my NWS alert driver to the built-in CML functions too before I give it to Dean.

Is there an easy/free way for modifying XML files? I've only ever found simple XML readers. To modify the XML, I've always had to go in to the xml file via a text editor.
Reply
#10
I like getting my hands dirty. I use PSPad for just about everything I do.
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  An Idea - CQC as Front End for Home Assistant znelbok 3 234 04-28-2022, 07:58 PM
Last Post: kblagron
  Driver for Amazon 4k Stick Darrie 3 432 01-15-2022, 02:21 PM
Last Post: znelbok
  CQSL Interface Driver connects but no control NightLight 3 493 10-26-2021, 01:12 PM
Last Post: NightLight
  WebRiva add to home screen fix NishanF 2 1,087 11-16-2020, 08:54 AM
Last Post: sic0048
  ClickPLC driver now failing after upgrade znelbok 2 941 09-21-2020, 10:48 PM
Last Post: znelbok
  IR Control LesAuber 1 784 08-03-2020, 07:40 PM
Last Post: LesAuber
  Pentair driver tom 5 1,873 08-02-2020, 11:29 PM
Last Post: kblagron
  Marantz receiver driver (IP) dlmorgan999 6 2,005 05-15-2020, 03:32 PM
Last Post: dlmorgan999
  Variables Driver Client gReatAutomation 4 1,611 04-25-2020, 12:46 PM
Last Post: gReatAutomation
  Reconfig of Driver Causes Built In Triggers to Fire gReatAutomation 2 1,195 03-25-2020, 04:09 PM
Last Post: gReatAutomation

Forum Jump:


Users browsing this thread: 1 Guest(s)