Skip to main content

The story of a Hack Job

"So, you have hacked it" -- Few days ago one of the guys at work passed me this comment on a random discussion about something I built. I paused for a moment and pondered:
  • Do I reply defending how that's not a hack.
    OR
  • Do I just not bother
I picked the second option for 2 reasons:
  • It was late.
  • It probably isn't worth defending the "hack vs" topic as the comment passed was out of context.
So I chose the next best action and replied "Yep, sure did and it is working great.". I felt like Batman in the moment.
In this post I will rant about the knowledge gap around hacking and then describe about one of the components of my home automation project (really, this is the main reason for this post) and use that as an example how hacking is cool and does not always mean bad.

But first lets align on my definition of hacking:

People use this term in good and bad, both ways. For example:
  • "He/she did a hack job" -- Yeah, that probably means bad. Let's say that an application was built using a certain framework and someone did not take the time to understand the framework first and put/deployed a code to work around it to make it work and in process creating a lot of code convolution and complexity. That's actually a bad hack which creates tech debts. (I am 90% sure we all have done it and/or at least had come across it and condemn it.)
  • "You hacked it" -- well, this one depends. It can mean good when you did something that extends the functionality than what was shipped with OR could be completely taken out of context because of lack of understanding (like my example above).
The main point is, the term Hack or Hacking is really quite contextual.
Also let me make few things clear here:
  • The way they show in movies that's not how hacking works. Hacking simply does not happen by typing on keyboard really fast. It requires a lot of knowledge, study, research and dedication. EG> If one didn't know how security algorithm, protocol, rolling code etc works inside and out, the individual won't be able to hack a damn thing (FYI, ddos is not considered as a hack). So one needs to put a lot of extra time and effort acquiring those skillsets before she/he promotes to be a hacker. 
  • Hacking applications and causing incidents or inconvenience to a lot of people's life, stealing PII etc is not in any way cool. It's a shameful act and waste of talent.
  • Being an Ethical hacker is cool. If you could let the right person know about the exploited vulnerability then that works in the positive way. Hack to improve life, not to make it difficult. 

Now, lets put things in context, shall we.

Scene 1:
Extending functionality using API layer isn't a bad hacking. In fact that's how (in a over simplified way) Microservices work. I think almost every  software engineer / programmer have done similar at some point in his/her life or is lucky enough to continuously doing it. So calling it a hack in a bad way isn’t contextually correct or fair.

Scene 2: 
My garage door motor only worked with a RF remote and I had to carry the bulky remote on my keyring to open or close the door. So I hacked the RF Remote to make it work such a way that I can open or close the garage door using my Mobile (which I generally carry all the time, who doesn't these days?). Keep it light by not carrying the extra weight. Is this hacking? Well yes it is but in my book this is good hacking and I take pride doing this hack job because:
  1. I could so I did.
  2. It works great !! (don't believe me? read the rest of post and/or watch the demo video).

The moral of the story:

  • Do not label generically that "It is a hack", "You hacked it". There're good hacks and then there are bad ones. Understand the difference and acknowledge before commenting. 
  • Hack to improve, not to destroy. You will only be cool when you use hacking in a positive way.
  • Hacking is really a skill set and a talent. 

The story of a hack job (Garage Door IoT'ed)

Requirement:
I want to open my garage door using mobile phone from anywhere in the world.
Why:
What I have is this:


And this works fine, mostly, typically. But I am beyond typical (because I am Batman).
Here're few problems with the existing problem:
  • I hate carrying keys and the additional attention to take the key on the way out and remember to bring it in one piece on the way in. As I am carrying mobile phone anyway I want to use it as a key and shed the extra weight.
  • Sharing keys is another problem. These RF remotes are expensive and I did not want to buy 1 per user/member of my family. If I could convert keys to an app then I can just add/remove user to the app. Pretty convenient, eh!?
  • The RF Remote only works when I am near by the door. This is a problem. So many times I have driven away few Ks only to turn back to close the door. So I NEED an internet based door control switch so that I can close or open from any where (Like Batman).
  • If I am not home and one my friends shows up they would have to wait outside till I get home (this has happened to me and my poor friend on a rainy day). Having control of the door over internet will help a great deal here. (eg> scenario: Batman remotely opening the door to bat-cave when justice league arrives for pizza & marvel night)   
Unfortunately, all garage door motor typically ships with RF remote that you need to carry to open/close the door.
What really want is this:

So you see there's a problem/gap between what I want to have and what I have now.
Challenges:
I have watched bunch of YouTube videos on how to automate/IoT garage door (actually that's most people's first DYI. For me it is the 2nd. See the first one here: Smart wifi controlled irrigation system). And pretty much all of them involved some form of live wiring and attaching things to the door motor. But I wasn't too comfortable with the live wiring part + all the attachments seems to make a mess up there. So I had to find an alternative approach and get creative about it.

The solution:
After staring at the wall for a weekend I found a way that worked for me. So the alternative approach is *drum roll please* hacking the garage door remote.(It is the first of its kind, I think, at list I have not seen/found this solution on the internet yet).


The garage door remote is a RF Remote which contains a tiny circuit powered by a battery and when a button is pressed to open/close the door it closes/completes the circuit (like a relay). So all I needed to do is to somehow mimic that button press using an IoT device that I could control the IoT switch over internet using my home assistant and the IoT switch will control the button press of the RF Remote.
This way I do not need any live wiring to the garage door motor itself or attach anything to it; in fact, the whole thing can be nicely tucked away in some corner of the house and it will function just fine.

I chose

  • Sonoff SV as relay for it's circuit isolation and ESP8266 based circuit properties. 
  • Tasmota firmware to flash the ESP8266 for its MQTT usability.
So here's what I did:
  • Flashed the sonoff SV with Tasmota firmware so that instruction can be passed on based on MQTT messaging.
  • Isolated the onboard relay from the main circuit controller chips.
  • Made the relay part of the circuit a dry circuit because the RF Remote circuit already has a power source so cannot have another voltage flowing through the relay.
  • Hooked 2 wires from the both side of the push button and attach to the sonoff dry circuit. This way when the relay closes it will complete the circuit in the RF Remote mimic-ing the button press.
  • Finally added a 5V power supply to power the ESP8266 circuit.
  • I programmed in Home Assistant a MQTT switch. Then programmed an automation to trigger when the switch is on and action to turn off after 200ms. This way the MQTT switch will behave like a toggle button.

YouTube:


Photo Gallery:

Sonoff SV

Garage Door Remote

Garage door circuit wired to Sonoff SV

IoT'ed garage door control in a chocolate box

Cost:

Sonoff SV = $8
Garage Door Remote = Free (Spare. If no spare then $15)
Tiny gage wires = $0.10 (for a whole metre)
5V Power adapter = Free (spare, If no spare then $9)

Total: $8 AUD (or worst case $32).
Can you price beat this with any off the shelf?

What's next:

This solution however has one flaw.
The garage door remote works based on toggle (meaning 1 click is close, 1 click is open, 1 click when on movement is pause) and the manual RF remotes are still in function (I have another one in the garage itself).
This creates an issue of keeping track of what state the door is in (open or close or paused half way in the middle). 
So I need some way to determine what is the door state and result of the state after my action.
(I do have a solution in mind, but that's a topic for another day).

Result:

Hacking improved the convenience in my everyday life.
#HackToImproveLife





Comments

Popular posts from this blog

Hall of justice - Authorisation Greeting System

Ever since I watched the Young Justice EP-1 the security system of the Hall Of Justice and Mount Justice wow-ed me. After all it was built by Batman. You see similar AI driven voice guided system in pretty much in all sci-fi series these days. I always dreamed of having something similar of my own. Well, now I have it (sort of). Although we not quite in the flying cars era yet (disappointment) but IOT powered locks are somewhat normal these days. The adoption rate is great.  Some background: What is this Hall Of Justice Authorisation system? This is the security system that Batman built for Hall Of Justice. The movies haven't shown it yet but there're several scenes in the animated series and comic books. Basically, it is a AI powered voice guided intelligent security system that scans bio signatures (like retina, body dimensions, temperature, heart rate) through a scanning device and identifies which member of the justice league it is, logs entry then gr

A CQRS Microservice Architecture - My Way

Microservice Architecture is the new trend in the industry. When I thought of building a decisioning engine to work as my personal assistant I decided to design it as a swarm of Microservices. The most compelling selling point about Microservice Architecture which resonated well for me was its ease of maintainability and that's a big factor for a hobby project like this which has a lot of custom logic programmed into it and requires a lot of frequent changes. In theory, Microservice should fit right in. I tried doing it in the Monolithic way and I failed !!. So, will Microservices solve it for me? Let's find out. In this post I will do it in the "Software Engineering" way. Background: Few weeks ago I created a wifi controlled water system that I can control via my Home Assistant (using my phone even if I am on the other side of the planet, like Batman). And this is working great for me. Read about that here: Smart wifi controlled irrigation system . Bu