A Deep Rabbit Hole - Home Assistant

I just wanted to add my garage door opener to Apple's Home App.

It really bothered me, for no real reason, that I couldn't. Maybe that's why it bothered me, because I couldn't.

A couple of years ago I would have been able to. The makers of my garage door opener had an open API that many home apps could use.

And then they decided to make it into a subscription model and walled off their 'garden'.

I had mostly written off adding the garage door opener until the YouTube algorithm fed me a video on adding a GDO device that was Home App ready (sort of).

So, I bought the device (a Konnected GDO blaQ), read, watched (and re-watched) the video on how to get it all set up.

However, the Apple Home App support was in Beta and mostly didn't work for me, so I decided to try out the Home Assistant (the device's preferred) approach.

What is Home Assistant?

Home Assistant is an open-source home automation platform. It's a single place to see and control everything in the house, no matter who made it: lights, locks, cameras, thermostats, speakers, sprinklers, even the smoker. Rather than juggling a dozen vendor apps, each with its own idea of "scenes" and "routines," Home Assistant pulls them all into one system. Then you can build automations that span brands, like "when everyone leaves, close the garage and lock the front door." It runs on hardware you own, and much of it works locally, without a round trip through someone else's cloud.

Holy shit ... I did not expect to go this deep

What started out as just getting Home Assistant set up so that I could add my garage door opener to my Apple Home App turned into a several-day adventure to add EVERY IoT device on my network to Home Assistant so that I had a single, unified tool to work from.

It turns out just about anything can get added to Home Assistant! So I added everything. Light switches from several different manufacturers? Check. Sonos Speakers? Check. Synology? Check. Essentially everything. It took the better part of a couple of days to get it all added and set up (not because it was hard ... but because cancer treatments suck and my daughter was home for the Thanksgiving holiday so I wanted to spend time with her!)

In all I added 37 different devices across 17 integrations. Home Assistant thinks I have 80. Apparently the Sun is a device now1, and so is every sprinkler zone and every hard drive in my Synology.

This is a bit overwhelming.

Organizing it all

Since there are so many devices (both real and 'virtual') I needed a good way to organize them. And they all needed to have better human friendly names. They get imported with names like GDO blaQ H4567. I know what that means right now, but in 2 weeks will I know it's my garage door opener? The chemo meds say probably not. Also, how is anyone in my household supposed to know what that means?

So I went about doing three things:

  1. Organizing the devices into areas
  2. Adding Floors for groupings
  3. Renaming the devices to be more human friendly

Areas

Areas were mostly imported from the various hubs and devices that I added. I did have to do a bit of cleaning up (like renaming Master Bedroom to Main Bedroom), and removing areas that were added that I didn't have (Study for example). I did this clean up manually at first and then used Claude to help me go through and rename things when necessary (this was part of the Device Renaming below).

Floors

Home Assistant has the concept of 'Floors' though I would argue that 'Area Groups' might be a better name since that's what it's doing for me2.

Here I exclusively used the Home Assistant API and Claude to group things together. The initial need was I had an area called 'Outdoors', but really outdoors meant:

  1. The Front Yard
  2. The Back Yard
  3. The Patio
  4. The South Yard (a small strip of grass that has its own sprinklers)
  5. The North Side of the House (a small strip of concrete that has a security camera and is the location of the condenser for my HVAC)

Once I realized that Floors weren't really Floors but Area groupings, I was able to split the house up into several Floors for better organization:

  1. Home Interior
  2. Attached Garage
  3. Outside
  4. People
  5. Services

Device Renaming

I used Claude to help with the renaming of items using the Home Assistant API in a very interactive session. I had to approve all of the name changes and would provide alternatives if / when it just wasn't getting it.

OK, now what?

Automations galore ... that's what!

I've set up 16 automations so far. Some are silly, like turning on an Apple TV, opening the FloSports app 10 minutes before a Firebirds game. Some are more security conscious like ensuring that the garage door is closed and the front door is locked when no one is home. I've also got alerts for my Synology when it gets too hot, and alerts for when the battery on my front door gets below a certain percentage so the battery can be replaced.

Here's an example of the Firebirds automation:

alias: Firebirds game in the living room
triggers:
  - trigger: time
    at:
      entity_id: sensor.firebirds_next_game
      offset: "-00:10:00"
conditions:
  - condition: state
    entity_id: input_select.firebirds_watch_location
    state:
      - Living Room
      - Both
  - condition: template
    value_template: "{{ state_attr('sensor.firebirds_goals', 'state') == 'scheduled' }}"
  - condition: or
    conditions:
      - condition: state
        entity_id: person.ryan
        state: home
      - condition: state
        entity_id: person.spouse
        state: home
actions:
  - action: media_player.turn_on
    target:
      entity_id: media_player.living_room_apple_tv
  - wait_template: "{{ not is_state('media_player.living_room_apple_tv', 'off') }}"
    timeout: "00:01:00"
    continue_on_timeout: true
  - action: media_player.select_source
    target:
      entity_id: media_player.living_room_apple_tv
    data:
      source: FloSports
    continue_on_error: true
  - action: notify.mobile_app_ryans_iphone_18
    data:
      title: Firebirds
      message: >-
        Game vs {{ state_attr('sensor.firebirds_goals', 'opponent') }} starts at
        {{ state_attr('sensor.firebirds_goals', 'startTime') }}. The Living Room
        Apple TV is on with FloSports.
mode: single

Instead of a fixed time, the trigger watches a sensor that holds the start time of the next Firebirds game3, and the offset tells it to fire 10 minutes early. When the schedule changes, the automation just follows along.

Wall Panel

With all of this in place I've installed the Home Assistant Companion App on my phone and my wife's phone, as well as an old iPad that has a Dashboard with several tabs that allow for control of the lights, and playing music at various Sonos Speakers. It feels very 'Home of the Future' 🚀

The (Nerdy) Details

For those of you that are curious about how it's set up, this section is for you.

How I host it

There are several ways to run Home Assistant: a dedicated device like the Home Assistant Green, a Raspberry Pi, a virtual machine, or a plain Docker container. I already have home servers managed with Coolify, so I went with the container. It runs from the official home-assistant:stable image, defined as a Coolify service. The Coolify setup itself lives in my infrastructure-as-code repo (OpenTofu).

Some things to know about the container route:

  • Host networking is required. Discovery for things like HomeKit, ESPHome and Apple TVs relies on multicast (mDNS), and that doesn't cross Docker's bridge network. The container runs with network_mode: host.
  • No Supervisor, so no "add-ons". Anything that would normally be an add-on runs as its own container next to Home Assistant. For me that's the Matter server and a security bridge.
  • Backups are your job. Coolify doesn't back up service volumes. I set up Home Assistant's built-in backups: nightly, encrypted, sent to my Synology, which copies them to B2 for an offsite backup.

A friendly URL with Nginx Proxy Manager

Out of the box, Home Assistant lives at http://<server-ip>:8123. That works, but it's not something I want to type, and it's not HTTPS. I already run Nginx Proxy Manager (NPM) on another home server to front my internal services, so Home Assistant got a proxy host there.

  • Wildcard certificate. NPM has a wildcard Let's Encrypt certificate for *.ryancheley.com, issued with a DNS challenge. One certificate covers every internal service, and the individual hostnames never show up in public certificate-transparency logs.
  • DNS. An A record points at the proxy server, managed in OpenTofu like the rest of my DNS.
  • Tell Home Assistant it's behind a proxy. It rejects proxied requests unless you set use_x_forwarded_for and list the proxy under trusted_proxies. Otherwise you get a 400: Bad Request. One quirk I ran into is that on a container install, those HTTP settings had moved into Home Assistant's internal storage, so an http: block in configuration.yaml was ignored.

Tailscale considerations

I don't expose Home Assistant to the internet. Its URL record points at the proxy's Tailscale address, so the name resolves anywhere, but it only connects from devices on my tailnet. That gets me remote access without opening ports. But there are trade-offs:

  • Every client needs Tailscale. Every phone, tablet or laptop that uses the app has to be on the tailnet.
  • Cloud webhooks can't reach it. Some integrations rely on the vendor's cloud pushing updates in. My front door lock is one, and its webhook can't reach a tailnet-only address. Home Assistant has to poll instead, so the lock's status can be a few minutes behind.
  • Certificates need a DNS challenge. Let's Encrypt can't reach a private address to validate it, so the certificate has to be issued through DNS.
  • Inside the house, the local network still matters. Device discovery and local control happen on the LAN, so the server itself sits on the home network and Tailscale is only the way in for people and apps.

What's next

More automations ... a little more money to be spent.

I've bought a few lightbulbs for outside my garage door and plan to add an automation to have their color match any holidays / seasons to add a bit of whimsy. I usually put up Christmas lights, but getting up on a ladder isn't something I (or my wife) feel comfortable with me doing so this will have to do until next year.

I also bought some light switches for my hallway. The idea is to add an automation so that after sunset, when someone gets home and comes in through the garage, the hallway lights turn on so they don't walk into a dark house. It's something I've wanted when coming home from hockey games, so I'm going to get that set up for when I can go to a hockey game again.

Working with Claude

A lot of what I did here I did with the help of Claude. It really did get me up and running quickly, especially with getting Home Assistant self-hosted, which is what made everything else possible. I'm not sure if collaboration is the right word here for what was done, but it did feel collaborative. I didn't just set it off to do its thing and come back to a mess. Claude and I iterated, each of us checking our own work and the other's. It helped turn a project that started as adding my garage door opener to Apple Home into the full-fledged home automation setup I've wanted for a while.

  1. Living in the desert, I guess it makes sense 😄. It's also what lets automations know when sunset is. ↩︎
  2. I live in a single story home and so I initially didn't think about using Floors at all. It was only when Claude put some areas into a Floor that I realized they could be used in a way that the name was blocking me from realizing. ↩︎
  3. That sensor comes from a little scoreboard service I run on a Raspberry Pi, which pulls game data from the AHL's feed. Home Assistant reads it like any other device. ↩︎

Putting it All Together

In this final post I'll be writing up how everything fits together. As a recap, here are the steps I go through to create and publish a new post

Create Post

  1. Create .md for my new post
  2. write my words
  3. edit post
  4. Change status from draft to published

Publish Post

  1. Run make html to generate the SQLite database that powers my site's search tool1
  2. Run make vercel to deploy the SQLite database to vercel
  3. Run git add <filename> to add post to be committed to GitHub
  4. Run git commit -m <message> to commit to GitHub
  5. Post to Twitter with a link to my new post

My previous posts have gone over how each step was automated, but now we'll 'throw it all together'.

I updated my Makefile with a new command:

tweet:
    ./tweet.sh

When I run make tweet it will calls tweet.sh. I wrote about the tweet.sh file in Auto Generating the Commit Message so I won't go deeply into here. What it does is automate steps 1 - 5 above for the Publish Post section above.

And that's it really. I've now been able to automate the file creation and publish process.

Admittedly these are the 'easy' parts. The hard part is the actual writing, but it does remove a ton pf potential friction from my workflow and this will hopefully lead to more writing this year.

  1. make vercel actually runs make html so this isn't really a step that I need to do. ↩︎

Automating the file creation

In my last post Auto Generating the Commit Message I indicated that this post I would "throw it all together and to get a spot where I can run one make command that will do all of this for me".

I decided to take a brief detour though as I realized I didn't have a good way to create a new post, i.e. the starting point wasn't automated!

In this post I'm going to go over how I create the start to a new post using Makefile and the command make newpost

My initial idea was to create a new bash script (similar to the tweet.sh file), but as a first iteration I went in a different direction based on this post How to Slugify Strings in Bash.

The command that the is finally arrived at in the post above was

newpost:
    vim +':r templates/post.md' $(BASEDIR)/content/blog/$$(date +%Y-%m-%d)-$$(echo -n $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

which was really close to what I needed. My static site is set up a bit differently and I'm not using vim (I'm using VS Code) to write my words.

The first change I needed to make was to remove the use of vim from the command and instead use touch to create the file

