Puppy Gate

So I have a 13 month old English Mastiff (@hafthor_mastiff) and when I’m not home he gets a bit of separation anxiety and has to destroy something! So I’ve blocked him off in a certain area where he supposedly can’t do too much harm. However, he finds a way to get past my defenses 🙂

I purchased a couple of baby gates. One is a bit shorter than the other, so I’ve had to add extra protection for that, however, I just got a newer taller gate to replace it with. That said he still can put his front paws on the gate and then using leverage jump over… so I thought maybe I’d put little 3D printed “spikes” on top of the gate to deter him from jumping over the gates.

We were recently playing catch and he broke the gate, so I’m also planning on making a re-enforcing part for that section of the gate.

Starting my project. First off I want to work on re-enforcing the gate, since he broke that section where it latches and he would only have to nudge the door to open it now. I took a photo <soon to go here> and I’m going to bring that into Fusion 360, so I have a shape to work with. I then measure with my digital calipers the width and height of the section, which I can then use in fusion to size things up appropriately.

Azure Functions and Logic Apps

I wanted to create a simple Azure Function to make an HTTP GET Request to my website, which is hosted on the cheapest GoDaddy subscription. This subscription is on shared hosting and I don’t have much control over it. The initial load time of the WordPress site is CRAZY slow… in the ~22 second range! After the initial load time I’m seeing anywhere from 5-9 seconds load time. So I thought I’d create a keepalive function to make a HTTP GET Request once every 4 minutes, since the app pool shuts down after 5 minutes of inactivity. At first I created a SUPER simple Python script to do this, and it worked well….. Until it didn’t. I wasn’t home for a couple of days and it stopped working. I was running it on a RPi at home. However, I didn’t have any kind of VPN setup, so I could login remotely to see what the issue was. I thought, heck, I’ll create a super quick Azure Function based on a timer to ping the site instead. That way I can see if there are issues online anywhere I have internet access and potentially fix the issue also.

I did that and it worked well. However, I started to notice some issues… The interval not kicking off every 4 mins like I set it up to do, and some communication service errors. The communication service error I attribute to potentially the sight being down at GoDaddy for maintenance or something similar. The not kicking off every four minutes??? I’m not sure what that issue might be attributed too, minus, maybe Azure maintenance?

I decided to replace all of this with a Azure Logic App. I started looking at an Azure Logic App, since I could easily create a workflow, that I could maintain. For example, I make the request every four minutes, if for some reason, I get a HTTP status code greater than or equal to 300 I can send myself a text message. In addition, it is really easy to hook it up to log to Azure Table Storage. Well there was a bit of trial and error to set it up, but I was able to figure it out in about 10 mins or so….

To insert into table storage the designer wants you to create valid json. The key for me was figuring out how to insert a GUID for the RowKey. See the syntax below:

{
"Body": "Body goes here",
"Headers": "@{outputs('HTTP')['headers']}",
"PartitionKey": "fsnKeepAlive",
"RowKey": "@{guid()}",
"StatusCode": "@outputs('HTTP')['statusCode']"
}

The @outputs sections were automatically created for me using the GUID, but I had to figure out that there was a guid function available in this context and the correct syntax.

In summary, the Azure Function gives a lot of control, but requires a but of coding. The Azure Logic App doesn’t require much “coding” AND provides a lot of features though the extensive list of integrations.

Turning a python script into a service

So now that I have my build lights I want the python script that controls the lights to be setup to run as soon as the RPi is turned on. So I needed to find a way to setup the python script as a service. I found a REALLY good blog post by Stephen Phillips on how to do this pretty easily.

It worked great! I only noticed one issue that I still need to investigate. If I stop the service the GPIO channels are not closed properly, so the lights will stay on.

Here are some things I’d like to do next:

  • I need to incorporate the code for the TeamCity Provider, so it will query a TeamCity build server (instead of the current test code).
  • Since, I don’t have a TeamCity build server currently I’ll need to make a synthetic or stub service that provides sample output from a TeamCity Build box.
  • Then I would like to build out other providers beyond TeamCity, so it could work with CC.NET or VSTS continuous build servers.
  • Once I create those, create a Python Service Locator, so based on configuration it will choose the correct provider.

Here’s my story…

I’m a Pacific Northwest native. I grew up in the greater Portland metro area and currently reside in Vernonia, Oregon.

I’ve always had a passion for computers. When I was in the 2nd grade my father purchased the “Trash 80” (i.e. TRS-80 or Tandy Radio Shack 80 personal computer). I remember getting magazines with pages and pages of code. I would spend hours typing in that code into the computer and was AMAZED with the results. I was HOOKED!

For the past 19 years I’ve worked in software engineering. I continue to learn and evolve my craft. Taking online training classes from Pluralsight to building a home security system using a RPi. I enjoy programming at home and work.

I try to find a balance by playing tennis and doing home improvement projects around the house.

I’m a father of four and between them, projects, and work they keep me busy.