Author |
|
jeffw_00 Super User
Joined: June 30 2007
Online Status: Offline Posts: 929
|
Posted: January 28 2008 at 21:22 | IP Logged
|
|
|
Hi - so I'm trying expand on how powerhome sends me an email when something is wrong. I want it to make a timestamped log entry, and I have many problems..
1) I want to get the day/time into a variable. I guessed the command is something like
ph_setvar_s(1,7,today())
but this doesn't work. nor do any permutations that i try.
2) originally I wanted to do something like
Launch App "echo <stuff> >> c:\insteon.log".
But this doesn't work. My guess it that it can't run the internal "echo" command.
So I wrote a very short perl script that does the work of Echo. That worked, but I'm surprised I can't use the echo command.
Anyway, does anyone know how to get today() into a variable, and/or if there's an easier way of doing this?
the rest of my script, BTW looks like.
ph_setvar_s(1,7," [LOCAL8]: INSTEON ERROR (count = {IERROR} ), Device [LOCAL1], Desired State [LOCAL2], Trigger [LOCAL3], Returned Status [LOCAL10]")
"c:\perl\bin\perl c:\insteon\writelog.pl [LOCAL7]"
thanks
/j
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 28 2008 at 22:31 | IP Logged
|
|
|
Multitasking here, but...
1. This returns what you would expect:
Code:
string(today(),"yyyy mm/dd h:mm:ss am/pm") |
|
|
2. My CIDLOG macro logs to a file using ph_writefile.
Also, here's a formula from my TSTAT macro that logs...
Code:
ph_writefile( "c:\program files\powerhome\hvac.log", if( ph_fileexists( "c:\program files\powerhome\hvac.log") = 1, 0, 1), "{TSTAT TEMP T}" + " " + "{TSTAT SP}" + " " + "{TSTAT TEMP} " + {TSTAT RUN T} + " {CURTEMP}" + char(13) + char(10) ) |
|
|
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: January 28 2008 at 22:33 | IP Logged
|
|
|
Jeff,
No problem . The output of the today() function is a datetime type and the ph_setvar_s function wants a string so we just have to convert it. This is good, because it also gives us an opportunity to get the date/time in a format we like. Try this:
ph_setvar_s(1,7,string(today(),"yyyy-mm-dd hh:mm:ss.fff"))
This should give you what you want.
To write to a log though, you don't even need to use echo or shell out to perl. You can do it all easily within PowerHome. I think this may give you what you want.
ph_writefile("c:\insteon.log",0,string(today(),"yyyy-mm-dd hh:mm:ss.fff") + " [LOCAL8]: INSTEON ERROR (count = {IERROR} ), Device [LOCAL1], Desired State [LOCAL2], Trigger [LOCAL3], Returned Status [LOCAL10]")
Hope this helps,
Dave.
**EDIT: Damn Tony...beat me to it . Great minds think alike it appears though.
Edited by dhoward - January 28 2008 at 22:35
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 28 2008 at 22:50 | IP Logged
|
|
|
Heh!
|
Back to Top |
|
|
jeffw_00 Super User
Joined: June 30 2007
Online Status: Offline Posts: 929
|
Posted: January 28 2008 at 23:35 | IP Logged
|
|
|
yeah - I missed ph_writefile - thanks guys. But this was the easy one. if you want a challenge, take another peek at
http://www.myx10.com/forum/forum_posts.asp?TID=1634&PN=1
and/or
http://www.myx10.com/forum/forum_posts.asp?TID=1628&PN=1
8-}
Thanks again
/j
Edited by jeffw_00 - January 28 2008 at 23:35
|
Back to Top |
|
|
|
|