newpost:
    touch $(BASEDIR)/content/blog/$$(date +%Y-%m-%d)-$$(echo -n $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

The second was to change the file path for where to create the file. As I've indicated previously, the structure of my content looks like this:

content
├── musings
├── pages
├── productivity
├── professional\ development
└── technology

giving me an updated version of the command that looks like this:

touch content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

When I run the command make newpost title='Automating the file creation' category='productivity' I get a empty new files created.

Now I just need to populate it with the data.

There are seven bits of meta data that need to be added, but four of them are the same for each post

Author: ryan
Tags:
Series: Remove if Not Needed
Status: draft

That allows me to have the newpost command look like this:

newpost:
    touch content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Author: ryan" >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Tags: " >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Series: Remove if Not Needed"  >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Status: draft"  >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

The remaining metadata to be added are:

  • Title:
  • Date
  • Slug

Of these, Date and Title are the most straightforward.

bash has a command called date that can be formatted in the way I want with %F. Using this I can get the date like this

echo "Date: $$(date +%F)" >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

For Title I can take the input parameter title like this:

echo "Title: $${title}" > content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

Slug is just Title but slugified. Trying to figure out how to do this is how I found the article above.

Using a slightly modified version of the code that generates the file, we get this:

printf "Slug: " >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
echo "$${title}" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

One thing to notice here is that printf. I needed/wanted to echo -n but make didn't seem to like that. This StackOverflow answer helped me to get a fix (using printf) though I'm sure there's a way I can get it to work with echo -n.

Essentially, since this was a first pass, and I'm pretty sure I'm going to end up re-writing this as a shell script I didn't want to spend too much time getting a perfect answer here.

OK, with all of that, here's the entire newpost recipe I'm using now:

newpost:
    touch content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Title: $${title}" > content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Date: $$(date +%F)" >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Author: ryan" >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Tags: " >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    printf "Slug: " >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "$${title}" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Series: Remove if Not Needed"  >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md
    echo "Status: draft"  >> content/$$(echo $${category})/$$(echo $${title} | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z.md).md

This allows me to type make newpost and generate a new file for me to start my new post in!1

  1. When this post was originally published the slug command didn't account for making all of the text lower case. This was fixed in a subsequent commit ↩︎

Auto Generating the Commit Message

In my first post of this series I outlined the steps needed in order for me to post. They are:

  1. Run make html to generate the SQLite database that powers my site's search tool1
  2. Run make vercel to deploy the SQLite database to vercel
  3. Run git add <filename> to add post to be committed to GitHub
  4. Run git commit -m <message> to commit to GitHub
  5. Post to Twitter with a link to my new post

In this post I'll be focusing on how I automated step 4, Run git commit -m <message> to commit to GitHub.

Automating the "git commit ..." part of my workflow

In order for my GitHub Action to auto post to Twitter, my commit message needs to be in the form of "New Post: ...". What I'm looking for is to be able to have the commit message be something like this:

New Post: Great New Post https://ryancheley.com/yyyy/mm/dd/great-new-post/

This is basically just three parts from the markdown file, the Title, the Date, and the Slug.

In order to get those details, I need to review the structure of the markdown file. For Pelican writing in markdown my file is structured like this:

Title:
Date:
Tags:
Slug:
Series:
Authors:
Status:

My words start here and go on for a bit.

In the last post I wrote about how to git add the files in the content directory. Here, I want to take the file that was added to git and get the first 7 rows, i.e. the details from Title to Status.

The file that was updated that needs to be added to git can be identified by running

find content -name '*.md' -print | sed 's/^/"/g' | sed 's/$/"/g' | xargs git add

Running git status now will display which file was added with the last command and you'll see something like this:

❯ git status
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        content/productivity/auto-generating-the-commit-message.md

What I need though is a more easily parsable output. Enter the porcelin flag which, per the docs

Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across Git versions and regardless of user configuration. See below for details.

which is exactly what I needed.

Running git status --porcelain you get this:

❯ git status --porcelain
?? content/productivity/more-writing-automation.md

Now, I just need to get the file path and exclude the status (the ?? above in this case2), which I can by piping in the results and using sed

❯ git status --porcelain | sed s/^...//
content/productivity/more-writing-automation.md

The sed portion says

  • search the output string starting at the beginning of the line (^)
  • find the first three characters (...). 3
  • replace them with nothing (//)

There are a couple of lines here that I need to get the content of for my commit message:

  • Title
  • Slug
  • Date
  • Status4

I can use head to get the first n lines of a file. In this case, I need the first 7 lines of the output from git status --porcelain | sed s/^...//. To do that, I pipe it to head!

git status --porcelain | sed s/^...// | xargs head -7

That command will return this:

Title: Auto Generating the Commit Message
Date: 2022-01-24
Tags: Automation
Slug: auto-generating-the-commit-message
Series: Auto Deploying my Words
Authors: ryan
Status: draft

In order to get the Title, I'll pipe this output to grep to find the line with Title

git status --porcelain | sed s/^...// | xargs head -7 | grep 'Title: '

which will return this

Title: Auto Generating the Commit Message

Now I just need to remove the leading Title: and I've got the title I'm going to need for my Commit message!

git status --porcelain | sed s/^...// | xargs head -7 | grep 'Title: ' | sed -e 's/Title: //g'

which return just

Auto Generating the Commit Message

I do this for each of the parts I need:

  • Title
  • Slug
  • Date
  • Status

Now, this is getting to have a lot of parts, so I'm going to throw it into a bash script file called tweet.sh. The contents of the file look like this:

TITLE=`git status --porcelain | sed s/^...// | xargs head -7 | grep 'Title: ' | sed -e 's/Title: //g'`
SLUG=`git status --porcelain | sed s/^...// | xargs head -7 | grep 'Slug: ' | sed -e 's/Slug: //g'`
POST_DATE=`git status --porcelain | sed s/^...// | xargs head -7 | grep 'Date: ' | sed -e 's/Date: //g' | head -c 10 | grep '-' | sed -e 's/-/\//g'`
POST_STATUS=` git status --porcelain | sed s/^...// | xargs head -7 | grep 'Status: ' | sed -e 's/Status: //g'`

You'll see above that the Date piece is a little more complicated, but it's just doing a find and replace on the - to update them to / for the URL.

Now that I've got all of the pieces I need, it's time to start putting them together

I define a new variable called URL and set it

URL="https://ryancheley.com/$POST_DATE/$SLUG/"

and the commit message

MESSAGE="New Post: $TITLE $URL"

Now, all I need to do is wrap this in an if statement so the command only runs when the STATUS is published

if [ $POST_STATUS = "published" ]
then
    MESSAGE="New Post: $TITLE $URL"

    git commit -m "$MESSAGE"

    git push github main
fi

Putting this all together (including the git add from my previous post) and the tweet.sh file looks like this:

# Add the post to git
find content -name '*.md' -print | sed 's/^/"/g' | sed 's/$/"/g' | xargs git add


# Get the parts needed for the commit message
TITLE=`git status --porcelain | sed s/^...// | xargs head -7 | grep 'Title: ' | sed -e 's/Title: //g'`
SLUG=`git status --porcelain | sed s/^...// | xargs head -7 | grep 'Slug: ' | sed -e 's/Slug: //g'`
POST_DATE=`git status --porcelain | sed s/^...// | xargs head -7 | grep 'Date: ' | sed -e 's/Date: //g' | head -c 10 | grep '-' | sed -e 's/-/\//g'`
POST_STATUS=` git status --porcelain | sed s/^...// | xargs head -7 | grep 'Status: ' | sed -e 's/Status: //g'`

URL="https://ryancheley.com/$POST_DATE/$SLUG/"

if [ $POST_STATUS = "published" ]
then
    MESSAGE="New Post: $TITLE $URL"

    git commit -m "$MESSAGE"

    git push github main
fi

When this script is run it will find an updated or added markdown file (i.e. article) and add it to git. It will then parse the file to get data about the article. If the article is set to published it will commit the file with a message and will push to github. Once at GitHub, the Tweeting action I wrote about will tweet my commit message!

In the next (and last) article, I'm going to throw it all together and to get a spot when I can run one make command that will do all of this for me.

Caveats

The script above works, but if you have multiple articles that you're working on at the same time, it will fail pretty spectacularly. The final version of the script has guards against that and looks like this

  1. make vercel actually runs make html so this isn't really a step that I need to do. ↩︎
  2. Other values could just as easily be M or A ↩︎
  3. Why the first three characters, because that's how porcelain outputs the status ↩︎
  4. I will also need the Status to do some conditional logic otherwise I may have a post that is in draft status that I want to commit and the GitHub Action will run posting a tweet with an article and URL that don't actually exist yet. ↩︎

Figuring out how Drafts REALLY works

On my way back from Arizona a few weeks ago I decided to play around with Drafts a bit. Now I use Drafts every day. When it went to a subscription model more than a year ago it was a no brainer for me. This is a seriously powerful app when you need it.

But since my initial workflows and shortcuts I've not really done too much with it. But after listening to some stuff from Tim Nahumck I decided I needed to invest a little time ... and honestly there's no better time than cruising at 25k feet on your way back from Phoenix.

Ok, first of all I never really understood workspaces. I had some set up but I didn't get it. That was the first place I started.

Each workspace can have its own action and keyboard shortcut thing which I didn't realize. This has so much potential. I can create workspaces for all sorts of things and have the keyboard shortcut things I need when I need them! This alone is mind blowing and I'm disappointed I didn't look into this feature sooner.

I have 4 workspaces set up:

  • OF Templates
  • O3
  • Scrum
  • post ideas

Initially since I didn't really understand the power of the workspace I had them mostly as filtering tools to be used when trying to find a draft. But now with the custom action and keyboards for each workspace I have them set up to filter down to specific tags AND use their own keyboards.

The OF Template workspace is used to create OmniFocus projects based on Taskpaper markup. There are a ton of different actions that I took from Rose Orchard (of Automators fame) that help to either add items with the correct syntax to a Task Paper markdown file OR turn the whole thing into an OmniFocus project. Simply a life saver for when I really know all of the steps that are going to be involved in a project and I want to write them all down!

The O3 workspace is used for processing the notes from the one-on-one I have with my team. There's really only two actions: Parse O3 notes and Add to O3 notes. How are these different? I have a Siri Shortcut that populates a Draft with a template that collects the name of the person and the date time that the O3 occurred. This is the note that is parsed by the first action. The second action is used when someone does something that I want to remember (either good or bad) so that I can bring it up at a more appropriate time (the best time to tell someone about a behavior is right now, but sometimes circumstances prevent that) so I have this little action.

In both cases they append data to a markdown file in Dropbox (i have one file per person that reports to me). The Shortcut also takes any actions that need to be completed and adds them to OmniFocus for me to review later.

The third workspace is Scrum. This workspace has just one action which is "Parse scrum notes". Again, I have a template that is generated from Siri Shortcuts and dropped into Drafts. During the morning standup meetings I have with my team this Draft will have the things I did yesterday, what I'm working on today, and any roadblocks that I have. It also create a section where I can add actions which when the draft is parsed goes into OmniFocus for me to review later (currently the items get added with a due date of today at 1pm ... but I need to revisit that).

The last workspace is post ideas (which is where I'm writing this from). Its custom keyboard is just a markdown one with quick ways to add markdown syntax and a Preview button so I can see what the markdown will render out as.

It's still a work in progress as this draft will end up in Ulysses so it can get posted to my site, but I've seen that I can even post from Drafts to Wordpress so I'm going to give that a shot later on.

There are several other ideas I have bouncing around in my head about ideas for potential workspaces. My only concern at this point is how many workspaces can I have before there are too many to be used effectively.

So glad I had the time on the flight to take a look at workspaces. A huge productivity boost for me!

Creating Hastags for Social Media with a Drafts Action

Creating meaningful, long #hastags can be a pain in the butt.

There you are, writing up a witty tweet or making that perfect caption for your instagram pic and you realize that you have a fantastic idea for a hash tag that is more of a sentence than a single word.

You proceed to write it out and unleash your masterpiece to the world and just as you hit the submit button you notice that you have a typo, or the wrong spelling of a word and #ohcrap you need to delete and retweet!

That lead me to write a Drafts Action to take care of that.

I’ll leave others to write about the virtues of Drafts, but it’s fantastic.

The Action I created has two steps: (1) to run some JavaScript and (2) to copy the contents of the draft to the Clipboard. You can get my action here.

Here’s the JavaScript that I used to take a big long sentence and turn it into a social media worthy hashtag

var contents = draft.content;
var newContents = "#";


editor.setText(newContents+contents.replace(/ /g, "").toLowerCase());

Super simple, but holy crap does it help!

Receipts

Every month I set up a budget for my family so that we can track our spending and save money in the ways that we need to while still being able to enjoy life.

I have a couple of Siri Shortcuts that will take a picture and then put that picture into a folder in Dropbox. The reason that I have a couple of them is that one is for physical receipts that we got at a store and the other is for online purchases. I’m sure that these couple be combined into one, but I haven’t done that yet.

One of the great things about these shortcuts is that they will create the folder that the image will go into if it’s not there. For example, the first receipt of March 2019 will create a folder called March in the 2019 folder. If the 2019 folder wasn’t there, it would have created it too.

What it doesn’t do is create the sub folder that all of my processed receipts will go into. Each month I need to create a folder called month_name Processed. And each month I think, there must be a way I can automate this, but because it doesn’t really take that long I’ve never really done it.

Over the weekend I finally had the time to try and write it up and test it out. Nothing too fancy, but it does what I want it to do, and a little more.

# create the variables I'm going to need later

y=$( date +"%Y" )
m=$( date +"%B" )
p=$( date +"%B_Processed" )

# check to see if the Year folder exists and if it doesn't, create it
if [ ! -d /Users/ryan/Dropbox/Family/Financials/$y ]; then
    mkdir /Users/ryan/Dropbox/Family/Financials/$y
fi

# check to see if the Month folder exists and if it doesn't, create it
if [ ! -d /Users/ryan/Dropbox/Family/Financials/$y/$m ]; then
    mkdir /Users/ryan/Dropbox/Family/Financials/$y/$m
fi

#check to see if the Month_Processed folder exists and if it doesn't, create it
if [ ! -d "/Users/ryan/Dropbox/Family/Financials/$y/$m/$p" ]; then
    mkdir "/Users/ryan/Dropbox/Family/Financials/$y/$m/$p"
fi

The last section I use the double quotes “” around the directory name so that I can have a space in the name of the processed folder. Initially I had used an underscore but that’s not how I do it in real life when creating the sub directors, so I had to do a bit of googling and found a helpful resource.

The only thing left to do at this point is get it set up to run automatically so I don’t have to do anything.

In order to do that I needed to add the following to my cronjob:

0 5 1 * * /Users/ryan/Documents/scripts/create_monthly_expense_folders.sh

And now I will have my folder structure created for me automatically on the first of the month at 5am!

Monitoring the temperature of my Raspberry Pi Camera

In late April of this year I wrote a script that would capture the temperature of the Raspberry Pi that sits above my Hummingbird feeder and log it to a file.

It’s a straight forward enough script that captures the date, time and temperature as given by the internal measure_temp function. In code it looks like this:

MyDate="`date +'%m/%d/%Y, %H:%M, '`"
MyTemp="`/opt/vc/bin/vcgencmd measure_temp |tr -d "=temp'C"`"
echo "$MyDate$MyTemp" >> /home/pi/Documents/python_projects/temperature/temp.log

I haven’t ever really done anything with the file, but one thing I wanted to do was to get alerted if (when) the temperature exceeded the recommended level of 70 C.

To do this I installed ssmtp onto my Pi using apt-get

sudo apt-get install ssmtp

With that installed I am able to send an email using the following command:

echo "This is the email body" | mail -s "This is the subject" user@domain.tld

With this tool in place I was able to attempt to send an alert if (when) the Pi’s temperature got above 70 C (the maximum recommended running temp).

At first, I tried adding this code:

if [ "$MyTemp" -gt "70" ]; then
   echo "Camera Pi Running Hot" | mail -s "Warning! The Camera Pi is Running Hot!!!" user@domain.tld
fi

Where the $MyTemp came from the above code that gets logged to the temp.log file.

It didn’t work. The problem is that the temperature I’m capturing for logging purposes is a float, while the item it was being compared to was an integer. No problem, I’ll just make the “70” into a “70.0” and that will fix the ... oh wait. That didn’t work either.

OK. I tried various combinations, trying to see what would work and finally determined that there is a way to get the temperature as an integer, but it meant using a different method to capture it. This is done by adding this line:

ComparisonTemp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))

The code above gets the temperature as an integer. I then use that in my if statement for checking the temperature:

if [ "$ComparisonTemp" -gt "70" ]; then
   echo "Camera Pi Running Hot" | mail -s "Warning! The Camera Pi is Running Hot!!!" user@domain.tld
fi

Giving a final script that looks like this:

MyDate="`date +'%m/%d/%Y, %H:%M, '`"
MyTemp="`/opt/vc/bin/vcgencmd measure_temp |tr -d "=temp'C"`"
echo "$MyDate$MyTemp" >> /home/pi/Documents/python_projects/temperature/temp.log
ComparisonTemp=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000))

if [ "$ComparisonTemp" -gt "70" ]; then
   echo "Camera Pi Running Hot" | mail -s "Warning! The Camera Pi is Running Hot!!!" user@domain.tld
fi

Using Drafts 5 at Work

I have many meetings that I go to in any given day. One of the things that I’d been struggling with was being able to keep track of what I needed to do after a meeting and/or documenting certain types of meetings more effectively.

I have been using a Workflow I created a couple of years ago to get the pertinent details of a meeting into Drafts. I spoke about updating that workflow to incorporate drafts 5 here.

Once I was able to get the information into Drafts 5 a new opportunity arose. I was able to run a Workflow in Drafts!

I decided that getting the information into Drafts was great, but I needed a good way to get it out.

There were two sections in the Draft that I decided I could leverage to help:

  1. Actions
  2. Notes

Broadly speaking there are 3 types of meetings I go to:

  1. Daily Standup aka Scrum
  2. One-on-One with direct reports or my manager
  3. General Meetings

Categorizing the meetings helped me to create Draft Actions that run Workflows for each meeting type.

Scrum

This workflow runs through the Actions of the Draft and adds each one to OmniFocus in a Project called Scrum with a Tag of Work. The due date set for these tasks is noon of the same day. My goal is to have the items that come from Scrum totally processed by noon of that day and for 80% of them I can. Some actions are more involved, but having them in OmniFocus helps me to make sure that they get taken care of.

