Arctic Blast Ice-Jam Warning System

Last winter, a house that I rent out sustained 11 thousand dollars worth of water damage because an ice jam formed above the gutters.  I learned a lot about how this happens during the ordeal.  Heat from the house melts the bottom layer of ice & snow on the roof.  The water from the melting trickles down the roof, but once it gets to the eaves (away from the heat because the eaves are not enclosed and extend away from the house), it freezes and forms a dam.  Since the water has nowhere to go, it backs up from the eaves between the roof and the ice above it and gets under the slates/shingles.

My tenants didn’t notice the water coming in in the dining room through the ceiling and walls until the damage had started showing on the first floor.  Once I was alerted, I hired a company to come and remove the ice dam above the gutters.

The conditions needed for an ice dam/jam to form on the roof are 4 or 5 days where the temperature never gets above freezing and ice or snow has accumulated on the roof.  Dealing with the ice jam was such an ordeal that this year, I wanted to figure out a way (or ways) to get an early warning that an ice jam could be forming.

I had an idea to use a moisture sensor in the windows that would sound an alarm if water made contact with the sensor.  There was one window in particular where the water built up the most, so I bought this cheap moisture sensor (only $12) and installed it between the window and the storm window:

moisturesensor

However, by the time it goes off, a good bit of damage will have occurred already.  That makes it a good backup, but I needed something predictive.  Long ago, I had tried looking into the possibility of getting weather alerts when the temperature stays below freezing for multiple days, however after installing tons of apps and even looking into IFTTT‘s weather channel, the best alerts I could find were when the temperature went below freezing on a single day.  So today I finally sat down and rolled my own way to get an alert after 4 or more days of freezing temperatures in a row.

The basic idea was, I wanted to use IFTTT‘s weather channel to add tomorrow’s high temperature from the forecast to a google spreadsheet every day.  I then would create a google script attached to the spreadsheet to email me when the last 4 entries in the spreadsheet all had values below 33 degrees (F).  The script can be set to be triggered whenever a new row is added.

The first hurdle I faced was that IFTTT only lets you set 1 location for weather alerts and I already have my location set to where I live (not where the house I rent out is) and I already have weather recipes that rely on my location (e.g. when the pollen count gets high, turn on my air filter).  If I was to change the location, all my recipes would use the new location, which made no sense.  So I posted to the reddit IFTTT board and found out from the suggestions there that you can create multiple IFTTT accounts connected to the same gmail address by using gmail’s magical “+” feature.  So if your gmail address is johndoe@gmail.com, you can register an alternate IFTTT account using johndoe+ifttt1@gmail.com.  Note, after you create the account, you’ll need to go into your account settings and change your default username from “johndoe+ifttt1” to something like “johndoeifttt1” because IFTTT complains about the plus sign.

Next, you must create an IFTTT recipe (now called an “Applet”).  The trigger will be the weather channel’s “tomorrow’s forecast” trigger and the action will be to add a row to a google drive spreadsheet.  The settings when you’re done should look like this:

temptospreadsheet.png

Note, you might need to add the Google Drive and WU Weather channels (now called “Services”) to your IFTTT account.  Make sure to go into the weather channel’s settings to ensure it’s set to the correct location and that you’ve given IFTTT‘s google drive channel permission to access your google drive.

Next, you’ll need to create a google drive folder named “IFTTT” (or whatever you entered in the recipe above).  In there, create a spreadsheet with the name you used for the IFTTT recipe.

You then need to add a script to the spreadsheet.  In the google docs tool bar, select “Tools->Script Editor…”.  Replace the code there with the following code, but be sure to enter your email address you want to receive the ice jam warnings.  Click the image to access copyable code on pastebin:

freezingmonitor.png

Save the script, click the “Select function” drop-down list, select the “createSpreadsheetChangeTrigger”, and click the play button.

You can now close the script editor window and test out your spreadsheet by entering temperatures in the first column.  I entered “22”, 4 times to test it out.  2 things should happen upon entering the 4th value:

  1. You receive the email alert
  2. Column 3 gets the value “ICE JAM WARNING!”

Now, when IFTTT adds a row, if it’s the fourth or more day in a row of freezing temperatures, you’ll get an email warning that maybe you should check for an ice jam!

Automatically create iOS reminders based on events added to a subscribed google calendar

My wife just got a new job which has an irregular schedule and long hours.  Unfortunately, I’d gotten accustomed to the fact that she always took care of feeding the cat and scooping her litter before I ever even thought about it.  Now, a few weeks into this new job, I’m getting myself in trouble when I forget to feed the cat or scoop the litter.  I imagine I’ll eventually get used to it, but until I do, I devised a clever way to get automatic reminders without me having to ask my wife her schedule every week and manually create the reminders, which means I’ll be less likely to forget.  Hopefully, I’ll start to get used to the routine and I’ll be able to delete this reminder scheme, but until then, here’s how I managed to do it.

Continue reading

Disable Pesky Facebook Calendar-App Notifications

internet_accounts

Internet accounts accessible via System Preferences are great.  Everyone’s on board.  E.g.:

internet_accounts2

You can create and maintain calendars in them and they all show up in your Calendar apps on your computer and on your mobile devices.  In most cases, you create events and you create alerts for those events and you get your notifications the way you want them. Except Facebook. Sure, Facebook gives you your events and your notifications… and it even shows you events you’ve been invited to: great! What’s not so great? Your friends can create alerts on their events – events you have no intention of ever going to – events halfway across the world – and those alerts trigger on all your devices as if you created the event and set up the alert notification. Other internet accounts, like Google, draw the distinction between your events and events in others’ calendars you’re subscribed to, but did not create yourself.  There are settings in your Calendar app that allow you to ignore alerts from these subscribed calendars.  You can even choose to ignore alerts from subscribed calendars in your Facebook account’s calendar sync, but it doesn’t do anything because don’t forget, facebook adds your friends’ events to your calendar as if you created them. You’re ignoring nothing. You cannot stop the Facebook calendar notifications without turning off all notifications from every calendar in your Calendar app.

So you go about your day and your calendar alert goes off. You take a quick look and get confused about a meeting without a marked location. Then you start digging and find out it’s some event half way across the country about some distant acquaintance’s pub crawl that you got mass invited to. Then you start seeing these notifications all the time! Pretty soon, you stop looking at the alerts and you miss the reminder for your meeting that you scheduled! So annoying.

Being able to see what’s going on via Facebook events in your Calendar app is convenient when you’re looking for something to do in the context of your own schedule, so you hate to delete the Facebook calendar subscription. Luckily, I found a way to stop those pesky alerts, but still be able to see Facebook events in your Calendar app.  Here’s how it works:

Continue reading

Turn your Computer into an iBeacon and Make it Trigger Reminders, Part 2

I’m one of those that does not normally restart my computer, however lately, the power in my office has been going out on a somewhat regular basis, which got me looking into finally automating the starting up of my iBeacon broadcasting.  I had initially created a very quick automator app long ago by recording the 3 clicks it took to start the app, clcik the broadcast button, and then hide the window, but I found that, while it worked when I manually ran it, it always failed upon login (when set as a login item) with this error:

I was able to reproduce this error simply by messing around with (clicking) the mouse as the workflow ran, so I figured that had to have been the problem.  Usually when I log in, I get asked for passwords and such and am rearranging windows on desktop spaces they’d been pulled from as a result of the logout.  I sent a complaint via apple feedback regarding this issue:

Automator won’t run properly as a Login Item

