External Time Source / Schedule Driver for SmartThings


(Bruce) #1

There is a mechanism by which you can solidify some of the scheduling issues in SmartThings, the ones involving repeating schedules, such as polling. The mechanism is to give your system an external time source.

My setup happens to have an Arduino / ThingShield, for my Lutron integration. It was trivial in the Arduino sketch, and the ThingShield device handler, to put in a once a minute message from the Arduino. This is not clock resolution timing, for sure; but it is heartbeat timing that is rock solid. I would not recommend running something like this faster that once a minute.

I have mine set to toggle a virtual switch. I can use that for other purposes, in Rules.

You could build this out of any Arduino / ThingShield pair, including Uno, Mega, etc. It costs $80 +/-.

Time based events failing?
Announcement: New "Update" feature in the IDE
runIn does not run at specific intervals
[RELEASE] Simple Device Viewer
(Geko) #2

Oh, I see, this is how SmartThings is going to make money. The $99 hub cannot keep time, so you have to buy a $35 ThingShield and an Arduino to complement it. :wink:

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #3

Indeed… probably much less; $35 for the shield, $10 for a clone Uno… :smile:

For a little more, you can add an “very accurate” RTC (Real Time Clock chip) with a battery (there are semi-accurate ones, and very accurate ones). And, I’m typing this quick so too lazy to look, but I’d bet a “cron” library is available.

So here’s a very feasible project:

  • A “CRON Device Type” (based on Arduino with RTC , a cron or similar scheduling library, and a ThingShield to receive schedules and send schedule triggered event calls.)

  • Alternatively build using a small Linux instance on rPi or PC type and use REST-API and Service Manager SmartApp to receive the calls. Then you could run real Linux CRON.

  • And 3rd alternative is to use a cheap hosting service (< $1.00 month) to do the second option.

SmartThings won’t be too happy if we “pound it” with incoming Events … but, heck, the Power Usage Events from the ZigBee Centralite / SmartThings Power Outlet are super frequent anyway.


I’d better a dozen readers of this could whip this up in a couple days, with a couple weeks of tuning and features to make an MVP.

(Bruce) #4

LOL. Yes indeed. I have become a co-conspirator in their secret plan. HeHeHe

(Geko) #5

You should ask for commissions. :wink:

(Bruce) #6

Yep. This isn’t very hard to do, and as you say, if you want a real clock, that’s not hard either. Then, someone could write a simple scheduler app on the Arduino, as you suggest, and just move this challenging-to-ST task from the cloud to a $25 computer.

Voila! Hardened schedules.

(Geko) #7

How about I’ll make it for less than $2 using ESP8266? :slightly_smiling:

(Bruce) #8

Oh boy, sounds good. Are you sure you can’t get the price down some?

A zigbee clock, HA capable, so it can join ST.

And, it’s a zigbee repeater, just a little thing you plug in somewhere, with a battery backup. Reports AC power out / on.

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #9

Go for it.

Though since folks only need 1 per household, super-minimizing the cost may not be necessary.

Sure … perhaps someone could markup a few bucks, but doubt more than a couple thousand would be bought…

So… Is there a reliable “cron” library for Arduio / ESP8266 / ? …

(Mike Maxwell) #10

Don’t get @tgauchat started on capability calendar. …

(Bruce) #11

Calendar can be a unique-to-the-zigbee-clock capability.

(Geko) #12

This is all funny, of course, but in all honesty, I feel sorry for SmartThings engineers who seem to have no pride in what they do for a living. How difficult is it to write a virtual RTC device that runs locally on the hub? I bet it would take me less than two days. :slightly_smiling:

(Mike Maxwell) #13

I’m sure the hub already knows what the correct time is, I’m guessing this is more of an architectural backed into a corner issue…

(Bruce) #14

Ya, because they decided to put scheduling of local events into the cloud. Smart. It works so well, they should really be proud.

(Geko) #15

Of course it knows the time. It’s running Linux kernel after all. That’s why it would be extremely easy to do.

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #16

It’s my contention that at least most of the “engineers” are competent and proud of what they have accomplished as a whole… But they are constrained by management and/or legacy architecture defenders. It’s a dysfunctional organization.

(Geko) #17

Sure, but don’t you think those who willingly work for a ‘difunctional organization’ are prostituting their profession? :wink:

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #18

Oh it’s all relative. I think I might have greater reservations working for a Bank or military contractor… Or not. Ya gotta make a living and folks are pretty good at “containerizing” the scope of their responsibilities. It’s healthy.

(Kevin) #19

[quote=“bravenel, post:1, topic:38398”]
You could build this out of any Arduino / ThingShield pair,
[/quote]I bought the Uno and the ThingShield when I bought my hub, but I never found a use for them so this works out perfectly.

(Geko) #20

Exactly, and I’m not saying it’s wrong. It’s just a J.O.B., nothing personal. There’s no room for pride. Case closed.