It also creates a calendar meeting for the next business day with my Scrum template and lets me know which team member will start that next day.

One-on-One

This workflow runs similarly to the Scrum workflow. It adds the Action items to OmniFocus with a due date of noon the same day, tagged with Work and in the One-on-One Project.

Instead of creating a calendar meeting for the next business day at 8:30 it appends items from the Notes section to a Dropbox file. The Dropbox path is predefined, but the name of the file matches the name of the person I met with (luckily I don’t have 2 Tom’s reporting to me).

General Meetings

This is the simplest workflow. It adds all of the items under actions to OmniFocus with a due date of noon, project of Meeting Follow Up and Tag of Work.

After the Actions are run from Drafts the notes are archived in Drafts.

I’m toying with the idea of archiving the notes from these meetings into Dropbox, but I’m not sure that it gets me anything ... so I haven’t really looked at it too deeply.

The links for each of the workflows can be found here:

Parse Scrum Notes

Parse One-on-One Notes

Parse Meeting Notes

Using Drafts 5 at Work

I have many meetings that I go to in any given day. One of the things that I’d been struggling with was being able to keep track of what I needed to do after a meeting and/or documenting certain types of meetings more effectively.

I have been using a Workflow I created a couple of years ago to get the pertinent details of a meeting into Drafts. I spoke about updating that workflow to incorporate drafts 5 here.

Once I was able to get the information into Drafts 5 a new opportunity arose. I was able to run a Workflow in Drafts!

I decided that getting the information into Drafts was great, but I needed a good way to get it out.

There were two sections in the Draft that I decided I could leverage to help:

  1. Actions
  2. Notes

Broadly speaking there are 3 types of meetings I go to:

  1. Daily Standup aka Scrum
  2. One-on-One with direct reports or my manager
  3. General Meetings

Categorizing the meetings helped me to create Draft Actions that run Workflows for each meeting type.

Scrum

This workflow runs through the Actions of the Draft and adds each one to OmniFocus in a Project called Scrum with a Tag of Work. The due date set for these tasks is noon of the same day. My goal is to have the items that come from Scrum totally processed by noon of that day and for 80% of them I can. Some actions are more involved, but having them in OmniFocus helps me to make sure that they get taken care of.

It also creates a calendar meeting for the next business day with my Scrum template and lets me know which team member will start that next day.

One-on-One

This workflow runs similarly to the Scrum workflow. It adds the Action items to OmniFocus with a due date of noon the same day, tagged with Work and in the One-on-One Project.

Instead of creating a calendar meeting for the next business day at 8:30 it appends items from the Notes section to a Dropbox file. The Dropbox path is predefined, but the name of the file matches the name of the person I met with (luckily I don’t have 2 Tom’s reporting to me).

General Meetings

This is the simplest workflow. It adds all of the items under actions to OmniFocus with a due date of noon, project of Meeting Follow Up and Tag of Work.

After the Actions are run from Drafts the notes are archived in Drafts.

I’m toying with the idea of archiving the notes from these meetings into Dropbox, but I’m not sure that it gets me anything ... so I haven’t really looked at it too deeply.

The links for each of the workflows can be found here:

Parse Scrum Notes

Parse One-on-One Notes

Parse Meeting Notes


Page 1 / 2