Talk About the Latest in Home Automation/Home Electronics
Home Automation Forum

Smarthome Forum
Shop All INSTEON Products
Login or Register
 
Home | Profile | Register | Active Topics | Search | FAQ | Smarthome
 All Forums
 General Discussion
 INSTEON
 SmartLinc 2412N Time Synchronization
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bmah
Junior Member

USA
30 Posts

Posted - 04/02/2010 :  09:57:19 AM  Show Profile  Reply with Quote
I have a SmartLinc 2412N v2.0. It's very strange that for a
network-connected device that's designed to support turning things on
and off at certain times, there's apparently no way for it to keep its
clock from running fast or slow. Mine seems to lose about 10 seconds
per day.

Technologically, this is not a hard problem to solve...there are at
least two ways that are applicable to the SmartLinc:

1. Synchronize to the 60Hz power-line signal; I'm told that many
electromechanical timers, clocks, and so forth do this.

2. Run some sort of network time synchronization protocol such as NTP
or SNTP. Most network-connected computers are capable of doing this,
and it's not hard for embedded devices to do.

Unfortunately SmartLinc does neither, and I have not seen any
reasonable solutions to this problem ("set SmartLinc's clock every few
months or as needed" as described in the SmartLinc troubleshooting
guide is somewhat astonishing to me).

Given all this, I present my hacky solution...somewhat inspired by the
posts of chadwackerman on these forums.

There is a way to programmatically (using a program such as wget or
curl) to set the clock on the SmartLinc to any arbitrary time. I
wrote a small script to get the local time and set the SmartLinc time
to this. I run this on a FreeBSD server I have in my house, once a
day using cron. (The server's clock is synchronized using NTP to
multiple time servers.) It's nowhere near as good as having real
clock synchronization, but it can at least keep the SmartLinc within a
minute of real time (that's as accurate as it can get).

The gist is:

#! /bin/sh

# Configuration
smartlinc=smartlinc.example.org

date=date
wget=/usr/local/bin/wget

# Retrieve current date
now=`${date} +%H:%M`

# Set it on the SmartLinc
${wget} -q -O - "http://${smartlinc}/1?TD=${now}=1=falsefalse" > /dev/null




A little bit of care is required to make the clock jumps happen far
away from any programmed actions, midnight, or daylight savings time
transitions (which for most of the United States happen at 2AM)...you
don't want to miss or double-trigger events due to clock jumps. I run
mine near the middle of the day.

I'm not sure how to handle authentication (i.e. if a username and
password is required to access the SmartLinc).

Making this work on Linux or MacOS is probably pretty easy (a Mac
might require installation of wget, or conversion to using curl).
Sorry Windows folks, I'm not sure how to make it work for you.

Hope this is helpful to somebody...

Bruce.

snewman
Junior Member

USA
53 Posts

Posted - 05/16/2010 :  12:43:13 PM  Show Profile  Reply with Quote
quote:
Originally posted by bmah

I have a SmartLinc 2412N v2.0. It's very strange that for a
network-connected device that's designed to support turning things on
and off at certain times, there's apparently no way for it to keep its
clock from running fast or slow. Mine seems to lose about 10 seconds
per day.

Technologically, this is not a hard problem to solve...there are at
least two ways that are applicable to the SmartLinc:

1. Synchronize to the 60Hz power-line signal; I'm told that many
electromechanical timers, clocks, and so forth do this.

2. Run some sort of network time synchronization protocol such as NTP
or SNTP. Most network-connected computers are capable of doing this,
and it's not hard for embedded devices to do.

Unfortunately SmartLinc does neither, and I have not seen any
reasonable solutions to this problem ("set SmartLinc's clock every few
months or as needed" as described in the SmartLinc troubleshooting
guide is somewhat astonishing to me).

Given all this, I present my hacky solution...somewhat inspired by the
posts of chadwackerman on these forums.

