Friday, August 11, 2017

DIY home automation, new generation

I've had my DIY home automation system for controlling outlets and reading sensor data running for about two years now. The system has been working fine and I haven't had any need to touch the code since I added the sensor reading to it, until a few months back.

Need for new functionality


Few months ago I got a new IoT toy for a lend from a friend until I'd get my own toys, a ruuvitag sensor beacon. Ever since I found the ruuvitag for the first time from kickstarter I had the idea of getting a bunch of ruuvitags and adding their weather station sensor readings as part of my home automation system.

The original home automation backend included only tellstick compatible devices and was written in Python, and in my mind it was kind of a hack. The ruuvitag beacons communicate via BLE i.e. Bluetooth Low Energy and that meant that I needed to add functionality to read the beacon data via bluetooth.

I found a ruuvitag Python library and initially thought that I'd just use that and extend the existing backend. As I started looking more into the ruuvitag and BLE beacon possibilities I came accross Node.js implementation that would be able to read the beacon data. As I started looking deeper and extended my search within Node.js libraries I also found a telldus library.

I've done some work with Node.js and even though it's not my first go-to choise it seemed that with it I could simplify my existing backend a lot and add the new functionality quite easily.

Backend rewrite


I'm not going to get in details of the backend code as it's basically a REST API that reads sensor data and controls outlets just like the original implementation but here's a link to the backend code and just a few notes about the backend.

The Node.js telldus library uses the native telldus library and is compiled with node-gyp so it needs to compiled on same architecture where the backend is going to be running. The compile time on my original Raspberry Pi was quite long.

The beacon library uses bluetooth library and it has the same restriction as the telldus library.

The readme file contains more information and instructions in case you're interested.

Refresing the UI


The UI of the original home automation system was a vanilla JavaScript experiment and I thought that I should also update that as I already rewrote the backend. This time I chose Vue.js as it's something on the rise and I haven't used it before. Just like with the backend I'm not getting in the details of the code but here's a link to the code and a screenshot.



Wait, what, no tests!


I made a conscious decision not to write any unit or integration tests for this project as without all the hardware (tellstick duo, controllable outlets, bluetooth, ruuvitag) I'd have to mock them and I'm not a big fan of mocks.

Sure i could have written a unit test for parsing the sensor data from the beacon URL but it just didn't seem worth the time and effort as I have manually tested the implementation for hundreds of times while developing.

Integration testing has also been manual while developing and continues to be manual as we use this system daily so I didn't see the need for automating that.

Final thoughts


The rewritten backend of the home automation system seems to be working as reliably as the first generation and I'm really pleased how much cleaner code I got with Node.js.

Vue.js seems to be a viable option at least for small projects like this one.

I already have some ideas how to do some actual automation and analytics based on the sensor data but that's another story.

P.S. I wish my ruuvitags had a light sensor as that would extend the automation possibilities even more.

Tuesday, February 28, 2017

Why am I a consultant

Have you ever wondered what do software consultants exactly do? I'll share my view of how I ended up as a software consultant, what I have gained and what do I do as a consultant.

My brief background


I started my career as a programmer in the early years of 2000's as part of my studies and via summer jobs. Back then I was working with web sites and doing... well what ever we could do back then. Few years later I enrolled to university and at some point started working as a programmer to have some side income and work experience. After I graduated I continued working for the same employer I had been been working for the past few years.

After four years of working with the same employer and on pretty much the same applications and technologies I started to notice that I wasn't learning new skills or technologies as much and fast as I wanted to.

Time for a change


I started looking for job openings and had a few interviews with different companies. I chose to work for a company that offered me a job with a in-premises project where I'd be joining a small team who'd been working on the project for a while. This seemed like a great opportunity to work on something new and learn new skills. I knew I'd be working for a company that did subcontracting on the form of software projects for various clients. What I didn't fully realize then was that that's exactly what consultancies in Finland actually do. So by a sheer chance I became a consultant. I worked for the company for a few years with various clients and really started to like how consulting in the software business works.

I've been working as a consultant ever since and the few times I've changed jobs I haven't seriously considered working in any other position.

I'm a consultant - what I have gained from it


I've thought about it more than few times what it means to me to be a consultant and what it has given me compared to my previous jobs.

Networking


The network I have gained during my years as a consultant is something I could have never achieved if I'd been working in product development company or in a company that has a internal software development unit. The professional network that I have gained as a consultant can be divided to different sections.

Clients

The network of different clients in various business domains. Via this network I know a lot of people from different business fields and I have gained working experience in various domains.

External contacts

External contacts consists of clients and their own software developers and it's common to be working side by side with consultants from other companies.

Internal contacts

Internal contacts are all my great colleagues from all the companies I have worked in.

Learning

By working with various clients in different business domains I have gained a lot of knowledge on different business fields. I can see commonalities and differences on how different clients and business fields do things and I can apply that knowledge and compare various technologies and work habits and processes to each other.

I believe I can learn from every client and from every colleague, internal or external, and I can honestly say that I have learned something while working with each of my clients and colleagues.

Learning as a programmer doesn't always mean learning new technical skills, frameworks or languages but also about soft skills, project habits and management or how to organize work and how to not do things.

What do I do as a consultant


Main area of my expertise is programming and that's the role I have when I start working with a new client.

Depending on the client and their needs I have been doing a lot more than just programming. With some clients I have been doing a lot of investigation tasks related to integrations between different systems or investigations on how some legacy systems work.

At some rare occasions my work has also included some work management in the form of introducing or trying to improve existing methods on how a team could organize it's own work better or make the teams work more transparent.

Besides the work I do for clients I also participate in some internal work. I have been doing recruitment interviews and when needed I give support to our sales people when they need assistance in technical matters and sometimes I take part in meeting our new or potential clients.

It's not all rainbows and unicorns


Even though I see a lot of positive aspects with consulting there are some not so great features with consulting that every consultant will face at some point.

Clients don't always know what they want but they want it done yesterday. The client might want one thing on one day and the opposite thing the next day. In worst case the client blames consultants of doing wrong things.

You don't fit in the team. On the outside everything might look fine but working as a consultant means that you are working with other people and some times people just don't get along with each other.

The job isn't what it was supposed to be. A new gig might be sold to you with buzzwords like new technologies, agile teams, up to date CI/CD pipelines but in reality you end up working with legacy systems or abandoned code bases without tests or maybe the agile team means that objectives yesterday were totally different from what they are today.


Why do I do it


To me all the positive outweighs the downsides of working as a consultant. When things get really bad I have the possibility to change projects/clients, it may take some time but it's always possible.

To me the best part of working as a consultant is the variation of clients and projects. I personally don't like working too long (read: years) on a single project even though some consultants do prefer them.

I get to work on various projects on different business domains and constantly learn new skills without the stress of changing jobs.