Is there a way to log specific events?

Posted on
Thu Mar 08, 2012 6:18 am
automatr offline
User avatar
Posts: 21
Joined: Feb 02, 2012

Is there a way to log specific events?

Is there a way to keep a running log of only specific events, perhaps in a text file? An example might be logging time and date of driveway sensor contact closures.

Posted on
Thu Mar 08, 2012 10:54 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Is there a way to log specific events?

If you use SQL logging then you can easily query out specific devices from the SQL database. Otherwise you'd need to write script(s).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Mar 08, 2012 11:56 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Is there a way to log specific events?

automatr wrote:
Is there a way to keep a running log of only specific events, perhaps in a text file? ...
And then jay wrote:
...Otherwise you'd need to write script(s).

One approach is to watch the log file in a shell script using tail and then grep for the events you want. Something like:
    tail -f logfile | grep "some search string" >> /some/log/file
Save your shell script as an executable file and then run it in a startup trigger in Indigo.

I can give a more detailed example if you can post more specifics.

Posted on
Sat Mar 10, 2012 7:55 am
automatr offline
User avatar
Posts: 21
Joined: Feb 02, 2012

Re: Is there a way to log specific events?

Thanks for the replies fellas. Both solutions are a wee bit above my current level of expertise, but I figure I can pick this stuff up pretty quickly.

Berkinet, an example of what I would like to log;

Simply a timestamped log entry of arriving and departing driveway activity, for which I already have several variables that might be useful. These variables change when a pair of magnetic driveway sensors are tripped. Arriving and Departing is determined by the order in which two sensors are tripped. If I could just maintain a log of the DrivewayArrivingTimestamp Variable and DrivewayDepartingTimestamp I would be home free.

DrivewayArriving (used as a programming flag and is reset after a few seconds)
DrivewayArrivingTimestamp (uses the "insert timestamp into variable" from the Action Collection)

DrivewayDeparting (used as a programming flag and is reset after a few seconds)
DrivewayDepartingTimestamp (uses the "insert timestamp into variable" from the Action Collection)

Thanks very much!

Posted on
Sat Mar 10, 2012 10:52 am
ELWOOD offline
Posts: 225
Joined: Feb 11, 2007
Location: Ramsey, NJ

Re: Is there a way to log specific events?

automatr

You might try a different approach. I have a number of outside motion detectors, a small door
that the UPS guy leaves packages in and an alarm system. When any of the devices are tripped
they activate there own triggers that writes a time date to a iCal. Each is written to there own
calendar and set with a different color. When you open iCal showing all three calenders I can
see daily or weekly or monthly activities. All outside motion is in green, alarm arm and disarm
is red and the UPS deliveries are blue.

Here is a copy of the apple script I use to write the drive way motion.

tell application "iCal"
tell calendar "Outside"
set theDate to current date
make new event at end with properties {summary:"Driveway Motion", start date:theDate}
end tell
end tell

You will need to make a separate script for each different condition and a different calendar for each if
you want it to show in an other color.

Hope this might be a simpler solution.

Elwood

Posted on
Sat Mar 10, 2012 11:42 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Is there a way to log specific events?

automate wrote:
...If I could just maintain a log of the DrivewayArrivingTimestamp Variable and DrivewayDepartingTimestamp I would be home free.

    DrivewayArriving (used as a programming flag and is reset after a few seconds)
    DrivewayArrivingTimestamp (uses the "insert timestamp into variable" from the Action Collection)

    DrivewayDeparting (used as a programming flag and is reset after a few seconds)
    DrivewayDepartingTimestamp (uses the "insert timestamp into variable" from the Action Collection)

Ok, since you are maintaining the data in variables, there is an easier way for you to approach this. Here is an example for the Arriving case:
    1) Create a trigger that looks for any change in the value variable DrivewayArrivingTimestamp.
    2) The trigger's Action is to Execute Script.
    3) Set the script to Embedded - AppleScript.
    4) Paste this code as the script
      Code: Select all
      set theLogText to "A car has arrived"
      set theLogEntry to the value of variable "DrivewayArrivingTimestamp" & ":    " & theLogText
      do shell script ("/bin/echo \"" & theLogEntry & " \">>$HOME/driveway.log")
    5) Edit the text for theLogText to whatever you want.
Now, anytime a car arrives in your driveway (causing DrivewayArrivingTimestamp to change) an entry will be recorded in the file driveway.log in your home directory. Of course, you can change the file name and location as you wish.

For the Departing case, just duplicate these steps, but use the Departing time stamp in the trigger and the second line of the AppleScript and change the message text appropriately
.
The key line in the script is the "do shell script" command. This uses the built-in command echo to write the message to the end of the log file (>>). While cryptic, this is a lot easier than opening, writing, and closing the file.

Post back any questions and (hopefully) a report of your success.

Posted on
Sat Mar 10, 2012 1:59 pm
automatr offline
User avatar
Posts: 21
Joined: Feb 02, 2012

Re: Is there a way to log specific events?

I tired both solutions and they both work perfectly. I'm kind of an information junkie and use ical A LOT, so I'm sure both of these methods will find extensive use in my setup.

Thanks guys!

automatr / Jeff

Posted on
Wed Mar 14, 2012 8:11 pm
automatr offline
User avatar
Posts: 21
Joined: Feb 02, 2012

Elwood Your iCal Hack is Incredibly useful! A followup quest

This iCal hack is proving to be incredibly useful, but I'm a little stuck trying to take it a step further. So a followup question if I may ...

Can you tell me how to log the value of a variable to an iCal calendar?

For example, how would one log the value of variable "WaterGallonsUsedToday" to an iCal calendar "Water"
I would like to call this Action Group Event every night at midnight. I know how to do that part, just can't seem to get the variable into iCal.

Thanks!

automatr

Posted on
Thu Mar 15, 2012 10:26 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Is there a way to log specific events?

Code: Select all
tell application "IndigoServer"
   set waterUsedToday to value of variable "WaterGallonsUsedToday"
end tell
tell application "iCal"
   tell calendar "Water"
      set theDate to current date
      make new event at end with properties {summary:"Water used today: " & waterUsedToday, start date:theDate, allday event:true}
   end tell
end tell


Run it at 11:59pm and it'll make a simple all day event named "Water used today: #" where # is the value in the WaterGallonsUsedToday variable. All day events are nice since they show up at the top of each day in any iCal view. I'd also run it as a script file rather than an embedded script (which is why the tell to the IndigoServer is in there).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Mar 16, 2012 6:29 am
automatr offline
User avatar
Posts: 21
Joined: Feb 02, 2012

Works great!

Jay, this is perfect!

Thanks!

Posted on
Sat Mar 17, 2012 8:40 am
ELWOOD offline
Posts: 225
Joined: Feb 11, 2007
Location: Ramsey, NJ

Re: Is there a way to log specific events?

automatr

What are you using to get your water consumption into indigo?

Sound like it can be used to set up a trigger to monitor how long
the kids are in the shower. If they are taking to long I can activate
a solenoid valve to turn off the hot water, that should get them out fast.

Thanks
Elwood

Posted on
Sat Mar 17, 2012 3:41 pm
automatr offline
User avatar
Posts: 21
Joined: Feb 02, 2012

Re: Is there a way to log specific events?

Elwood -

I am using a Meter Master model 20

http://www.meter-master.com/products/fl ... /mm20.html

It's connected to a dedicated water meter that I have in the basement. The output of this device feeds an EasyDAQ digital I/O board on an isolated voltage input.

The model 20 makes 50 pulses for every gallon of water that passes through the meter. This setup did not work well with the EZ8DIO because of the large number of pulses flooding the power line with Insteon data, but seems to do just fine using the EasyDAQ, which is connected directly to a USB port. It does, however put A LOT of traffic in the Event log. Still looking for a way to suppress the logging of that particular input.

Having water consumption logged daily in iCal rocks!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests