Hammers and Saws and IOT – oh my

After moving to a new apartment I needed to get some hardware in order to hang a few pictures in the livingroom. A quick trip to the hardware store should allow me to make my apartment a home. While walking through the store I was surprised to see smart sockets wedged in between fans and light bulbs. Not only smart sockets but also a small selection other smart components such as light bulbs and light switches.

When seeing that I had to decide on a smart socket, smart light bulbs, or smart light switches. I thought that perhaps the most flexible item that I could use would be smart socket, no electrician required.

Smart sockets are just a rather clever bit of hardware which includes a small relay for switching on the power on and off. The real brains for the smart solution is the phone app that controls the device.

I thought I would get a few more smart sockets and see how smart I could make my apartment.

Malmbergs

The first device tested was that first smart socket from the hardware store. The first real step for all these smart sockets is install the corresponding app from your app store – this app was in both the Google store and the Apple store.

The instructions that came with the device instructed to install the app with the name “REC Smart” by Ankuoo[1]. The app requires that you create an account and once the account is created you log into the app everything works pretty much as you might expect.

Pairing a new device is just a matter of holding down the power button on the smart switch for at least five seconds and then it is in discover mode. You can see that by the blue led flashing on the device and then just follow the prompts to add the device Illustration 1.

xxxxxxxx
Illustration 1: Malberg

This smart socket and its supporting app really does provide a lot of basic functionality. The app will keep a list of all the sockets that have been registered. Initially the app will give each device a generic name but it is also possible to assign a friendly names to each device.

The functionality that makes the smart sockets smart is the ability, with the addition of software, to create schedules when it should be switched on or off. One of the nice features is the countdown timer. The timer offers six predefined times (5, 10, 15, 30, 60 and 120 minutes). There is actually one little quirk for this particular feature. The timer functionality assumes that the socket is already turned on.

Traditional hardware timers make it is possible to schedule when the socket should turn on or off. With software it is easier to make this a bit more flexible. The rules can be setup for either individual days or to run at the same time on multiple days.

Scheduling tasks is fairly orthogonal, it is possible to add schedules, remove schedules but more important they can be disabled and re-enabled at a later time.

The final bit of functionality is called “anti-theft timer”. Much like the schedule functionality you select a time range for a day or for days. The app will turn the socket on and off at random intervals during this time period.

Note: When you enable the anti-theft timer a warning comes up that the other functionality will be disabled while the anti-theft timer is running.

I used wireshark to watch the traffic when adding a device to the app. The smart switch does make a number of connections over the internet. Once this connection has been defined it is possible to control the device using the data connection from a cell phone.

The communication between the device seems to be UDP messages[2]. However, despite the information available on how to control such a device on the internet I was unable to control the socket myself. The information that I did find implied that the packets were unencrypted and it was possible to resend packets to control the device. My experience did not match that of the other users from the internet. It is possible that over the last few years[3] that the manufacturer has modified their devices to put security first and remove this avenue of control. It is also a bit sad as I did not find any API that would allow me to control this device from Linux.

[1] https://www.hornbach.at/data/shop/D04/001/780/491/304/314/6216499_Doc_02_DE_20180117133221.pdf

[2] https://github.com/Diagonactic/Ankuoo

[3] https://news.ycombinator.com/item?id=11211037

S1 Series

The next device I tested was the “S1 Series WiFi socket”. This socket is marketed as also working with Alexa which is some additional functionality that the Malmberg socket does not support. I do not have an Alexa so my tests were focused on the basic intelligence on the socket and the app that controls it. Like the Malmberg device, it appears that most of the intelligence is not in the device itself but is actually in the smart app that controls the device.

Just like the Malmberg socket, adding a device is actually quite easy. Press the power switch for 5 or more seconds until the led starts to flash. From that point follow the steps in the app to add a device. (Illustration 2)

Illustration 2: S1

The only complicated part about adding a new device is the wide breadth of types of devices that are supported by this app. This is a double edged sword for the technically less savy as you need to be aware of which type of device you are trying to join up.

ZigBee Low power digital radio

Bluetooth Short wavelength UHF radio waves

WiFi Standard wireless networking

Just like the Malmberg device, it is required that you create an account with the manufacturer, Tuya, in order to use the app.

Not unsurprisingly the app has a fairly simple set of features, quite similar to the previous app but Tuya seemed to give more attention to the development of the app, it just felt more polished.

The timer also has a much finer level of granularity. The timer can be defined for how many hours and minutes before the device is switched off but it can also be defined to switch on after a given amount of time.

It is also possible to setup a schedule to turn devices on and off at different times. I found it to be a bit odd that this device only allowed you to define a day and time for switching the device either on or off. This does obviously maximize flexibility but it also creates a larger list to be searched when matching up the pairs of on/off times as the number of entries increases.

The S1 Series device is different from the other two devices reviewed as it supports Alexa and that the Tuya corporation appears they have made some libraries and documentation available[4][5]. This should allow people the ability to control their own devices.

I did take a look at the documentation that was available but it is not for the faint of heart. I was unable to create anything myself using this but it is possible due to the number of projects on github. Just search for project with Tuya in the name.

From looking at the website of the Tuya corporation, it seems that they might be licensing the design of their smart switch solution. This is because their web site allows for the creation of your own app with using your own branding[6].

[4] https://docs.tuya.com/en/app/app-sdk/android-sdk.html

[5] https://github.com/TuyaInc/tuyasmart_android_sdk/tree/master/TuyaSmartAndroidSdkDemo/libs

[6] https://docs.tuya.com/en/app/app-autobuilding.html

Sonoff S20

The Sonoff S20 smart socket is only one of many different Sonoff smart devices. The company also sells smart sockets that also measure temperature, monitor humidity as well as remote controlled light switches[7].

The S20 is controlled by the eWeLink app to support setting up a timer for creating a schedule for turning the device on and off.

The pairing of devices is as simple as starting the synchronization on the switch itself while adding a connection from the smartphone app. One of the things that make the Sonoff app different from the other two is that it does assume that there can be difficulties in the pairing process, illustration 3. Based on the realization that difficulties can occur, the app included a frequently asked questions section with a list of the most common problems, illustration 14. The list is both long and very helpful.

Illustration 3: Sonoff S20

All three applications are generally friendly and are localized to the language that has been selected on my smart phone. One difference in the eWeLink app, used by the Sonoff, is that it explicitly supports 22 different languages. You can select the language on the app itself which does allow you to select a language on the application that is actually different than the underlying phone operating system.

Although changing the application language does work for all of the application menus and status’s there is one tiny little inconsistency for the eWeLink app. All of the text that is available under the frequently asked questions remain in English and does not change despite what language is selected for the application.

[7] http://sonoff.itead.cc/en/

All of these smart sockets are well built and the smart phone apps are easy enough to use. Unfortunately all of these smart sockets are produced by separate companies each with incompatible protocols which prevents a single app from controlling them all. The solution is to either purchase only from one manufacturer or modify these smart sockets with some open source software.

This entry was posted in programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *