Alarm Clock Plugin

Posted on
Wed Jun 08, 2016 3:48 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Alarm Clock Plugin

IndigoPluginDownload.png
IndigoPluginDownload.png (14.88 KiB) Viewed 3969 times


Introduction

Alarm Clock is a plugin that lets you treat your devices as alarms. While there are many ways to accomplish doing this (i.e., via iCal events), this has a few unique features that I wanted in my own setup. For one thing this plugin has been designed around use on a control page where single taps of a graphic can manage the alarm.

I have many uses for this in my Indigo setup already, but the one that really precipitated me writing it was my wife's crazy travel schedule. Often times she will have to get up a 3 or 4am to catch a flight and when it's this early she sleeps in the guest room. Because she is awesome she has fully embraced all my home automation geekiness and asks me to "set the house to turn on the lights in the guest room at 3am". I used a series of schedules and action groups to turn on the lights and then turn them off when she leaves the house. This plugin puts it all in one place.

In summary, this plugin will:
  • Turn on and off any device in your Indigo network that responds to On and Off commands (this includes virtual groups)
  • Control all aspects of the plugin via a control page, such as changing the alarm time, the days of the week to use it, duration until off and turning the alarm on and off
  • Provides timers for the control page (compatible with LCD Creator) to show HH:MM until the alarm and HH:MM until the alarm turns off
  • Lets you "hard code" alarm settings into the plugin and reduce how much control a control page has over the alarm
  • Includes a "blink" ability to blink the device or devices a configurable number of times
  • Includes using text-to-voice to also "say" something when the alarm goes off and how repeat it 3 times (i.e., "Get up!")
  • Ability to manually turn the alarm off (instead of waiting for the auto off) and in doing so has a configurable option to set the wait time until it executes (great for turning off the alarm but giving it a few minutes before turning off the lights so you don't have to leave a dark room)
  • Like a regular alarm clock it will know when you set your alarm if it is valid for today or, if you have set certain days of the week, to make it for next week instead
  • Ability to let an alarm recur so once it has activated it will re-schedule itself for the next occurrence
  • Indigo device list will show the state as Green with a countdown if it is turned on, Grey with "Off" if turned off and Green with "Active" if the alarm is currently active

It does not have a snooze, I had considered adding this feature (and it would be quite simple to add) but when you consider the amount of effort required to wake up, grab your phone (or iPad), unlock it and tap the "snooze" graphic, you are likely wide awake :). Then again you could tie the snooze to a Insteon button pad instead... Let's put a pin in that for "if people ask for it".

This screen shot is just an example of how it can be used on a control page, the graphics are NOT part of this plugin!
IMG_0627.PNG.png
ROM RNS Screenshot
IMG_0627.PNG.png (428.12 KiB) Viewed 4337 times


Download and Installation

Install according to the Indigo documentation.

Download Plugin (Indigo File Library)

Release Notes

  • June 8, 2016 (1.1.0):
    • Added optional alarm on and alarm off action group execution
  • June 8, 2016 (1.0.0):
    • Initial release

Configuration and Use

Simply add a Alarm Clock device for each alarm you want to have and set the options.

Screen Shot 2016-06-08 at 7.26.48 PM.png
Device Config
Screen Shot 2016-06-08 at 7.26.48 PM.png (69.03 KiB) Viewed 4603 times


Screen Shot 2016-06-08 at 3.29.40 PM.png
Indigo Device View
Screen Shot 2016-06-08 at 3.29.40 PM.png (21.66 KiB) Viewed 4749 times


