Home Automation – SentryPi

Who left the garage door open?

We have a full house with a lot of activity and visitors.  There have been several times when the garage door is left open for extended periods of time.  While our Christmas decorations and paint supplies may not be a treasure most would be thieves would desire, it is still not the most comforting thing to think about leaving the garage open for all passerby to see.  I often thought it would be great to have a way to notify whoever is in the house that the garage is open.

Phase 1 – LED Indicator

I decided that my first step would be to design a way to detect “door open” by providing a simple indicator light.  I explored a few optical ways to do this (light beam, camera, reflectors) but quickly pivoted my approach when I found some unused microswitches.

I found a good place to detect “closed” on the main track.  I thought about piggybacking on the garage opener sensors but dismissed that as I didn’t want to risk an undesirable interaction with the opener and more importantly, I wanted to have the detection work even if power to the opener was interrupted.

This required that I build a bracket to mount the switch to and a ramp plate to compress the switch when the door was in the down position.

I used an aluminum sheet, cut with sheet metal snips,  bent and drilled holes to mount the microswitch and eventually attach it to the garage door track.  It took a few tries to get the right fit and right placement of the micro switch.

My first attempt destroyed the microswitch after a few uses.  The garage door track sled has a straight edge that collides with the microswitch roller. It created too much force on the small roller and eventually popped it loose.  To help with that, I added an aluminum ramp to the sled so that the microswitch roller would gently rise as the sled entered the “closed” position.

I decided to make the “door open” state be the closed circuit condition so that phase 1 of the project could start as a simple LED circuit indicator.

I attached the switch and drilled some pilot holes and mounted the bracket to the garage door track right above the sled when the door is in the closed position.

I added a 9V battery, a 470 ohm resister and a red LED to the circuit.  To complete this phase, I ran the wire from the garage to our entry hall and mounted an LED and housing above the HVAC controls.  Now we can all see the brilliant red LED glowing when the garage door is open.  That covers some of our use cases but I also want a more proactive notification.  Now on to phase 2…

Phase 2 – Raspberry Pi – Home Automation Sentry

Now that I have a working “door closed” sensor and indicator, I am ready to add the proactive home automation component, specifically the Raspberry Pi (RPI).  It just so happens that I have a spare RPI Model 3 that needed a project, and I wanted to experiment with AWS IoT services.

Raspberry Pi 3 B

I used the RPI to detect the state of the switch. To do that, I will need to wire the circuit into the RPI’sGPIO headers.  I decided to use GPIO Pin 23 and the adjacent ground (GND) pin.

Here is the code that is used to detect the closed circuit (indicating an open door):

#!/usr/bin/python

##  
## Garage Door Sentry - RPI script to monitor door
##  

## load libraries
import RPi.GPIO as io 
import time 

print "Garage Door Sentry\n\n"

## set GPIO mode to BCM - allows us to use GPIO number instead of pin number
io.setmode(io.BCM)

## set GPIO pin to use

door_pin = 23
print "Sentry Activated - Watching: GPIO 23"

## use the built-in "pull-up" resistor
io.setup(door_pin, io.IN, pull_up_down=io.PUD_UP)  # activate input

## States for door: 0=closed, 1=open, 2=init
door=2
## infinite loop
while True:
    ## if switch is open
    if (io.input(door_pin)==True and door!=0):
        door=0 
        print "Door closed"
        # do some action
    ## if switch is closed 
    if (io.input(door_pin)==False and door!=1):
        door=1 
        print "Door open"
        # do some action
    time.sleep(1) # 1 second wait

The next step was to connect to AWS IoT to record this sensor data and send alert messages to my phone.

The following will help you set up your Raspbery Pi as a platform to install the SentryPi scripts.

Required:

  • Raspberry Pi – B+, 2 or 3
  • Wifi Dongle or Network Cable configured
  • SD card (Recommend: 16GB or larger)
  • AWS Account (IoT, DynamoDB)

Read the details on this GitHub Project: https://github.com/jasonacox/SentryPi

The project describes how I added these additional features:

  • Sentry Alert – Send a text message to contacts when an alert condition is reached.
  • Dashboard – Provide an automation dashboard for realtime status.
  • Other Sensor Data:
    • Temperature Sensors
    • Barometric Pressure Sensor
    • Humidity Sensor
    • Motion Sensor

To set up a web based dashboard, I decide to use static HTML, CSS and JS (jQuery, Chart.js and the AWS JavaScript SDK) so it can be hosted on a simple S3 bucket, a web server, or the RPi itself.  See here for the code. 
SentryPi Dashboard
SentryPi Dashboard - Garage Door Graph

DevOps Enterprise Summit – London 2017

#DOES17

I had the privilege of attending and speaking again at this years DevOps Enterprise Summit in London at Queen Elizabeth II Centre across the street from Westminster Abby and Big Ben. The conference was attended by nearly 700 transformative leaders from companies and organization across the UK and the rest of Europe:  Hiscox, ITV, Barclays, Hearst, Jaguar Land Rover, Lloyds Banking Group, Orange, Northrop Grumman, easyJet, Capital One, UK Ministry of Justice, ING, Swisscom, Lockheed Martin and more.

The speakers’ slide decks and videos of their talks are available now!

Great talk by Chris Hill (Jaguar Land Rover) and a great quote…

I love this quote from Suzette Johnson (Northrop Grumman) – an example of a good leader empowering the team:

Jonathan Smart (Barclays) had several great points, including this courageous quote on challenges along the journey:

I love this quote from Jonathan Fletcher’s (Hiscox) talk:

Creating Digital Magic

I was honored to speak again and talk about our DevOps journey at Disney.

Even though I wasn’t able to record my presentation, TheNewStack provided a great write-up of my talk: https://thenewstack.io/magic-behind-disney-devops-experience/

Ask the Speakers

Great “Ask the Speakers” session with my new friends Jonathan Smart (Barclays) and Andrea Hirzle-Yager (Allianz Deutchland AG):

And…

The best part of this years trip to London?  Yes, an amazing journey through time and space with my sweetie…

A Seat at the Table: IT Leadership in the Age of Agility

Book Review

A Seat at the Table: IT Leadership in the Age of Agility
by Mark Schwartz

This should be required reading for all technology and business leaders who are serious about digital transformation.  This book takes you on a provocative, fun and comprehensive tour of the key areas that will promote and ignite digital empowering agility, creativity, learning, community and collaboration.

This book may be about taking a seat, but this is no time to be sitting still!   IT leaders will be convinced that their job is now about incentivizing and inspiring courage, passion and technical excellence in service of business objectives rather than blindly servicing requirements. You will even find practical advice on how to deal with projects, scope creep, IT assets (what the author calls Enterprise Architecture), governance, security, risk management, quality, and shadow IT.

DevOps Enterprise Summit 2016 – San Francisco

The 2016 edition of the San Francisco based DevOps Enterprise Summit underscored the momentum and scale of the DevOps movement across the industry.  The summit saw record level attendance and phenomenal presentations from established DevOps luminaries, notable DevOps transformational companies as well as many new companies.

“We are at our best when we are helping each other, serving each other, and making a positive difference” – Jason Cox, Disney

Articles related to DOES 16:

Chef at DevOps Enterprise Summit 2016

DevOps Chat: Gene Kim on The DevOps Handbook and DevOps Enterprise Summit

Innovation at Dimension Data: Taking DevOps Beyond Deployment

Innovation at Dimension Data: Accelerating Innovation and Digital Transformation with StackStorm Event Driven Automation

 

 

 

 

 

 

Thinking Environments

Transformational technology leaders from many companies across the world assembled at the 2016 DevOps Enterprise Forum to discuss DevOps practices, challenges and best-known methods to help our organizations and our community succeed.

Along with several other leaders, I had the privilege of helping put together a guidance document on DevOps Organizational Models to accelerate business and empower workers. In this free publication by IT Revolution, we take a look at how and why organizations are structured, examine which have characteristics that promote or impede business enabling DevOps practices, and take a deep dive into four different models that began to surface during our research:  (1) the traditional functional silo hierarchy, (2) the matrix model, (3) the product platform model and the (X) adaptive organization model.

Download PDF Here

Authors

  • Mark Schwartz, CIO, US Citizenship and Immigration Services
  • Jason Cox, Director, Systems Engineering, The Walt Disney Company
  • Jonathan Snyder, Sr. Manager, Service Deployment & Quality, Adobe Systems
  • Mark Rendell, Principal Director, Accenture
  • Chivas Nambiar, Director Systems Engineering, Verizon
  • Mustafa Kapadia, NA DevOps Service Line Leader, IBM

More DevOps guidance documents can be found here: http://itrevolution.com/devops_enterprise_forum_guidance

DevOps Handbook

devopshandbookDevOps Handbook: 
How to Create World-Class Agility, Reliability, & Security in Technology Organizations

These notable DevOps luminaries provide a comprehensive definition, patterns and guidance on implementing business winning DevOps culture and practices within your your organization.  Beyond just looking at successful DevOps principles from “unicorn” companies like Google, Amazon, Facebook, Etsy, and Netflix, the authors provide several practical examples and case studies where these same practices are helping traditional enterprise companies like Target, Nordstrom, Raytheon, Nationwide Insurance, CSG, Capital One, and Disney.

The handbook captures several quotes from industry practitioners as well as unpack patterns that help promote increased velocity, feedback and experimentation and learning.

Citations from The DevOps Handbook

wordcloud-devops-handbook

DevOps Enterprise Summit – London 2016

I once again had the privilege of attending the DevOps Enterprise Summit.  This time it was in the U.K. at the Hilton Metropole.  I was impressed with the representation and talks from companies and organization across the UK and the rest of Europe:  SAP, ITV, Hiscox, ING, Barclays, HMRC, Zurich, and many more.

Themes that I picked up from these DevOps leaders:

  • People – Its all about People – empathy, org change, transformation
  • Speed – Continuous Integration and Delivery
  • Quality – Investment in DevOps practices often results in higher quality output
  • Agility – Microservices and Flexible Infrastructure
  • Security – Everyone’s responsibility
  • Business – Focus on Product vs. Project with integration with business in transformation (BizDevOps?)

I was honored to speak again and talk about our DevOps journey at Disney.

Jason Cox DOES16 London

Even though I wasn’t able to record my presentation, ComputerWorld UK provided a great write-up of my talk, and even gave me a new title! 🙂

There was considerable interest in our journey to DevOps, especially our transition from Operation Specialist to embedded Systems Engineers.

Other Quotes

“If technology is done well it looks like magic”

References

Systems strategy chief Jason Cox details Disney’s devops journey – ComputerWorld UK

Tips for DevOps Success from DOES 2016 – ComputerWorld UK

DevOps Across the Pond – London Reprise – ITproPortal

Overcoming the scale-up challenge of enterprise DevOps adoption – ComputerWeekly.com

 

How to Effectively Communicate to Leaders

As an leader who loves working with people, I often have the pleasure of hearing from individuals at all levels across the organization.  However, I am often amazed at how many people fail to communicate effectively with their leaders and others. They are terrible at scheduling meetings, pitching their idea or even asking for help. That got me to thinking, what advice would I give to anyone who needs to communicate with me or other leaders? I came up a list of 7 imperatives that I have learned from those who are the most successful.