I created an Automator “app” called “Toggle iBeacon Broadcasting”. I created it using the record feature. All it does is click on the BeaconOSX app in my dock, click the “startBroadcasting” Button, and finally, clicks the yellow hide button of the window. I put it as a Login Item so that my Mac would always be broadcasting an iBeacon signal. However, every time I log in, I get this uninformative error: [The action “Watch Me Do (Toggle iBeacon Broadcasting)” encountered an error. Check the actionʼs properties and try running the workflow again.] And every time I run it there-after, it runs fine. However, I was able to reproduce the error by clicking the mouse while it ran, so perhaps automator should detect stuff like that and pause with a dialog asking if it should proceed? Just a thought.

So since the recorded automator workflow had problems with mouse interference, I decided to try an applescript. The first problem I encountered was obtaining the app interface (and you’ll see this ends up being a recurring issue on multiple fronts).  I have a handy applescript called getAppInterface that elucidates an app’s “accessibility” features, and the applescript language necessary to get to them, but I got an error from the system saying that Fastscripts (the menu-bar app I use to run scripts) didn’t have “assistive access” (despite it being in there already):

Error Number:System Events got an error: FastScripts is not allowed assistive access.
-25211

I’ve encountered this issue before.  Apparently, if you edit a script or an app you’re developing, assistive access must be refreshed.  So you have to remove and re-add it from the security preferences pane.  More on enabling assistive access below, however something about Fastscripts must be changing, and I didn’t want to get into it.  Running the script from applescript however worked and I was able to get the handles I needed to write the applescript that will start up the app, start broadcasting, and hide the window.  It’s a pretty simple script:

tell application “BeaconOSX” to activate

tell application “System Events”

tell application process “BeaconOSX”

try

click button “Start Broadcasting iBeacon” of window “BeaconOSX”

on error

try

click button “startAdvertising” of window “BeaconOSX”

end try

end try

click button 3 of window “BeaconOSX”

end tell

end tell

Note that the BeaconOSX app, as written, sometimes changes the button text of the start broadcasting button, so we try both if the first attempt does not work.  If the button text is “Stop Advertising”, nothing will happen.

I added the applescript directly to my login items, but upon testing, I eventually concluded that the script was either not running or quietly failing.  Regardless, I suspected that the accessibility security features could be again interfering with the functioning of the script and that perhaps Apple just had not built in a way to allow individual scripts assistive access.  I didn’t want to deal directly with that, so I sent Apple another piece of feedback:

Too many hoops for login item scripts to get it to work

I had an automator-created recording that was not working (for unrelated reasons), so I wrote an applescript to start an app called BeaconOSX & click it’s broadcast button. The script runs fine manually, but adding it to my login items results in it quietly failing, after which the BeaconOSX window weirdly disappears. (Sometimes I can glimpse it in Mission Control by right-clicking the app in the dock & selecting show All Windows, but it promptly disappears for good once I select it.) Then I tried running it embedded in an automator app set as a login item. Finally I got asked to grant the app access in the security prefs upon login, after which, it worked, albeit very slowly (perhaps 20 seconds after login). The applescript should have worked without the automator wrapper.

Note, the feedback mentions another oddity: the disappearing of the iBeacon window.  I do not believe this had anything to do with iBeacon itself, but rather the windowing system losing track of the window – perhaps because of the assistive access issue.  Again, I didn’t want to deal with it – I just wanted something that would allow me to start up the broadcast reliably.

To get around this, as I alluded to in the feedback, I returned to Automator to embed the script in an app for which I could enable assistive access.  Here’s how to do it:

Create a new automator application (not the default workflow) and drag the “Run Applescript” action from the main library to the pane on the right side and in between the “on run” / “end run” lines, replace whatever’s there with the above applescript.  Save that as “StartiBeacon.app” and then add the app to your login items (System Preferences -> Users & Groups -> Current User (left pane) -> Login Items (tab)) by dragging it into the list of login items.

Then go to System Preferences -> Security & Privacy -> Privacy (tab) -> Accessibility (left pane)and add your app there as well.  If you do not perform this step, the next time you log in, you will get the following error/notification combo:

Clicking the “Open System Preferences” button will bring you to this preference pane:

All you have to do is check the checkbox next to the StartiBeacon app listed there. Though you may need to unlock the preferences pane by clicking the lock icon in the lower lefthand corner.  If you do that, you’ll be asked for your password:

After doing this, the next time you log in, your beacon should start broadcasting automatically, though I noted that it didn’t run for me until about 10-20 seconds after logging in.

This post is more of a description of what I went through to get this all to work.  if there is a desire for a simple step-by-step how-to, please request it in the comments.  I still have not managed to figure out how to tweak the iBeacon settings to get notifications at the expected distance, though I will say that one thing I’ve learned that is non-intuitive is that the higher you set the power, the better the accuracy of the distance measure.  I believe, if I recall correctly, there’s a default distance that’s pretty short, though I’m still very vague on the details.  That’ll be part 3 if I ever get it refined to go off just as I get into my office.

Search Stickies with Spotlight – Hack

Stickies are not searchable by spotlight

I keep a bunch of cheat-sheets & other various notes in Stickies.app, but I have less frequently needed notes in various other kinds of text files and it seemed that whenever I needed to find a certain command that I was sure I’d recorded somewhere, I could never find it.  Well, I discovered the other day that Spotlight does not search the contents of Stickies notes.  I read a lot about it in various blogs.  I even tried to use a set of XCode 4.2 instructions in XCode 6 to create a Spotlight Importer for the Stickies database, but quickly discovered I was in over my head, so I set about constructing a hack to easily save all the stickies as backup text files that would be indexed and searchable by Spotlight.

The catch to this trick is the fact that I have various Sticky Notes bound to specific Mission Control desktops (some of which I hide under the dock with a huge font – to use as desktop labels) and the code for grabbing the stickies content required access to the visible window.  I had first experimented with cycling through the desktops with key code trickery, but discovered a more efficient way – the Window menu item!  Selecting a window in the window menu changes desktops implicitly, so I used the getAppInterface.scpt script (google shows that it’s not out there anymore, so if anyone requests it, I’ll post) to elucidate the menu interface and came up with this script.

set fileName to “”

set stickyNum to 0

set windowMenuListStart to 8

set destFldr to (choose folder with prompt “Choose a destination folder:”) as text

set mydestFldr to POSIX path of destFldr

tell application “Stickies” to activate

tell application “System Events”

tell process “Stickies”

set winMenuList to name of every menu item of menu 1 of menu bar item “Window” of menu bar 1

repeat with winMenuItemNum from windowMenuListStart to (count winMenuList)

click menu item winMenuItemNum of menu “Window” of menu bar item “Window” of menu bar 1 of application process “Stickies” of application “System Events”

delay 0.5

set awindow to name of front window

set noteContent to value of text area 1 of scroll area 1 of window awindow

set stickyNum to stickyNum + 1

set fileName to “stickies” & “_” & stickyNum & “.txt” as string

set theFile to mydestFldr & fileName

do shell script “/bin/echo ” & quoted form of noteContent & ” > ” & quoted form of theFile

end repeat

end tell

end tell

A few notes about the script…  It needed a delay in order for mission control to be able to keep up with the script getting the front window.  If you end up with duplicated and skipped notes, you might need to increase the number of seconds in the delay.

You can only run this script when the screensaver and screen lock is inactive, so putting it in a cron job is not a viable option.  It will cause mission control to change desktops and you may not end up on the desktop you started on when it’s all done.  I tried valiantly to find a way to determine the current desktop number but it looks like that is squirreled away in the code for the Dock and it very difficult to extract.  What you might do to somewhat automate this so that you don’t have to periodically run it manually is use something like ScriptSaver to run the script just before the screen saver comes on.  I have not tried this though and I don’t even know if ScriptSaver is still around.

One last note: if you try to debug an issue by adding dialog windows with messages, note that this will affect the “front window” function.