There is a way to programmatically (using a program such as wget or
curl) to set the clock on the SmartLinc to any arbitrary time. I
wrote a small script to get the local time and set the SmartLinc time
to this. I run this on a FreeBSD server I have in my house, once a
day using cron. (The server's clock is synchronized using NTP to
multiple time servers.) It's nowhere near as good as having real
clock synchronization, but it can at least keep the SmartLinc within a
minute of real time (that's as accurate as it can get).

The gist is:

#! /bin/sh

# Configuration
smartlinc=smartlinc.example.org

date=date
wget=/usr/local/bin/wget

# Retrieve current date
now=`${date} +%H:%M`

# Set it on the SmartLinc
${wget} -q -O - "http://${smartlinc}/1?TD=${now}=1=falsefalse" > /dev/null







This is great, Bruce! Out of curiosity, how did you figure out the URL to set the time? Is this stuff published somewhere?

I'm finding little bits and pieces spread all over the place, and I'd like to document them all in one spot.
Go to Top of Page

ddequarto
Starting Member

USA
2 Posts

Posted - 06/17/2010 :  5:42:37 PM  Show Profile  Reply with Quote
Can someone tell me how this could be done in Windows. Or, explain what has to happen programatically?

thankyou
Go to Top of Page

bmah
Junior Member

USA
30 Posts

Posted - 06/21/2010 :  9:03:02 PM  Show Profile  Reply with Quote
quote:
Originally posted by snewman



This is great, Bruce! Out of curiosity, how did you figure out the URL to set the time? Is this stuff published somewhere?

I'm finding little bits and pieces spread all over the place, and I'd like to document them all in one spot.



There's another user on this forum, chadwackerman, who earlier posted a bunch of hints (in particular how to get the SmartLinc to turn on or off various scenes by accessing URLs on the device). He mentioned that he figured a lot of this stuff out by looking at the HTML source code for various Web pages on the SmartLinc (in particular the URLs for various links). So I just did the same thing for the time-setting page. A little guesswork and testing yielded up the info in my post.

To my knowledge this is not documented "officially" anywhere, so in theory if there are future software updates to the SmartLinc, this method *could* break.

Cheers,

Bruce.
Go to Top of Page

bmah
Junior Member

USA
30 Posts

Posted - 06/21/2010 :  9:18:25 PM  Show Profile  Reply with Quote
quote:
Originally posted by ddequarto

Can someone tell me how this could be done in Windows. Or, explain what has to happen programatically?



I'm not sure, but you basically need to be able to do three things:

1. Find out what the current time is, in a certain format.

2. Execute an HTTP GET request to feed that time to the SmartLinc.

3. Do that GET request periodically to keep the time roughly in sync.

I have no idea if Windows has these facilities or not. If I had to do this on a Windows system, I'd start by installing something like Cygwin, which gives a minimal UNIX-y like environment on a Windows PC. But if you're not familiar with both Windows and UNIX this might be a bit of an undertaking.

Good luck!

Bruce.
Go to Top of Page

Kcspaceman
Starting Member

Canada
7 Posts

Posted - 01/27/2011 :  6:42:58 PM  Show Profile  Visit Kcspaceman's Homepage  Reply with Quote
For Mac OS X users who will likely have curl installed and not wget, you can use this:

#! /bin/sh

# Configuration
smartlinc=smartlinc.example.org

date=date
curl=/usr/bin/curl

# Retrieve current date
now=`${date} +%H:%M`

# Set it on the SmartLinc
${curl} "http://${smartlinc}/1?TD=${now}=1=falsefalse" > /dev/null


Thanks Bruce for the initial code, it works great. :)
Go to Top of Page

bmah
Junior Member

USA
30 Posts

Posted - 01/27/2011 :  7:57:34 PM  Show Profile  Reply with Quote
quote:
Originally posted by Kcspaceman

For Mac OS X users who will likely have curl installed and not wget, you can use this:

(snip)



Looks good, thanks! (Irrelevent comment: I actually put wget on all of my MacOS machines because I dislike the curl default of writing retrieved files to stdout, as opposed to wget and (FreeBSD) fetch, which default to saving the file.)

Bruce.
Go to Top of Page

mmb
Starting Member

3 Posts

Posted - 02/20/2011 :  10:13:14 AM  Show Profile  Reply with Quote
This is excellent! My controller time drifts (like everyone I gather) and lack of ntp sync is a pain. I'm now syncing 3 times a week off my Centos box.

Would be great if the authentication piece was figured out.

Thanks for the help!

mike
Go to Top of Page

EVIL Teken
Advanced Member

Canada
1223 Posts

Posted - 02/20/2011 :  7:12:14 PM  Show Profile  Reply with Quote
Wanted to leave some feed back as well and confirm that the Smartlinc does in fact drift off in time. It's 2011 now and they can't make a device that keeps time for 2 months WTF???

At this point the Smartlinc is being used only as a secondary back up for none essential services. Everything else is being controlled by the ISY-99 Pro which operates like a champ with out silly time problems.
Go to Top of Page

bmah
Junior Member

USA
30 Posts

Posted - 02/21/2011 :  08:37:02 AM  Show Profile  Reply with Quote
@mmb: Glad this helps. I hadn't thought of synchronizing less than once a day...that's probably an additional way to minimize the chance of disrupting programs that with on-off times close to when you do the clock sync operation. I suppose that on my unit, once a week would suffice.

@EVIL Teken: Lack of better timekeeping continues to mystify me too, particularly given that one of the main features of the 2412N is to be able to turn devices on and off at particular times.
Go to Top of Page

BLH
Advanced Member

4359 Posts

Posted - 02/21/2011 :  08:46:05 AM  Show Profile  Reply with Quote
The ISY99i uses the NTP to synchronize the time every 24 hours. Though it can be set to shorter time intervals.
Go to Top of Page

andyf0
Junior Member

USA
43 Posts

Posted - 02/21/2011 :  1:26:59 PM  Show Profile  Visit andyf0's Homepage  Reply with Quote
I don't know if anyone is interested but I wrote a small HTML page to sync the SmartLinc controller's time with your computer's time. Since SmartLinc only takes hours and minutes it will wait for the minute to turn over on your computer before setting the time. This ensures it's accurate to within a second.

Note. I didn't take into account SmartLinc authentication and I've only tested it on IE8.

Thanks to previous posters who gave me the format.

http://home.comcast.net/~andyf0/OldWeb/UpdateSLC.htm

This will create a cookie on your system so you don't have to re-enter the URL and port number each time. Feel free to view and use the source at will.


Andy

Edited by - andyf0 on 06/14/2012 06:59:09 AM
Go to Top of Page

bmah
Junior Member

USA
30 Posts

Posted - 02/21/2011 :  2:58:43 PM  Show Profile  Reply with Quote
quote:
Originally posted by andyf0

I don't know if anyone is interested but I wrote a small HTML page to sync the SmartLinc controller's time with your computer's time. Since SmartLinc only takes hours and minutes it will wait for the minute to turn over on your computer before setting the time. This ensures it's accurate to within a second.


That's very cool. Thanks for sharing this!

Bruce.
Go to Top of Page

EVIL Teken
Advanced Member

Canada
1223 Posts

Posted - 02/21/2011 :  4:40:31 PM  Show Profile  Reply with Quote
Andy,

From the bottom of my heart . . . Thank You Sir!!
Go to Top of Page

mmb
Starting Member

3 Posts

Posted - 02/27/2011 :  4:20:54 PM  Show Profile  Reply with Quote
Very cool Andy.

The authentication piece is still bothering me because I want to use from my iPhone while keeping time up to date with ntp. So I added an authenticated reverse proxy (I don't care about the lan - I own it Works great and syncs nicely with mobilinc pro...

Of course everyone knows the real fix is building ntp into the controller

Anyway, works for me...

Thx

mike
Go to Top of Page

andyf0
Junior Member

USA
43 Posts

Posted - 02/27/2011 :  4:31:46 PM  Show Profile  Visit andyf0's Homepage  Reply with Quote
I believe Safari will allow the http: //User:Password@home.comcast.net/~andyf0/OldWeb/UpdateSLC.htm format. This should get around the authentication issue on the iPhone. It appears only IE blocks this method of authenticating because it's not secure. There is a registry key you can set in Windows to override the security in IE.

Andy

Edited by - andyf0 on 06/14/2012 06:59:35 AM
Go to Top of Page

EVIL Teken
Advanced Member

Canada
1223 Posts

Posted - 02/27/2011 :  5:21:07 PM  Show Profile  Reply with Quote
Andyf0,

You rock . . . Much thanks again for giving the little guy an alternative solution.
Go to Top of Page

andyf0
Junior Member

USA
43 Posts

Posted - 02/27/2011 :  5:31:55 PM  Show Profile  Visit andyf0's Homepage  Reply with Quote
Stay Tuned. I'm working on a demo of SmartLinc Control using the same HTML/Javascript functionality. Getting the device status requires running the HTML/Javascript locally but currently seems unreliable. Working on it.

Andy
Go to Top of Page

mmb
Starting Member

3 Posts

Posted - 02/27/2011 :  7:12:11 PM  Show Profile  Reply with Quote
Good work Andy - I'll happily drop the proxy and I'm sure everyone will appreciate the effort!
Go to Top of Page

williegoat
Starting Member

USA
4 Posts

Posted - 07/12/2011 :  6:58:12 PM  Show Profile  Reply with Quote
quote:
Originally posted by bmah

I have a SmartLinc 2412N

....(snip)....

Hope this is helpful to somebody...

Bruce.




Thank you! You have solved one of the two BIG disappointments with the SmartLinc. I set this script up to run as a cron job on my Debian machine, and it works great.

I'm a grumpy old man, and I approve of this message
Go to Top of Page

ravedog
Starting Member

USA
2 Posts

Posted - 10/03/2011 :  01:17:14 AM  Show Profile  Reply with Quote
quote:
Originally posted by bmah
The gist is:

#! /bin/sh

# Configuration
smartlinc=smartlinc.example.org

date=date
wget=/usr/local/bin/wget

# Retrieve current date
now=`${date} +%H:%M`

# Set it on the SmartLinc
${wget} -q -O - "http://${smartlinc}/1?TD=${now}=1=falsefalse" > /dev/null





Bruce,

is the format for the NOW variable HH:MM in 24 hour format? Or does the unit need date as well? I'm writing an applescript app that runs a shell script calling curl... will post it here in the next couple weeks when I finally get my first Insteon gear.

Also, is there a way to poll the unit using http to get the time from the unit?

Thanks,

Garrett

Edited by - ravedog on 10/03/2011 01:20:30 AM
Go to Top of Page

bmah
Junior Member

USA
30 Posts

Posted - 10/03/2011 :  12:39:46 PM  Show Profile  Reply with Quote
quote:
Originally posted by ravedog

is the format for the NOW variable HH:MM in 24 hour format? Or does the unit need date as well? I'm writing an applescript app that runs a shell script calling curl... will post it here in the next couple weeks when I finally get my first Insteon gear.

Also, is there a way to poll the unit using http to get the time from the unit?



Yes it's 24-hour time. Not sure about the date part. My assumption at the time was that I could get the SmartLinc somewhere in the vicinity of real time, and that I just needed to keep it there. Also this was one of the reasons that I mentioned keeping the clock jumps away from midnight.

Hrm, as for polling the unit, I'm not sure. I presume that you could screenscrape this information from anywhere it displays time. I apologize for not being very much help here...I actually decomissioned my 2412N awhile ago and replaced it with an ISY-99 (the hack I needed to do for time synchronization was one of the reasons for this).

Why do you want to do this...is this to track the time drift? If so, note that the time is only displayed or set on the granularity of a minute, so tracking a few seconds' time drift is going to be very tricky.

Bruce.
Go to Top of Page

ravedog
Starting Member

USA
2 Posts

Posted - 10/03/2011 :  1:14:58 PM  Show Profile  Reply with Quote
quote:
Originally posted by bmah

quote:
Originally posted by ravedog

is the format for the NOW variable HH:MM in 24 hour format? Or does the unit need date as well? I'm writing an applescript app that runs a shell script calling curl... will post it here in the next couple weeks when I finally get my first Insteon gear.

Also, is there a way to poll the unit using http to get the time from the unit?


Hrm, as for polling the unit, I'm not sure. I presume that you could screenscrape this information from anywhere it displays time. I apologize for not being very much help here...I actually decomissioned my 2412N awhile ago and replaced it with an ISY-99 (the hack I needed to do for time synchronization was one of the reasons for this).

Why do you want to do this...is this to track the time drift? If so, note that the time is only displayed or set on the granularity of a minute, so tracking a few seconds' time drift is going to be very tricky.

Bruce.




Well, it's more of a curiosity thing and also a confirmation thing... you want to "write" the time to the unit, you want to read it back to confirm it changed. That's all. Thanks for the help.

I'd like to get the 99 eventually, however this is my first jump into things and, well I'm just trying a few devices and an iPhone to kick the tires so to speak, before I go completely mental on hooking everything up.
Go to Top of Page

PhilLesh69
Starting Member

USA
1 Posts

Posted - 11/26/2011 :  05:28:40 AM  Show Profile  Reply with Quote
quote:
Originally posted by mmb

Very cool Andy.

The authentication piece is still bothering me because I want to use from my iPhone while keeping time up to date with ntp. So I added an authenticated reverse proxy (I don't care about the lan - I own it Works great and syncs nicely with mobilinc pro...

Of course everyone knows the real fix is building ntp into the controller

Anyway, works for me...

Thx

mike



In the wget command, add --user=USERNAME --password=PASSWORD before the -O switch.
Go to Top of Page

barnabas1969
Junior Member

USA
52 Posts

Posted - 10/08/2012 :  5:47:55 PM  Show Profile  Send barnabas1969 an AOL message  Reply with Quote
I was very interested in this thread. Unfortunately, I wanted to do this from my router (running DD-WRT). The problem is that the wget command in DD-WRT does not seem to support any kind of user authentication.

So, I resorted to having one of my Windows PC's (that wakes regularly for other tasks anyway) do this. I wrote the following PowerShell script that will sync the time on the SmartLinc to within 500 milliseconds (1/2 a second) of the PC's time. If you're smart, you can make this happen immediately after the PC syncs with a time server (using events to trigger a scheduled task). You'll also need to configure your PC to allow PowerShell scripts to run. Here's the code:

$username = "MyUserName"
$password = "MyPassword"
$IPaddress = "192.168.1.123"
$port = "80"
###
$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential($username, $password, "")
do {
    write-host (get-date).second
    [System.Threading.Thread]::Sleep(500)
    }
until ((get-date).second -le 1)
#
$dow = (get-date).DayOfWeek.Value__
if ($dow -eq 0) {$dow = 7}
if ($dow -eq 1) {$weekstr = "=t=f=f=f=f=f=f"}
elseif ($dow -eq 2) {$weekstr = "=f=t=f=f=f=f=f"}
elseif ($dow -eq 3) {$weekstr = "=f=f=t=f=f=f=f"}
elseif ($dow -eq 4) {$weekstr = "=f=f=f=t=f=f=f"}
elseif ($dow -eq 5) {$weekstr = "=f=f=f=f=t=f=f"}
elseif ($dow -eq 6) {$weekstr = "=f=f=f=f=f=t=f"}
elseif ($dow -eq 7) {$weekstr = "=f=f=f=f=f=f=t"}
write-host $weekstr
$myhour = [string] (get-date).hour
$myhour = "0$myhour"
if ($myhour.length -gt 2) {$myhour = $myhour.substring($myhour.length - 2, 2)}
$mymin = [string] (get-date).minute
$mymin = "0$mymin"
if ($mymin.length -gt 2) {$mymin = $mymin.substring($mymin.length - 2, 2)}
$webpage = $webclient.DownloadString("http://$IPaddress`:$port/1?TD=$myhour`:$mymin=1=falsefalse")
$webpage = $webclient.DownloadString("http://$IPaddress`:$port/1?D=1=1$weekstr")
write-host "Time set to`: $myhour`:$mymin"


Save it as a file with a file extension of .ps1, and allow PowerShell code to execute on your Windows PC. Then, add it as a scheduled task to run on whatever frequency you like... but make sure it runs at least once a day... and will run as soon as possible after the PC wakes... or wakes the PC to run. Even better if you can trigger a time sync on the Windows PC immediately before this script runs.

Edited: To make the code also set the correct day-of-week. Woo hoo!

Edited by - barnabas1969 on 10/08/2012 6:48:32 PM
Go to Top of Page

chuck5395
Starting Member

5 Posts

Posted - 03/12/2013 :  6:23:09 PM  Show Profile  Reply with Quote
quote:
Originally posted by andyf0


http://home.comcast.net/~andyf0/OldWeb/UpdateSLC.htm

This will create a cookie on your system so you don't have to re-enter the URL and port number each time. Feel free to view and use the source at will.





I'm sad to say that this link no longer works. Sigh...
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Smarthome Forum © 2000-2014 SmartLabs, Inc Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07