Category Archives: Home automation

Making everyday life easier and more energy efficient, one sensor at a time…

Listing all Telldus Live devices in Node-RED

Tellstick Net and DuoContinuing from the previous post about publishing data from Telldus Live to MQTT, here is small piece of related Node-RED code. It outputs a list of all (wirelessly controlled) 220V/mains switches I have linked to Telldus Live, using a Tellstick Net.

The background of the code was simply that I wanted a convenient way of getting a complete list of all devices (switches, dimmers, door bells, …) known to my Telldus Live account. When testing different devices, moving them around, renaming them etc, it is very easy to loose track of which device does what, and what their respective IDs are. This little function solves that quite nicely.

Continue reading

Using Node-RED for publishing Telldus Live data to MQTT

Tellstick Net and DuoTelldus has a set of nice little gadgets (“Tellstick”, for short) that both allow you to control remote switches over radio (433.92 MHz), and to read sensors transmitting on that same frequency. Telldus also has a backend service, Telldus Live, which offer Tellstick users scheduling features (turning lamps on/off at certain times, or when certain conditions occur), as well as showing the latest sensor readings.

The above is at least true if you have a Tellstick Net, which connects to your home network and sends device and sensor data to the Telldus Live service. You can also achieve the same thing with the non-connected Tellstick models, and an always-on computer running Telldus’ software.

Anyway – let’s assume that Telldus Live can see your switches, sensors and other connected devices. Would it not be cool if you could bring all that data into Node-RED, and from there create whatever feature you dreamt of.

How about sending an SMS when the  garage door is still open, but your presence data indicate that you have left for work? Easy.

Or the opposite: Send a tweet to your Node-RED server, which will then fire off an event to Telldus Live, turning a switch on, and by doing so closing the garage door? No problem.

Continue reading

Enabling Mosquitto websockets on Synology NAS

Websockets are cool. They are the modern sibling of http in that they run over tcp, but "EthernetCableBlue2" by Raysonho @ Open Grid Scheduler / Grid Engine - Own work. Licensed under CC0 via Wikimedia Commons - https://commons.wikimedia.org/wiki/File:EthernetCableBlue2.jpg#/media/File:EthernetCableBlue2.pngwebsockets offer a lot more, most notably full duplex (i.e. data can be sent in both directions) and realtime delivery of messages.

Those two features enable the creation of web pages that update dynamically as soon as new data is available on the server. No need to reload the web page in the user’s browser.

I have been struggling with how to get websockets integrated with MQTT on my Synology DS1515+ NAS, but in the end it turned out to be pretty easy!

Continue reading

Start Node-RED on OS X login

Node-RED flow for controlling a Blink(1) USB indicator light

Node-RED flow for controlling a Blink(1) USB indicator light

Node-RED is a truly awesome framework for visually building data flows. There is a lot of focus on wiring together hardware devices and Internet of Things, but there are also plenty of modules for connecting to email, social media, various online services etc.

After using it during some months I can confirm that stability is absolutely fine, don’t think I have had a single issue with the setup due to Node-RED itself.

Version 0.10.1 came out a week or so ago (early Feb 2015) and brought things like better partitioning of flows in the form of subflows, improved Raspberry Pi support, binary MQTT payloads to name just a few of the improvements.

I am running Node-RED on an always-on Mac, running latest OS X. This machine is very stable but for various reasons I do need to restart it every now and then. It would then be very nice to have Node-RED start automatically at boot. That’s somewhat complex to do, but having an app starting at login is trivial – let’s do that instead. I am always logged into this computer anyway, so it won’t be a problem.

Continue reading

Raspberry Pi won’t boot – only red power light comes on – SD card corrupt? Not so fast…

After having problems with SD cards failing after a few months in a Raspi that was supposed to be always-on, it was time to look for options.

The IPE distribution seemed like a perfect match – it effectively makes the Raspi only use a ramdisk, except possibly during boot. When needed the SD card file system can be made writeable, meaning that apt-get etc can be used as usual to install apps.

This worked great for ca 3 weeks, then this setup ALSO failed, with the same symptoms as before: at boot only the red power light would come on – nothing else. A fresh SD card with a fresh copy of IPE worked fine in the same Raspi hardware, thus not the Raspi itself that had fried (the cabinet where it lives is kind of warm, nothing too crazy though).

Now the weirdness starts for real. The failing SD card works perfectly fine when inserted in both an iMac and a Windows laptop. I spent hours and hours reformatting the card with various low-level tools, then writing the standard Raspian image to the card. Just for reference I did the same to a third SD card too, that card was identical to the failing one.

Still the same issue: that one card would still prevent the Raspi from booting.

The card in question is a Kingston 16 GB microSDHC card marked SDC4/16GB 081. It comes with an adapter that makes it usable also in large SD card connectors.

Photo on 11-09-14 at 06.52 #2

Finally, and I of course should have thought of this sooner, I tried swapping the two different microSD to SD adaptors. And of course… the solution was simple. It was not the SD card that had failed, it was the adapter. For some reason (heat? just poor quality?) the adapter had a small crack in its plastic housing, and as a result most likely some poor connection inside, between the microSD card itself and the surrounding adapter. When inserted into a proper computer, there was probably enough pressure on the adapter to squeeze it against the actual microSD card, while the SD card holder on the Raspi is kind of flimsy, and did not provide the needed pressure. When using a working adapter all three microSD cards work flawlessly in the Raspi.

Note to self: Use full sized SD cards in Rasperry Pis….

 

 

 

 

How to monitor broadband uptime

After moving to a house a few years back we ended up in a situation where ADSL was the only option (aside of mobile broadband, which is not really a realistic option if you plan to do a fair amount of computer work from home) available to us. However, the nearest phone station turned out to be close to 4 kilometers away, which according to the broadband provider is a lot, maybe even approaching the distance where ADSL is usable.

Except that they failed to mention this when we informed them about the move from hyper-connected downtown to the suburb we now live in…

After well over a year of poor broadband speeds I got them (the ISP in question is Glocalnet, subsidiary of Telenor, btw) to acknowledge the problem, and even give us a refund for the months we’ve been paying for a 24 Mbit service, even though actual speed never gets above 5 Mbit.

Fast forwarding a couple of years, we’ve been paying less per month than before, but the quality of the ADSL connection is still poor, with the connection yoyo-ing several times per day. A couple of weeks back I finally had it and told them to fix the problem or stop charging us for a service they can’t deliver. A few days later an SMS arrived stating “your technical problem has been resolved” .

So, to the point of this blog post. How can I monitor they have actually fixed the problem and now provide a stable broadband service to us?

I ended up using a two-tiered approach:

1. External monitoring service
Using a free, third party server monitoring service to ensure there is connectivity from Internet to my home network. As the broadband outages we had experienced were typically quite short (on the order of a few minutes each), I needed a service that would ping a suitable computer in my home network at frequent intervals. Turns out there are many good free monitoring services (moni.tor.us etc), but they all (?) offer 20 or 30 minutes as shortest ping interval.

I finally found Pingdom, which offer you a free account from which you can monitor ONE server, with a shortest ping interval of 1 minute. Perfect. Their web site is slick and no-nonsense, they even have a very efficient and easy-to-use iPhone app. Great.

Only caveat is that you need an always-on computer at home, in order for Pingdom to have something to check connectivity to. Assuming that’s in place, you get stats like the following:

2. Ping from internal network to Internet
In order to minimize the number of false positives I decided to also check connectivity from the home network to a suitable site on the Internet. Once again, this assumes there is an always-turned-on computer in your home network. I use a Linux virtual machine that is always running anyway, looking after various other stuff.

A small script pings www.google.com once every minute and outputs the result into a text file. If Pingdom indicate a broadband connectivity outage, I can then go into the text file to verify that this was really the case (ruling out problems with Pingdom’s servers/service). The script looks like the following, paths might need some editing in other environments.

echo —————————– >> /home/goran/pinglog_google.txt
date >> /home/goran/pinglog_google.txt
ping -D -c 2 www.google.com >> /home/goran/pinglog_google.txt

Add to this a crontab (run crontab -e) entry for running the above once every minute:

# ping Google once every minute to make sure broadband connection is up
*/1 * * * * /home/goran/ping_google.sh

…and that’s about it. Keeping fingers crossed I won’t have to use this data against the ISP – nonetheless good to have it, just in case.

Wiring the house, part 3: Planning the 1-wire sensor network

When ordering the needed hardware new possibilities came to mind, as they so often do when you are browsing catalogs of companies selling cool gadgets…

The first version of the 1-wire network will look something like this, possibly with some of the sensors furthest away from the server installed at a later time. Some of these sensors are after all pretty expensive (just the humidity sensor, HIH-4000-001, got it from Digikey, that is attached to the DS2438 AD converter cost around €20). Getting the all the cables in place have also turned out to be a bit tricky, the tubing in the walls back in –65 just weren’t made with cat-6 networks, phone lines and 1-wire networks in mind…

SP53 1-wire network

The Linux server will run either temploggerd and owfs (if I can get it to work on the small Bubba Linux server that I am using, so far it compiles ok but doesn’t seem to respond properly to the sensors), or thermd.

I verified thermd runs (it does work as expected but it takes 15-20 seconds or so to update the graphs) on the Bubba server as long as you install the perl runtimes and quite a few Perl packages, but as owfs offers a better client-server approach it would be the preferred solution.