Once you’ve backed up your Stickies as text files and Spotlight has had time to index them, you will then see search results in the documents section with file names like “stickies_4.txt”.  If you don’t want to wait for Spotlight to do the indexing on its own time, you can go to the Terminal and have it index your newly created stickies backup files with commands like this:

mdimport -d1 stickies_4.txt

The end result is that spotlight searches now show the contents of the stickies you’ve backed up.  The caveat is that you have to occasionally run the script to keep them up to date.  If anyone figures out a better way to do this, I’m all ears – so please comment below.

Deleted Emails Linger in Yahoo Accounts: Root Them Out!

This week, I responded to a message in a yahoo group, which I rarely do. It was the only response to the message which had been reposted just days ago, so I figured they wanted a response. I was surprised then that a couple days had passed without one, so I logged in to send another message. This time, I was using my phone and when I got to the compose interface, it showed that I still had an old email address as the email I was “sending from”. I thought, “Oh, well that’s why I didn’t get a response. I didn’t update my yahoo account when my old email address got deleted.” So I sent a quick message, noting that they should respond to my new email address, and then went about updating my account info.

However, once I got to my account page’s “Email Preferences” tab, it showed that I had already updated the account with 2 new email addresses and had already deleted the old one.  I then double-checked the yahoo group message interface and noted on my computer that it doesn’t even show what email you’re “sending from”. I switched back to my phone to compose the message, and there it was, the old email address again!

yahoo_phone_compose_redacted

Looking back on my computer to try and find evidence of the lingering old email address, I noted a message at the top saying “Your email address <old-email-here> is bouncing! Click here to Unbounce or see More Info.”

yahoo_email_wrong_bouncing_redacted

Both of those links insisted on making my profile public, which I did not want to get into. Besides, I didn’t know what “unbounce” meant – all I wanted to do was delete it.

I started googling around and found (surprisingly) zero information about how to fully delete an email address from your yahoo account that doesn’t show up under the “Email Preferences” tab (which is why I decided to create this post).

As it turned out, I found where it was that the old email was lingering in my account. It was under the “Manage My Groups” tab in my account settings:

yahoo_manage_groups_redacted

So if you ever delete an email from your yahoo account, and even if you assign a new email address as your primary email address, make note that you will have to delete the old email address again under the “Manage My Groups” tab.  The next time you go to edit that page, your old email address will have disappeared.

Turn your Computer into an iBeacon and Make it Trigger Reminders

I’ve been playing around a lot lately with different ways to get reminders other than at specific times and using geofences using the iOS Reminders App. I’ve got a second post in the works for my experiences with WeMo motion-based notifications, but I was excited to learn about iBeacons and was eager to try it out.  This post will detail my early experiences with successfully setting up my iMac at work as an iBeacon and getting reminders from it on my iPhone 4S. When I started looking for iBeacon software, there was no free out-of-the-box way to set them up that I could find. There’s code available and tutorials on how to write the code, but nothing that I could find that gave a layperson’s perspective on how to get it going.  I didn’t want to get into a new coding project.  I just wanted to use what was available.  This post will show you how to turn your office computer into an iBeacon and get reminders when you get to your office or when you leave your office.  It uses, and is based on the excellent code and article for BeaconOSX by Matthew Robinson.

Why would someone need this?  The Reminders app has location-based reminders, you say?  Well, location based reminders in the Reminders App are based on geofences, which are not very accurate.  You get the “when you leave” reminders after you’re a ways down the road, or sometimes even miles away.  Same goes for the “when you arrive reminders”.  At those times, you’re not paying attention to your phone, you’re looking at the road, and the reminder frequently goes unnoticed or forgotten.  With iBeacon reminders, you get “indoor-level” location based reminders, like when you step into a specific room.  When you get to your desk, you get reminders relevant to that setting.  So it’s really handy when setting reminders to make that important phone call or not to forget your gym shorts.

