About Ron Lisle

http://lisles.net

Posts by Ron Lisle:

Like a Scene from The Big Bang

Ron and his desk lampOk, I feel extremely nerdy. Did you see the episode of The Big Bang where they program an IoT device to turn on a lamp by sending a signal all around the world before it gets back to the lamp to turn it on? Well, I was suddenly struck by the similarity when I got Alexa to turn on the Z-Wave light bulb in my desk lamp last night:

  • “Alexa, turn on desk lamp”
  • The voice command is picked up by the Alexa Show device on my desk and sent to Amazon cloud.
  • Alexa Smart Home converts the audio command to a “turn on desk lamp” intent and routes it to my Alexa Smart Home skill running in an Amazon Lambda in the cloud.
  • My Smart Home skill converts the intent and forwards a “turn on desk lamp” command to Particle.io.
  • Particle.io publishes the command to my Photon IoT controllers, one of which is acting as a bridge from particle.io to MQTT.
  • The Photon bridge reformats the command and publishes it to MQTT.
  • The MQTT broker is running on a Mac Mini, which then forwards it to all other devices subscribing to MQTT.
  • One of these MQTT subscribers is the smartthings-mqtt-bridge app running on the Mac Mini. It then receives the MQTT “turn on desk lamp” command, and forwards it to the Smartthings web hook over the internet.
  • (Should I mention the Wifi to router to … Nah).
  • The Smartthings server receives the command via web hook, routes it through a Groovy program running in Smartthings, and forwards the command to my Smartthings hub over the internet (and router to wifi, etc).
  • My Smartthings hub then transmits the “turn on” command over Z-Wave radio to my desk lamp light bulb.
  • And the light turns on.

Woohoo!

Patriot 4: Swift Programming IoT Home Automation

I’ve turned a corner in my thinking about how best to automate my home. For years now I’ve been trying to integrate and generalize all of the various technologies (MQTT, SmartThings, Particle.io, Alexa, iOS, Raspberry Pi, etc) to provide a simplified interface for controlling everything. The tough part is really describing what I want the system to do; how it behaves. Using an any sort of text or table driven, simplified, abstract programming model always comes up short. By this I mean the sort of approach where I am allowed to specify things such as “if device A is on, and the time is after HH:MM PM, then set device B to XX”. This works great for doing fairly simple things, but doesn’t really handle the more complex types of scenarios I always run into, or if it does handle it, it does so in a manner that gets very complicated and unmaintainable very quickly. As a professional programmer, this situation is very familiar, and describes what happens with poorly written code. So I started thinking about how to solve this problem in a way that would be greatly extensible and very maintainable.

And I got to thinking about how Patriot automatically detects new devices. Well, sort of automatic. If I program a Photon to expose a device, and write the Photon code to implement that device, then Alexa can detect it and control it with voice. That’s very cool, but I’m getting tired of having to tell Alexa which lights to turn on and off every morning and night. I want my home automation system to know when to do that based on the plethora of sensors that I’ve installed.

So then the big ah-ha moment for me. Automatically detecting and installing devices doesn’t provide any automation until I write some sort of specific code to control it. This could be generalized code such as IFTTT, or bare bones custom code like Photon C++ or Python code on a Raspberry Pi.

One of the issues that frustrates me is the large number of different programming languages and platforms I’ve had to work with. So recently I decided to replace my Raspberry Pi with a used Mac Mini in order to reduce the number of different programming languages, environments, and platforms I have to remember and work with. The 2010 Mac Mini is quite powerful and flexible, and I found one on craigslist for $150. It’s now my media center as well as my MQTT broker and home automation controller. And I can program it in Swift, which is my daytime job programming language.

So if I have to write code no matter what, why not do it using the best tools, environment, and clean programming practices? To my mind that means Swift programming on the Mac Mini.

So that’s where I’m going with Patriot 4. I’m writing a Mac app in Swift using clean, TDD code. I’ll be sharing the Swift framework that is evolving out of this, but it’s going to require Swift programming skills in order to use it. I’m excited to see just how far this can go.

Final day on Safari at Masai Mara, Kenya

Monday morning we had time to venture out for one last time before beginning our flight back to the U.S. in the afternoon.

We still had not spotted any Rhinoceroses, so that was our primary objective.

As we were leaving, we passed the Balloons getting ready to take off.

 And so we got one final group picture as we’re getting ready to hop into the trucks to head back home.

Safari Day 3 at Masai Mara, Kenya

Sunday we packed a lunch and headed out again. We had a full morning of Lions,

Giraffes,

And of course Hippos.

We drove down to the Tanzanian border, and some of our group crossed over illegally.

In the afternoon, we visited a real Masai village.

Final Day in Matete

Thursday we spent the morning again at the AP office in Matete.

We met with Matete Pastors, and participated in a round table discussion about their experiences with World Vision and the benefits of the training provided to them.

Finally it was time to say good bye to all our new Kenyan friends. We debriefed, exchanged contact information, then traveled back to the Eldoret Airport. We flew back to Nairobi and stayed overnight again at the Eka Hotel.

Safari Day 1 in Masai Mara, Kenya

Friday morning we flew from Nairobi to the Masai Mara wildlife preserve. We stayed at the Little Governor’s camp.

We hopped into trucks, and headed to the camp. We saw zebra, gazelle, and warthogs on the way.

When we got to the camp, we needed to cross a river, so this kind gentleman pulled us across using a rope.

We then had a short hike up to the camp.

Looking back at the river we’d crossed.

And when we arrived at the camp, we had the customary Kenya tea and relaxed watching God put on a show right at our camp.

The tents and tables were situated next to a pond that was a constant show of various different wildlife. They’d appear on one side, walk across, then disappear out the other side.

When Ron and Tom arrived at their tent, it was discovered that the twin beds were actually a single king size. Tom looked at me and said “You know, Ron. What happens in Kenya stays in Kenya”.

Day Three in Matete, Kenya

Wednesday we again had breakfast at the hotel before traveling back to the ADP. Sister Grace lead us in morning devotionals, followed by tea.

We then visited an education project; the Kivaywa Primary School, a school with many RC / WASH interventions.

We were welcomed to the school by approximately 1,000 cheering and waving children, and met by the Head Teacher.

In addition to touring the school, we participated in a Swahili lesson. Side note: we were surprised to lean that the Kenya national language is not Swahili, but English.

Each of the classes then performed for us, either singing, or reciting, or dancing. What a wonderful experience.

We were both delighted and saddened to visit the single classroom for handicapped children. We learned that up until recently, handicapped children did not participate in school at all, and were often just abandoned. Primarily because of the efforts of World Vision, many now were attending school, but there is a lot progress needed in this area.

After lunch back at the ADP, we again ventured out, this time to the Matete Water Users Association office. We met with the management committee, and learned all that had been accomplished. This included expanding the water distribution network. The small fees charged by the co-op, and the efficient management of it actually provided sufficient funds to allow sponsoring three girls. This provided their school fees and uniforms. Without this help, these teenage girls would have instead been sold by their families into marriage.

Our Second Day in Matete

Tuesday morning, following breakfast at the hotel, we returned to the Matete ADP for morning devotions and of course a tea break.

We then visited the Balibayo CBO for a presentation of the CBO and the donors to understand how they manage the over 4323 RC in the AP.

Following lunch at the AP, we split up met with our sponsored RC at their homes. Shelley and I sponsor 3 children, so WV arranged for all of them to meet with us at one of their homes.

This was a fun afternoon, getting to know the children and their families. We exchanged gifts, were treated to locally grown fruits, nuts, and vegetables, and of course more tea. We exchanged gifts, and then were given a tour of the family’s farm. It was truly amazing how much was being done with a fairly small amount of land.

Afterward, on the way back to the hotel we stopped by the Webuye waterfall.

Our First Day in Matete

Monday morning we had breakfast at the hotel, then were picked up and driven to Matete.

Upon arriving at the World Vision ADP office in Matete, we were greeted with much singing and dancing and ululating. We then had introductions and welcoming remarks from Florence, the AP manager.

Grace then led us in a morning devotional, followed by a presentation about the World Vision Area Program.

We then had the first of what would become many tea breaks.

Following tea, we met with some of the program’s beneficiaries and learned first hand how their lives had ben changed.

Following a fresh, local lunch, we traveled to two of the farms that have been agents of change to the community, having been trained by World Vision Kenya.