Options:
  • Toggle Device: Any Indigo device that supports On/Off, including virtual device groups
  • Increment: How many minutes to add or subtract each time an Increase/Decrease Minutes is called or Increase/Decrease Duration is called
  • Alarm Default Duration: How many minutes until the Toggle Device is turned off automatically
  • Times to Blink: As soon as the alarm time is reached the plugin will blink the Toggle Device on and off this many times. Enter zero if you don't want to blink
  • Alarm On / Alarm Off Action: Optional action groups to execute when the alarm goes off or when it shuts down (or both)
  • Say: What to say through Indigo when this alarm goes off. Leaving this blank will disable this feature.
  • Manual Off Delay: How many minutes to wait after someone has manually turned off an active alarm before the lights go out. For example, you have a default duration of 60 minutes - this means in 60 minutes the Toggle Device is turned off - when someone manually turns off the alarm in, say, 30 minutes then the devices will stay on for this many more minutes to give the person time to clear the room before it is turned off. You can enter zero here if you don't want to use this feature
  • Show Time in 24 Hours: As it implies, instead of showing the alarm time at 01:00pm it will instead show as 13:00
  • Recurring Alarm: Whenever this alarm is turned off (manually or automatically), if this option is checked then it will automatically schedule the next alarm according to the other settings (i.e., tomorrow or the next instance of a day selected for days of week)
  • If Not Today Show +xxD: If this is disabled then the countdown to alarm / countdown to alarm off / Indigo device list text will show HH:MM. If this is enabled these displays will instead say, for example, "+01D" to let you know the alarm is more than a day away, once it is less than 24 hours it will revert to HH:MM again.
  • Set Days of Week Via Control Page: When enabled the days of the week the alarm will enable is set purely from the control page (and thus read from states), when disabled you can select which days of the week the alarm will enable (thus read from props). Changing this setting effectively ignores the the alternative option
  • Days of the Week: Optionally select which days of the week this alarm will enable on. This is to say that if you turn ON the alarm on Monday and you have selected Wednesday on this list then the alarm will schedule for Wednesday and not today. Also for recurring events this list is used to determine the next occurrence of this alarm

Advanced

As already stated, this has been optimized to use with control pages, so it has a number of actions to tie your control page graphics to:
  • Increase / Decrease the hour and minute of the alarm
  • Increase / Decrease the auto off time
  • Select which day(s) of the week to enable the alarm
  • Turn the alarm on and off
  • Manually turn off an active alarm

One important action in case things go awry for some reason is Reset Alarm State. If something I haven't quite accounted for happens and the plugin errors out, running this will reset the alarm and turn it off.

Another thing to note is that the readouts will show "HH:MM" or "HH:MM.", the period is there to imitate how alarm clocks add a period to indicate AM or PM. If using 24 hour time this does not show up. This feature was designed this way because it worked quite well when using LCD Creator and looked just like an alarm clock. This only shows up on the alarm set time and alarm off time states, nothing else. If this becomes an issue for some folks then chime in and let me know and I'll see about reworking that, but even if you don't use LCD Creator it should still look good.

The current ROM screenshot is a test image, the next version of ROM will include a special new background for the new Rise-N-Shine 400 device :)

Examples of Use

  • Example: Your significant other gets up at 3am every Monday then gets ready for an hour and leaves the house. She sleeps in the guest room for early wake ups. This example turns on the lights at 3am then off at 4am.
    • Device: Add an Alarm Clock device and change these options
      • Device: Whatever is needed
      • Alarm default duration: 60
      • Recurring Alarm: Checked
      • Set days of week: Unchecked
      • Save the device

#Version|2.0#

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 4:45 pm
durosity offline
User avatar
Posts: 3596
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: New Plugin: Alarm Clock

Awesome! I've got something a bit like this bodged together with various AppleScript, but this will do the job so much better!

Computer says no.

Posted on
Wed Jun 08, 2016 4:47 pm
howartp offline
Posts: 3349
Joined: Jan 09, 2014
Location: West Yorkshire, UK

New Plugin: Alarm Clock

Now we just need it to configure the alarm clock on an iPhone ;-)

(I use both audible iPhone alarms as well as lights and airfoil radio tuning on)


Sent from my iPhone using Tapatalk

