Posts

Graphing Energy Consumption with TP Link HS100 Smart Plug

Image
Monitoring energy is a rather large interest of mine - I've developed Monitor for EnergyHive and Efergy Engage and my family have solar panels. It's interesting to see trends in our energy usage with my app, however it doesn't give us any information about which devices in particular are using the most energy.

I happen to use a HS100 smart plug to control my desk but was disappointed by the little information that the Kasa application displays and therefore have never used it to track my energy consumption. Today I got a bit of free time and decided to look into reverse engineering the smart plug. Luckily this had been done before by @ggeorgovassilis on GitHub so I didn't need to look into it myself - I just grabbed the script, made a few modifications and then wrote my own logging shell script.

This was one of my first properly functional shell scripts and, wow, I actually quite like working with shell scripts. They are versatile and reliable and also fun to write. I …

Material About Library - Release 2.3.0

Image
Earlier today I released version 2.3.0 of material-about-library. This is a brief summary of the changes in the release.
In this release, we have addressed the issue of the ActionItem and TitleItem text from being misaligned. (#79)

Since the design of the default items has changed, please note that this update contains breaking changes. If you have created your own custom items to use alongside the defaults, make sure that they still look good and check their alignment with the new design. The photo below is a comparison between the old layout and new layout. There was some discussion in issue #79 in which @code-schreiber and I decided that the 'new' (right side) layout is more aesthetically pleasing.



In addition to this, I would like to thank @code-schreiber again for updating translations in the library and tidying up the readme.

Finally, the bundled version of the support library has been updated to 27.1.1 which fixes some Fragment Transactions that you might have encountere…

Last.fm Desktop Wallpaper

Image
As you've probably gathered by now, I listen to music basically whenever I can. I keep track of my listening statistics using a fantastic service called Last.fm. This benefits me in multiple ways - they're able to suggest me new tracks based on the type of songs that listen to (albeit the algorithm isn't as good as the one Spotify uses), and I can see how my music taste shifts over time. Statistics interest me, so the weekly report is a fantastic method of visualising my listening habits. I tend to listen to a large number of tracks over the course of a week.
Another great thing about Last.fm is the number of 3rd party applications available. The API allows these services to access your listening data and provide all kinds of cool stats & visualisations. There's a great post over at /r/lastfm with list of all the currently working websites.
One of my favourites is lastfm.dontdrinkandroot.net which creates a word cloud of your top artists. Here's mine:
I was al…

Custom Error Handling with RxJava & Retrofit 2

Recently I started redeveloping my Android app Monitor for EnergyHive in order to try and take advantage of some of the new techniques that "modern Android devs" are using. I must say, the many hours of reading up and research was totally worth it - MVP keeps everything much simpler, Retrofit stops me from having to build API calls myself and RxJava handles threading - letting me focus on the code instead of avoiding the dreaded memory leaks.

Before I added RxJava, in an effort to modularise things, I made use of Retrofit Callbacks. These had some extra logic that would take the erroneous server response and parse it into my own custom Exception. I would check for response error messages and error codes even when the server returned something other than code 2XX and then create a custom ApiError object. I was able to create my own Callback that extended the Retrofit callback, and performed some logic in the Retrofit methods that passed the relevant Exception to two new abstr…

Amazon-Hyphen

Image
So, you’ve probably seen the Amazon Dash Button - a compact little wifi connected button. There have been loads of different “hacks” circulating on the internet, and since they were recently released in the UK I decided to order one.

One day later I had it toggling my Lifx light bulb thanks to the countless tutorials on the internet. I followed Steven Tso’s blog post and it only took me about half an hour.
Setting up the Dash Button with the app was simple, and cancelling at the final step (selecting the product) let’s you press it without ordering anything. Since the Dash only connects to WiFi when it’s pressed, the majority of the “hacks” online involved monitoring the WiFi network, waiting for the Dash Button to join, and then executing the relevant code.

Works great… Until your internet dies. I don’t know about you but I have to restart my WiFi router almost daily to avoid slowing down, which seems to break the ARP monitoring code. When trying it again today, I realised that I cou…

Android Bottom Sheet with Dimmed Background

Image
So, I was developing a new budget feature for Monitor for EnergyHive and Engage and needed a way to display the data without obstructing the current user interface.

I am going to do a complete redesign of the app sometime soon, but for now, this is how it looks:



As you can see, the design I have used doesn’t leave much space for extra features. I’m in desperate need of a good UI designer.


Anyway. As always, the Google Material Design Spec is a godsend for us developers who have no sense of style. I wanted to achieve something like the first image on the bottom sheet spec with nice animations.


Essentially, a modal bottom sheet that contains normal interactive elements rather then a list. I was glad to see that official bottom sheet support was added to the Android Support Library 23.2 but after looking further into the implementation, what I wanted didn’t look as simple as I thought it would be.

You see, the support library offered two options - the ability to create a bottom sheet out…