Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Set your ELK Clock
#1
I hate having lots of devices with their own clocks. One of my favorite automation tasks is to have the server update the clocks of all the little devices that have clocks.

Here's how I do it for the ELK:

Code:
System::FormatTimeVal
    P1=[local]
    P2=LVar:dayOfWeekName
    P3=Pattern
    P4=\%(d)

If System::Equals
    P1=%(LVar:dayOfWeekName)
    P2=Sunday

LocalVars::SetVariable
    P1=LVar:dayOfWeekNumber
    P2=1

End

If System::Equals
    P1=%(LVar:dayOfWeekName)
    P2=Monday

LocalVars::SetVariable
    P1=LVar:dayOfWeekNumber
    P2=2

End

--- Repeat above for Tuesday, Wednesday, Thursday, Friday, Saturday ---

System::FormatTimeVal
    P1=[local]
    P2=LVar:timeString
    P3=Pattern
    P4=\%(s,2,0)\%(u,2,0)\%(H,2,0)%(LVar:dayOfWeekNumber)\%(D,2,0)\%(M,2,0)\%(y,2,0)

Devices::FieldWrite
    P1=Security.Passthrough
    P2=rw%(LVar:timeString)
    P3=True

This code is in a scheduled event that fires every day at 2:30am.

--Bob
Reply
#2
I would'a thunk I'd have had a standard RTV for current week day number, but I guess not. But there is a fairly simple hack you could use to get it, and that would let you cut that action down a lot. I'm doing this by eye, so I may have made some mistakes but:

LocalVars::CreateVariable(LVarBig GrinayList, MEng.String, "Enum: Sunday, Monday, .....", %(StdRTV:WeekDay));
LocalVars:GetEnumOrdinal(LVarBig GrinayList, LVarBig GrinayNum);


So you create a local string variable, make it an enum and set the limit to the days of the week, and set the inital value from the day of the week standard runtime value. So now it's set to the correct day. You can then get the ordinal value of the the variable, which will be the index of the limit value that is currently set.

So that gets you the day of the week number in two lines.
Dean Roddey
Explorans limites defectum
Reply
#3
Ah, very nice. Thanks to Dean's clever use of Enum here is the new version:

Code:
LocalVars::CreateVariable
    P1=LVar:dayOfWeek
    P2=String
    P3=Enum: DontWantZero, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
    P4=%(StdRTV:WeekDay)

LocalVars::GetEnumOrdinal
    P1=LVar:dayOfWeek
    P2=LVar:dayOfWeekNumber

System::FormatTimeVal
    P1=[local]
    P2=LVar:timeString
    P3=Pattern
    P4=\%(s,2,0)\%(u,2,0)\%(H,2,0)%(LVar:dayOfWeekNumber)\%(D,2,0)\%(M,2,0)\%(y,2,0)

Devices::FieldWrite
    P1=Security.Passthrough
    P2=rw%(LVar:timeString)
    P3=True

--Bob

BTW, I love the TEST button on the Manage Events screen. One minor nit is that the TIME that is associated with each command is actually the time from the previous command. It didn't take 3.1secs to create an enum variable, it took 3.1secs to write the time to my (lame) furnace controller in CMD 4.

CMD: 005. (3120ms) - LocalVars::CreateVariable
P1=LVar:dayOfWeek
P2=String
P3=Enum: DontWantZero, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
P4=Friday
Reply
#4
Hey Dean,

I seem to recall you adding a function to the ELK driver to make this time setting via passthru nonsense obsolete. However, I can't find any record of it in the forums, or in the ELK driver documentation. Did I dream it? Oy that would be sick.

--Bob
Reply
#5
I think that must have been for something else. It's not in the Elk driver currently. I don't see it in the HAI either, so it wasn't that. But I do remember adding such a command for something, though it might have been the Tekmar thermos driver. Is there such a command for the Elk?
Dean Roddey
Explorans limites defectum
Reply
#6
Okay, now the easy way to Set Your Elk Clock:

Write "TimeSync" to the "InvokeCmd" field of your elk driver.

Note you need version 2.2 of the Elk driver or later. Dev version posted here

--Bob
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Displaying countdown timer in clock format (not hex) ControlFreak 2 2,252 04-11-2013, 02:13 PM
Last Post: Dean Roddey
  Time Clock DB Driver Available for Testing 0 556 Less than 1 minute ago
Last Post:

Forum Jump:


Users browsing this thread: 1 Guest(s)