1) Be contextual – I often have meeting invites or receive emails or presentations that provide little or no context. The senders may have mentioned it in a prior exchange and are usually saturated in the subject themselves, but most leaders are constantly task switching and juggling multiple ideas, projects, discussions, etc., and can struggle to make connections back to the senders requests. While we all want to be superhuman and always “know what you are talking bout”, the truth is that we have a finite capacity to retain more than a handful of contexts. Provide “helps” to onboard the leader and the rest of the audience quickly. That will help you succeed in getting the point across and if needed, a decision. I love seeing context in the meeting invite or email, or in the case of ad hoc meetings, and introductory summary for why he or she should listen to you.

2) Be brief – As with most leaders, I get several hundred emails, calls, texts and IMs per day. I must skim to survive. You should fashion your communications so that important ideas are highlighted. For written communication, make use of white space to help the eye quickly skim and do what you can to avoid unnecessary language. Can I suggest that executives aren’t the only ones who appreciate this and anyone who discovers this art of concise and effective communication will succeed in their career?

3) Be real – Leaders see through bogus accomplishments and self promotion. I’m most impressed with people who are respectful but direct, confident but humble, and candid but optimistic. They spend more time acknowledging others and the achievements of their team rather than their own.

4) Be kind – Good leaders have little tolerance for other leaders or managers who berate, belittle, or otherwise deal harshly with their team or others. Don’t expect to find a gracious audience with your own leader if you can’t deal respectfully, courteously and graciously with your own staff and partners. Treat others as you want to be treated.

5) Be honest – I’ve seen individuals and teams manipulate messages and presentations to get an executive decision or modify perception without providing all the details or slightly modifying the story. If you know something that could materially impact the decision process, why are you hiding it? Blocking signals to manipulate circumstances for your own benefit will backfire on you personally and in some cases have a significant impact on the company, brand, employees or customers. Be honest.

6) Be optimistic – Good leaders are not looking for everyone to be Pollyanna and will prefer a difficult truth to a comforting lie, but rarely are things without hope or some positive element. Bring a bias toward positive solutions, look for the opportunity in the disappointment, the lesson in a setback or wisdom in a failure. Business is about taking risks and moving forward from mistakes. Surround yourself with others who believe we can make a difference and impact the world for the better. Be an optimist.

7) Be proactive – Don’t just tell your leader what someone else needs to do, take action yourself. It’s great to have a plan to make something better and to bring that to the attention of your leader, but be prepared to be part of the solution!  Leaders are always on the lookout for a great idea with muscle. What are you doing to turn your great idea into reality? Get started.

This list is in no way comprehensive, but hopefully it will help you as it has helped me.

The Art of Business Value

art-of-biz-valueA review of The Art of Business Value by Mark Schwartz

Business value, the north star of Agile, Lean and DevOps champions, is often more difficult to determine than one would imagine. This book takes the reader on a journey to discover that value while along the way, creating helpful mental models, challenging preconceived notions and proposing some creative ways to transform an organization.

The author does a great treatment of ROI (Return on Investment – does anyone ever really measure that?), NPV (Net Present Value), MVA (Market Value Added) and SVA (Shareholder Value Added). I especially enjoyed the humorous practical example that revealed a surprising truth that acquiring an MBA can easily have a negative NPV (in other words, a bad investment!) So save your money and pay attention to the author’s “four-paragraph MBA” (p. 20) that unpacks the main two principles learned in an MBA: 1) There is time value of money and 2) A business venture needs a sustainable competitive advantage.

Legacy IT architecture and bureaucracy are often considered negatives and obstacles to progressive competitive relevance but the author brings a refreshing perspective on the “value” of that complex hairball of legacy and rules and the right way to polish and transform them.

On Agile…

“The purpose of an Agile team is to self-organize and meet the underlying business need in the best way possible, often by cutting through the bureaucracy.” (p 55)

On DevOps…

“The DevOps model…looks to break down the silos that have resulted from technical specialization over the last few decades. But the DevOps spirit goes further looking to eliminate the conflicting incentives of organizational silos and the inhumane behaviors that can result from those conflicting incentives.” (p 48)

On Bureaucracy…

“Bureaucracy delivers business value. Just sometimes not enough.” (p 59)
…”developers are bureaucrats by nature. We have a tendency to solve problems by creating standard processes rather than by relying on human judgment.” (p 54)
“The pipeline is an automated bureaucracy: it applies its rules in a rigorous, unemotional way, sine ira et studio. That does not mean that the software development process is unemotional; it means that the tools are unemotional and the passion is brought to the process by the people.” (p 105)

And on Business Value…

“Business value is a hypothesis held by the organization’s leadership as to what will best accomplish the organization’s ultimate goals or desired outcomes.” (p 90)

I highly recommend this book to IT leaders, digital executives, strategic managers, and anyone seeking to make their organization more agile, effective, relevant, competitive and humane.

Docker + Mesos + Marathon in AWS EC2

I wanted to see if I could get a Docker + Mesos + Marathon platform up and running quickly in AWS EC2 using t2.micro instances.  I found this great article by Gar (@gargar454) where he has put all the components in docker containers and provides a simple  tutorial which I paste below with some minor edits:

Create a Docker Host on EC2

Create your EC2 instances (Amazon AMI t2.micro will work), set it up in your private VPC and auto-assign a public IP so you can test.  You will need to open TCP ports 5050 and 8080 in  your security group from your workstation if you want to see the Mesos and Marathon UIs.   Run these commands to set up a docker host:

sudo yum update -y
sudo yum install -y docker
sudo service docker start
# grant ec2-user ability to run docker commands without sudo
sudo usermod -a -G docker ec2-user
# you must exist to refresh user rights
exit
  1. Export out the local host’s IP
    • HOST_IP=`wget -qO- http://instance-data/latest/meta-data/local-ipv4`
  2. Start Zookeeper
    docker run -d \
    -p 2181:2181 \
    -p 2888:2888 \
    -p 3888:3888 \
    garland/zookeeper
  3. Start Mesos Master
    docker run --net="host" \
    -p 5050:5050 \
    -e "MESOS_HOSTNAME=${HOST_IP}" \
    -e "MESOS_IP=${HOST_IP}" \
    -e "MESOS_ZK=zk://${HOST_IP}:2181/mesos" \
    -e "MESOS_PORT=5050" \
    -e "MESOS_LOG_DIR=/var/log/mesos" \
    -e "MESOS_QUORUM=1" \
    -e "MESOS_REGISTRY=in_memory" \
    -e "MESOS_WORK_DIR=/var/lib/mesos" \
    -d \
    garland/mesosphere-docker-mesos-master
  4. Start Marathon
    docker run \
    -d \
    -p 8080:8080 \
    garland/mesosphere-docker-marathon --master zk://${HOST_IP}:2181/mesos --zk zk://${HOST_IP}:2181/marathon
  5. Start Mesos Slave in a container
    docker run -d \
    --name mesos_slave_1 \
    --entrypoint="mesos-slave" \
    -e "MESOS_MASTER=zk://${HOST_IP}:2181/mesos" \
    -e "MESOS_LOG_DIR=/var/log/mesos" \
    -e "MESOS_LOGGING_LEVEL=INFO" \
    garland/mesosphere-docker-mesos-master:latest
  6. Goto the Mesos & Marathon Web pages
    # You can find your EC2 instance public IP address with:
    wget -qO- http://instance-data/latest/meta-data/public-ipv4

    Mesos Web Page

  7. http://<public-ip>:5050

Marathon Web Page

http://<public-ip>:8080

Create an App (+ New App button) on the Marathon page to see the task get assigned to a Mesos slave and executed.

Marathon New App - test1

Log in to the slave container and watch the file grow:

docker exec -it mesos_slave_1 /bin/bash

tail -f /tmp/running.out