Posted on
Wed Jun 08, 2016 4:50 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: New Plugin: Alarm Clock

durosity wrote:
Awesome! I've got something a bit like this bodged together with various AppleScript, but this will do the job so much better!

Yea, that's how this started life too, as a bunch of action groups, triggers and schedules. Then (like most of my plugins released here) I wrote a flimsy plugin to help and then am just finally polishing those flimsy plugins up to share on here. This is the result of all that, and the fact that this past weekend I got the "can you set the room to turn on at 3am" and thought "I'm going to complete that stupid plugin this week so she can do it herself". Presto :).

howartp wrote:
Now we just need it to configure the alarm clock on an iPhone

Haha, I can't do much about that just yet but I'm creative, give me a while and maybe I'll dream up something for you :)

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 4:54 pm
howartp offline
Posts: 3349
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: New Plugin: Alarm Clock

Or a.n.other iOS app that supports say a web service that Indigo can interact with?


Sent from my iPhone using Tapatalk

Posted on
Wed Jun 08, 2016 5:06 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: New Plugin: Alarm Clock

howartp wrote:
Or a.n.other iOS app that supports say a web service that Indigo can interact with?

Don't do that to me! Now the wheels are turning and I'm thinking "hmmm, pretty sure I can do that in Cocoa/Swift..." I'm NOT the guy to suggest cool new stuff to :). Crap, that's actually kind of brilliant. If I start down that path I'll be sure to give you credit for the idea :D

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 5:16 pm
durosity offline
User avatar
Posts: 3596
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: New Plugin: Alarm Clock

Colorado4Wheeler wrote:
I'm NOT the guy to suggest cool new stuff to :)


You’ve now been appointed to the position of “Official plugin request man” (As i’m the official indigo spokesman it’s within my power to elevate you to that status). Your new duties will include:

Making ALL plugins that are requested of you
Coming up with ideas for more plugins
Quit all your day time jobs and do this full time..
Etc.

Computer says no.

Posted on
Wed Jun 08, 2016 5:19 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: New Plugin: Alarm Clock

durosity wrote:
You’ve now been appointed to the position of “Official plugin request man”

I hope that comes with a raise because this plugin development stuff doesn't bring squat in for income :P

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 6:35 pm
Korey offline
User avatar
Posts: 512
Joined: Jun 04, 2008
Location: Henderson, NV

Re: New Plugin: Alarm Clock

Nice work!

How about adding the option for a simulated sunrise and music fade in? :wink:

I use these scripts for my alarm clock:

Slowly fades music up:

Code: Select all
tell application "iTunes"
   stop
   set sound volume to 0
   set nOldSoundVolume to sound volume
   repeat with nSoundVolume from sound volume to 0 by -1
      set sound volume to nSoundVolume
      delay 0.0
   end repeat
   set the_playlist to user playlist "Radio Faves"
   set view of front window to the_playlist
   play track "Fréquencesrelaxation" of playlist "Radio Faves"
   set sound volume to nSoundVolume
   repeat with nSoundVolume from sound volume to 100 by 1
      set sound volume to nSoundVolume
      delay 20
   end repeat
end tell



Slowly brightness lights:

(there are a bunch of these scripts for different lights)

Code: Select all
tell application "IndigoServer"
   set deviceName to "Master Bedroom Keypad - B"
   set maximumLightPercentage to 60
   set minutesToSunrise to 30
   
   -- This math is importaint as it sets the number of repeats below
   set raiseLightsBy to round (maximumLightPercentage / minutesToSunrise / 2)
   
   log "Starting to raise the lights by " & raiseLightsBy & "% every 30 seconds over the next " & minutesToSunrise & " minutes to achive a final brightness of " & maximumLightPercentage
   
   repeat minutesToSunrise * 2 times
      -- Turn up the brightness of the device one increment
      brighten deviceName by raiseLightsBy
      
      -- Set a variable with the current brightness of our device so we can log it below
      set currentBrightness to brightness of device deviceName as integer
      
      log "Sunrise Simulator raised " & deviceName & " to " & currentBrightness & "%"
      
      -- Since the parameter minutesToSunrise is in minutes, delay one minute
      -- but loop every 30 seconds to give it a more even increase in
      -- brightening. Note the "minutesToSunrise / 2" and "repeat minutesToSunrise * 2 times"
      -- above to account for the half minute increment.
      delay 30
   end repeat
   
   -- In case there is a rounding error above, set it to the target percentage
   brighten deviceName to maximumLightPercentage
end tell



Changes iTunes to a chosen station after a 15 min or so:

Code: Select all
tell application "iTunes"
   
   set nOldSoundVolume to sound volume
   repeat with nSoundVolume from sound volume to 0 by -10
      set sound volume to nSoundVolume
      delay 0.5
   end repeat
   set the_playlist to user playlist "Radio Faves"
   set view of front window to the_playlist
   play track "CBC Radio One Winnipeg" of playlist "Radio Faves"
   set sound volume to nSoundVolume
   repeat with nSoundVolume from sound volume to 100 by 1
      set sound volume to nSoundVolume
      delay 0.5
   end repeat
   
   play
   
end tell
Attachments
Screen Shot 2016-06-08 at 5.32.34 PM.png
Screen Shot 2016-06-08 at 5.32.34 PM.png (98.3 KiB) Viewed 4632 times

--
Korey

Posted on
Wed Jun 08, 2016 7:14 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: New Plugin: Alarm Clock

I had briefly considered adding in onAlarmOn and onAlarmOff to let you call Action Groups but it is a duplication of the same functionality I have in Scene Toggle and since this plugin supports that one I figured that would be a no brainer.

That being said I could do is add the action group calls to the program quite easily.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 7:30 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: New Plugin: Alarm Clock

Updated!

1.1.0 now has action group calls as an option. At least in the meantime you can use that for your music and simulated sunrise/sunset until I think of good ways to integrate those in without rewriting the plugin :).

Screenshots and documentation updated as well.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 7:38 pm
durosity offline
User avatar
Posts: 3596
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: New Plugin: Alarm Clock

16 minutes to implement a change.. that’s gotta be some kind of record!

also +1 on the whole sunrise simulator idea… i suspect in the winter months that’s really going to help my other half with her “chronic fatigue syndrome”/“sleep apnea”/“M.E.”/“whatever the doctors next diagnose her with”

Computer says no.

Posted on
Wed Jun 08, 2016 8:54 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: New Plugin: Alarm Clock

durosity wrote:
also +1 on the whole sunrise simulator idea

Already on the list from Korey's original request. It sounded like a good fit for the alarm clock plugin so it's something I'm looking into. But, alas, it won't be a 16 minute fix so don't go putting dollar bills in my g-string just yet :D

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Wed Jun 08, 2016 9:09 pm
durosity offline
User avatar
Posts: 3596
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: New Plugin: Alarm Clock

Dollar bills? No way matey.. Scottish pound notes!! Image

Computer says no.

Posted on
Wed Jun 08, 2016 10:31 pm
Korey offline
User avatar
Posts: 512
Joined: Jun 04, 2008
Location: Henderson, NV

Re: New Plugin: Alarm Clock

Colorado4Wheeler wrote:
durosity wrote:
also +1 on the whole sunrise simulator idea

Already on the list from Korey's original request. It sounded like a good fit for the alarm clock plugin so it's something I'm looking into. But, alas, it won't be a 16 minute fix so don't go putting dollar bills in my g-string just yet :D



:D :D :D

Love it!!

Thank you for your FANTASTIC contributions to the Indigo eco system!!

I'm consistantly blown away the the caliber of talent we have in this group!

:D :D :D

--
Korey

Who is online

Users browsing this forum: No registered users and 1 guest