Requirements.  You need at least:

  • iPhone 4S or higher with:
  • A Mac with
    • OS X 10.9 (Mavericks)
    • Bluetooth 4.0
    • XCode (Apple’s developer software, which is free – don’t worry, no coding required)

The first thing we will do is turn your mac into an iBeacon.  Here’s how it works.  First, we will download and compile the BeaconOSX application:

  1. Download BeaconOSX from GitHub (https://github.com/mttrb/BeaconOSX/archive/master.zip)
  2. Unzip the file by double-clicking it.
  3. Double-click on the file named “BeaconOSX.xcodeproj”.
  4. You might be asked to approve new software to be installed.  If so, click “Yes”.
  5. Click the “play” button in the top left corner of the XCode.

This will build and launch the BeaconOSX application.  It will put it in a directory similar to this path, though it might be slightly different:

~/Library/Developer/Xcode/DerivedData/BeaconOSX-bdmdqpzkufjqfjfbtwttnnnsdggz/Build/Products/Debug/BeaconOSX.app

The running app will have a window that looks similar to this:

BeaconOSX

Next, we’re going to get BeaconOSX to start broadcasting an iBeacon signal.  This part took me awhile to figure out, because of that top value in the BeaconOSX window, which is called a UUID.  Each beacon has a UUID which is specific to the app you use to detect it.  I happened to find the UUID in the image above in the sales record for beacons created for the app “Pocket Informant 4.0” (which I had some difficulty getting to work), but I think any UUID might do.  I’d be curious to know more specifics about what makes a valid UUID, but for now, let’s use the UUID above:

A77B94E5-F974-4B6D-B0DD-E3064FCCAA44

Paste that UUID into the top field in the BeaconOSX window and then click “startAdvertising”.

Lastly, we need to install, run, and configure our iOS iBeacon reminders app.  We’re going to use Proximitask.  Though there may be others out there, this was the first one I was able to get to work.  Proximitask is nice because you can enter the same values that BeaconOSX takes.

Go to the App Store App and search for and install Proximitask.  When it’s done downloading, run it.  You’ll see a screen something like this:

screen568x568

We now need to tell Proximitask about our new beacon.

  1. Swipe left until you see a button that says “Add New Beacon”.  Touch that.
  2. Give the beacon a name (I chose “Office”).
  3. Enter the UUID, Major, and Minor values that are in your BeaconOSX window.
  4. Touch save.

Now, you simply need to restart your computer (and possibly your iPhone).  Launch BeaconOSX and click “startAdvertising” again, and you’re good to go.

Proximitask has 2 categories of reminders, “Upon Arrival” and “Upon Exit”.  When you click the “+” icon, you will be able to either create a new task for the highlighted category (“Upon Arrival” or “Upon Exit”), or select one to import from the Reminders App.  You can feel free to play around.  The tasks in Proximitask can be deleted and it will not delete them from the Reminders App.

Some notes…  I have yet to play around with/tweak the power of my iBeacon signal.  I’m getting my reminders well outside of my office.  In fact, my “Upon Exit” reminders are being triggered after I leave the entire building as opposed to exiting my office door.  Tweaking the signal strength might improve that, but I’ve yet to play around with the settings.  It might be that even if I tweak the settings, I might not get the “Upon Exit” reminders in a timely fashion, as I’ve read that some people have experiences spurious triggering of beacon notifications while their phone is right next to the computer.  My guess is that if the signal disappears, Proximitask keeps looking for it for awhile before deciding that you’ve left.  This is probably an attempt to prevent spurious triggerings of notifications.

Also, I have not yet configured a way to keep BeaconOSX running through restarts.  You can definitely add it to your login items under System Preferences->Users & groups->Click your account->Login Items, but that won’t start up the iBeacon Signal.  You’ll still have to click “startAdvertising”.  I may whip up some AppleScript to get that going at some point in the future.

I only this week got this all up and running and will report back on my experience after I’ve been using it awhile.  Have fun playing around with it.