How I helped my high-rise neighbors remotely control their smart apartments for free
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
💡💡 PROTIP: To experience this exciting story in the correct order of logs, read through them starting with the oldest:
https://hackaday.io/project/194515/logs?sort=oldest
Additionally, the names for the items on the list were quite cryptic - they named the room they're in and their cardinal directions but that's not really user friendly. Some of the items were even just numbered sequentially...
If I were to design a user interface for a smart home/apartment, I would put much more effort into it and make the floor plan the primary view and put action buttons/toggle switches on it in the positions that correspond to their actual locations for an intuitive experience. And that's exactly what I did.
I made a simple interactive floor plan editor/viewer that each user can customize by adding buttons, then dragging and resizing them to fit their needs. It's coded in simple PHP and JavaScript and it was done in a day. I pulled floor plans from the apartment sales materials and made them "dark mode" for better contrast.
In the photo I attached to this project's front page you can see how it greatly improves upon the original UI (in the top left corner) in the form of a list to an intuitive floor plan where only one touch is required to for example turn lights on/off.
I created floor plan background images for all the active users of my system that I know of but the process of customization is something each will have to do on their own - I don't know the exact locations of their controllable objects and I don't have time to design the layouts on their behalf. The editor is very easy to use though, so anyone can do it.
Thank you for taking the time to read through my project(s) logs and I hope it was an interesting read to you! :)
I still needed to put the internet server somewhere in-between. In theory, I could ask the tenant association to let me co-locate a Raspberry Pi in the building's "comms room" (and I still might, if I ever decide to move...), but I decided on providing that service from my own apartment - and I'm dogfooding my own solution so I know how well it works and can react quickly if it goes down.
The original Android app to control apartments expects an username and a password. I implemented a simple proxy service on my RPi which everyone would access where the username denotes the significant digits of the internal network's IP for that apartment (allowing the proxy to know where to forward the HTTP request to) and the password is generated on first run of the python service inside the Android app - the service will expect the password as part of the HTTP request headers or it would discard the request.
As for the Android app that would provide this python service, I just added it on top of the original app I developed! A new option was added to its only screen to enable/disable remote control and when enabled, show the unique autogenerated password needed. (See the screenshot on the project's front page.)
The best part is, the whole solution is to just install the app on the tablet - the original one or a better replacement (on which of course the original tools that root it instantly and make it faster and reveal the WiFi password are not available or even necessary - only the remote control service option is shown there) - and no hardware installation is needed.
Also, no changes to the smart apartment or the building's network infrastructure are needed and it is thus a "clean" solution that generates just a bit more traffic on the internal LAN (and far far less than each MJPEG webcam connection for the IP doorbells :P).
I'm proud to say that as of 2024, 29/128 (or almost a quarter) of apartments are using my remote control solution. Some of the neighbors reached out and thanked me for it, but far from the 29 I can detect using nmap -p5000 :) - that means that the Quick start guide PDF (also shown on this Hackaday.io project's front page) I sent out to spread awareness of how easy it is even for non-power users works well. But that's okay, I'm most satisfied when I see I was able to provide a free solution that greatly improves the usability of the smart apartment systems. And I made some fine new acquaintances in the process, too!
Before I continue the details from my previous log, let's focus back on the building's networking infrastructure a bit. It's actually ironic that without the need for the 6 building entrances' IP doorbells to call each apartment and for the weather station on the roof that supplies data to the apartment PLCs (enabling automatic window blind adjustment based on light conditions and a safety feature where if the wind speed reaches a certain threshold, window blinds are automatically raised to prevent any damage) there would be no need to connect all apartments together inside an internal network and possibly leaving some vulnerabilities/misconfiguration open to exploitation. But here we are. ;)
I managed to get access to my smart apartment's router/access point configuration by using the device's network boot ability to temporarily boot a custom OpenWrt build which copied the password file from the internal flash storage. Due to the weak encryption used, the password could be decrypted from that file instantly. Geez.
I was then able to deduce the configuration details of all the apartments - it was the basically the same except for different IPs and IP ranges. And I did not like what I found - the subcontractor exposed way too many ports and left the job 3/4 done which explains why there was no after-sales support or monitoring plans - it seems we were in the dark as much as the smart apartment vendor who hired the ex-subcontractor.
Most of the "holes" in the firewalls of each apartment were due to the need to have VoIP calls pass through from the IP doorbells. It seems to me the whole VoIP/SIP architecture is quite complex and convoluted - reminds me of the Active/Passive modes of FTP which use many ports for a simple task of transfering files. Anyhow, the VoIP server is actually an Android app made by the IP doorbell vendor which under the hood uses the Linphone stack.
The subcontractor read the VoIP/SIP specifications (and possibly the instructions by the IP doorbell vendor) and happily opened lots of ports, both TCP and UDP. Luckily, one of those ports does not need to be forwarded for the TCP protocol, which my HTTP python service running on the tablets uses. And remember, the ports already point to the static IP of the wall-mounted tablet as the IP doorbell app is running on it, too!
So now I had a way in to each apartment, directly to my HTTP python service running inside an Android app.
One of the positive things that came out of the difficult time period that was the early 2020s was that hackers and tinkerers everywhere found themselves with lots more time for their hobbies, many of which were open source/made public. I was no exception.
When I introduced Raspberry Pis as a way to enable remote access to our smart apartments' systems I was bothered by the complexity of it all - most of my neighbors would not be able to do it on their own and I was not interested in doing much more than the 10 already done house calls to equip the others.
I wanted to develop a way that would ideally be a software-only solution and should be as simple as my original Android app tool (documented in my first project's logs here on Hackaday.io).
I was aware that every apartment already had a low-power computer that was powered on 24/7 which could be turned into a server - the wall-mounted Android tablets! (Though I had mixed feelings about the device being a mid-range model - and since it was introduced, 7 years have already passed.)
Some things needed to be considered:
My neighbors loved their new remote control options but had several feature requests (doesn't that always happen? :)) - I must say that they were very polite about it and not acting entitled at all, so I was motivated to develop the system even further :)
With so many new options available, everybody got what they needed and it seemed nothing could be improved further. Or could it?
I had my first working system that I felt confident enough in to share with my neighbors - I emailed the tenant mailing list and offered to set it up for a few people without any charge except for the Raspberry Pi 3 hardware (~ 80€ at the time).
I got multiple requests and set up 10 apartments in 2019. In the 5 years to come, some of them have sold their apartments or no longer needed remote access but all other deployments are still working well still on their original SD cards.
I think the technical reasons for the successful setup were:
The biggest issues I noticed and fixed during these years were:
This first public release offered the following 2 remote control clients:
But I couldn't very well leave it alone at that, could I? :)
Well, used to be. Nowadays when I see what the "hello world" app code looks like in Android Studio, I feel unwell, close it and uninstall it. What has happened to lightweight 50 KB APKs anyway? R.I.P.
I decompiled the Java code from the app and studied it - luckily the code was not optimized/obfuscated and no native code was involved, making the Android app quite future proof and available for hacking/modding :)
The main thing I wanted to solve was the lack of HTTPS support.
I created SMALI patches for the relevant features I wanted to fix:
On the server side, I added Basic Auth password protection for the whole HTTP server to "cover up" the fact that a very old Django version is running the show and used certbot to deploy Let's Encrypt which I must say has worked flawlessly for many years now diligently renewing the certificate when needed.
While I might not have the best opinion of the system as a whole due to its "black box" approach, weak security and even some misconfiguration, one positive thing that can be said for the vendor is they give out their software tools freely and are happy that their users expand upon it. (If they can understand it first, heh.)
I was lucky to find their implementation of a remote access server in a form of a Raspberry Pi image online just in time - after a year or so the site went down. I studied it and figured out what steps needed to be done to make a fresh install on the latest (then) Raspbian OS.
I learned that the Android smart apartment app could function in two modes - locally it uses a custom UDP protocol to talk to the PLCs directly but it also supports HTTP communication for remote access.
The software running on the vendor provided Raspberry Pi image comprises a python service that translates HTTP calls to UDP commands and also a Django based web interface where one can make a custom UI for controlling the PLCs and even set up some basic data logging and graphing of the sensor measurement (temperature, humidity, air quality,...).
I was quickly able to configure it for my apartment, my RPi acting as a bridge between the internal network (connected to its ethernet port) and the internet (connected via Wi-Fi). The only trick was to change the local IP subnet of my internet router to a new one because the apartment stuff used a very common one which conflicted with it and could not be changed. I had to of course also open up port 80 so the Android app installed on my smartphone could access it.
It worked quite well - I managed to copy all the UI configuration for the Android app from my wall-mounted tablet and after fixing a bug in the Django/python code that only allowed data to be read (ie. status of the lights) and not written to (ie. turning on the lights) it worked well.
However, the security of the whole setup bothered me and I knew I couldn't offer this to my neighbors as a proper solution:
More effort was needed.
From time to time I sent my findings to the tenant mailing list and also got introduced into the building's tenant association. It was important for us to discuss these technical details and brainstorm ideas to improve the quality of the smart apartments because the original vendor and their subcontractors pretty much left us to fend for ourselves - they would only come on a service call if something broke in a specific apartment - nobody was monitoring or tweaking the system as a whole any more.
I have been living in the building for 9 years now and things would fail:
I did enough poking around to figure out the way everything was connected. And it seems I was the only one since there was some potential for mischief but luckily nobody had the motivation or reason to explore as much as I did.
In each of the 128 apartments:
In the common areas of the building:
And boy, this "limited internet connectivity" was a hack job:
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates