Grafana: Useful plugins

grafanaGrafana is a cool data visualisation tool. You can even improve it by adding additional panels and plugins. The whole plugin directory can be found here: https://grafana.net/plugins.

I recommend the Histogram panel. Unfortunately you can’t do it directly from the GUI (at least not in the current version 3.0). However, installing on the Raspberry Pi is relatively simple:

cd /usr/share/grafana/public/app/plugins/panel
sudo git clone https://github.com/mtanda/grafana-histogram-panel
sudo service grafana-server restart

Cool sensors for your next automation project

Home automation isn’t about controlling a lamp with your smartphone. It is called “automation”. A home automation software should do things automatically. Do do this, it needs to have an idea what’s going on in your apartment (or outside). For this, you need sensors. While some sensor types are well-known you might not know what is available already on the market for a small budget. The following sensors can be integrated easily with your Arduino, EPS8266 or Raspberry Pi.

Temperature

35040-img_0674Almost everybody already did experiments with temperature sensors. The DS18B20 is a 1-Wire sensor that can be connected easily to many platforms. You will find a lot of code snippets for this sensor already. It has a 0.5 degree celsius accuracy which is more than enough for most use cases. If you only want to monitor the temperature, go for this one.

Humidity

dht-11-1The DHT-11 and DHT-22 are two sensors that combine a temperature sensor with a humidity sensor. Both are more expensive than a simple temperature sensor. However, humidity informations might help you to do better automatisations. One use case could be turning on an air humidifier when the humidity is too low. Another would be opening windows, when humidity is too high. While these sensors also use a 1-Wire-type protocol, it is different from the 18B20 sensor. You can’t connect both sensors to the same GPIO. However as the DHT-11 has the temperature sensor already included, there is no need for an additional 18B20.

Soil moisture

13995201090You’re plant are dying regularly because you forget to water them? Another use case for a sensor. Soil moisture sensors are available in 2 variants: the cheap sensors just measure the soil resistance. The problem with this sensor type is corrosion (over a longer lifetime). Capacitive sensors are becoming more popular and don’t show this problem as the electrodes are isolated. However, they are more expensive and a bit less sensitive. You need to experiment a bit to find the correct threshold for alarming.

Motion detection

pir-motion-sensor-536x408You want to know if somebody is home? PIR motion sensors are also available for a few bucks and will give you information about people (or pets) moving. If somebody is just sitting or sleeping, the motion sensor won’t detect this. However, for many use cases this is just fine.

Sound pressure

grove-Sound-SensorYou’re not at home, but your teenage son. What do you think will happen? A party! Your neighbors will tell you tomorrow. Wouldn’t it be cool to automatically reduce the volume of your stereo system when the volume exceeds a specific level? This level might be higher at 5pm than at 11pm. A sound pressure sensor will do the job – at least until your son finds our where it is located and puts some damping onto it.

Small particles

Particle sensorSmall particles in the air can be a problem for some people – especially if you suffer from asthma. These emissions can come from various sources. Measuring the number of small particles in the air might give you an idea what might be the source and do something against it. These sensors are based on optical measurements. While this might sound complicated, sensors like this are not very expensive anymore.

Accessing your Home assistant installation outside your house

Having a home automation solution that is only available inside your house might work for some people, but most people want to control their home also form the outside.

There are different options to achieve this in a secure way.

VPN

IC196810Using a VPN is usually the most secure solution. Even if there is a major security bug in your Home Assistant installation, attackers still can’t compromise your system as it isn’t publicly available on the internet. Many ISP’s today already provide a VPN service. You need to check with your ISP if it is available and how to configure it.

The disadvantage of a VPN is that you have to connect to the VPN first. This becomes an even bigger issue, if you use 3rd party applications (e.g. device trackers) that want to connect to your Home Assistant server. If the VPN isn’t connected, they will fail and some status informations might not be updated correctly.

HTTPS

Using a public HTTPS server is not the most secure solution, but still ok in general. Just note that you have to always check for security problems and update your Home Assistant installation regularly.

letsencryptFor HTTPS you will need certificates. A simple and free option today is Let’s encrypt. There is already a guide on the home assistant web site that shows how to use Home Assistant with Let’s Encrypt.

An additional security improvement can be implemented by using a web application firewall in front of the web server. While you can do this by yourself, it it quite complicated. Another option is using Cloudflare.  While you can’t use your own rules in the free version, it will still provide some basic security and protection against general attack patterns.

Comparison of both variants

VPN HTTPS
Security Highest, as your system is protected even in case of security flaws in Home Assistant Ok, but you need to make sure that you regularly patch Home Assistant
Ease of setup Relatively easy if your ISP already offers it, otherwise complicated Medium, guides are available
Ease of use  Medium, you always have to connect the VPN first Very easy

Configuring iBeacons

iBeacons are a great way to locate you within your apartment without draining the battery too much. An iBeacon is basically a Bluetooth-Low-Energy device that just broadcasts an identifier in periodic intervals. iOS and Android devices that receive these broadcasts can identify the iBeacon and even calculate the distance to it.

For in-door navigation, the cheapest iBeacons works best as their range is limited. This makes it easier to locate you without using complex triangulation algorithms. When you move, you will just leave a cell when you are too far away for the iBeacon.

As most existing iBeacons use a Texas instruments chipset they are not extremely cheap. Even when ordering directly from China, it is hard to find them for less than $10. One iBeacon that is relatively cheap is the Ghostyu. It consists of a small PCB and a relatively large battery on the back.

ghostyu

Using a single piece of these is simple. You can just use them as they come. If there are neighbours or people on your way to work that use the same beacon, you might run into trouble as the basic configuration is the same for all of these devices. The basic configuration is:

UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
Major: 0
Minor: 0

All 3 IDs can be used, but the UUID is always being used (you can ignore major and minor).

Therefore I recommend not only to set major and minor to different values than the default, but also UUID. The UUID is an 128-bit ID, you can just randomly select one without having to fear that somebody else in the world will use this. The easiest way is using an online UUID generator.

But how do you change the UUID? For the Ghostyu, there is an iOS app called LightBeacon. Unfortunately it is completely in Chinese. However, clicking around a bit should bring you to the following configuration dialog:

lightbeacon

Here, you can not only define UUID, major and minor ID, but also the advertising interval. This can have a major impact on the battery life. If you want to use iBeacons to turn the light on when you enter a room, 0.5s might still be ok. If you just want to track you and turn the light off when you left the room for some time, even the longest interval of 4 seconds is more than enough. In many use cases, 4 seconds will work fine and result in a longer battery life.  Now just store the value to the iBeacon. It will reboot and advertise the new UUID, major and minor.

5 Ways to start Home Automation for under $50

Home Automation is getting more and more simple with each day. Using WiFi, almost everything in your house can become ‘smart’. For under $50 you can begin to monitor and control your house, from anywhere, without breaking the bank.

Hook-Budget-Home-Automation-SystemHook: The Hook home hub finds its origins in DIY Home Automation. With successful crowdfunding, Hook is a low-cost Automation system that can control up to 15 devices remotely; in partnership with IOS, Android, Amazon Alexa, and the IFTTT web server. With Radio Frequency compatibility, Hook can convert any cheap RF socket to a smart socket. The Hook hub ships this month for just $49.95.

tplinkTP Link: This smart outlet is an affordable Home Automation device that can give your house a lived-in look to deter burglars with its ‘away mode’ protocols, turn your devices on and off from afar, and control your appliances. Compatible with Android, iOS and Amazon Alexa, the outlet also integrates energy monitoring, and can be controlled through their free Kasa app. A low-cost beginning that save you money and monitors your home, the TP Link comes with a 2-year warranty and 24/7 customer support to guide you through the transition of smart-proofing your home. The TP Link can be purchased for $40.72, with cheaper options starting at $29.95.

huePhilips Hue lighting:  Starting at $29.99, your investment need not go beyond a lightbulb. The Philips hue lighting products offer lighting protocols that adjust to your time of day; creating a natural light that can also be customized for specific moods and settings. With daily routines and quick-control features, you can flick the switch; dimming or turning off your lighting, from your smart light-switch on your phone. With the addition of an optimized, open source Home Automation system such as Hobson, this investment can be the first piece of your Home Automation framework, and control your in-home lighting remotely, for ‘lived-in’ protection in your house. Philips Hue also offers a free app tailored specifically towards this product.

insteonforscamInsteon Remote Control Plug-In On/Off Module: This small hub can control lamps and other small appliances. The perfect introduction to Home Automation, Insteon is compatible with smartphones for remote accessibility. Starting at $49.99, the Insteon can also be connected to a larger hub, for when you need to expand upon your Home Automation.

Foscam Camera: Using Home Automation, you can check on your house remotely with this IP camera. With its own remote viewing and recording system, this device can easily be linked into any open source software, as part of your User Interface; growing with multiple devices. Pricing for Foscam IP cameras start at $39.99

Home Automation has become a vast and diverse landscape of options. Expanding outside of WiFi’s limitations, Investment in Home Automation seeks to revitalize your household with Infrared, Bluetooth and Z-wave compatibility.

Hacking the H801 LED dimmer

I just received the H801 LED dimmer. I couldn’t figure out, what the “W1” and “W2” connectors on this device were. So I removed the case and checked the board. I was pleasantly surprise to see that this isn’t a 3 channel (RGB) but a 5 channel device. The W1 and W2 connectors are 2 additional channels.

Installation isn’t complicated. You connect the power supply and the LEDs and turn on the device.

With a laptop or mobile device, you connect to the WiFi network HCX_856705 (the numbers might be different) and use the password “88888888”.  Now, the trouble begins if you don’t have an Android phone. I was expecting there is at least a simple web interface available that allows to configure WLAN credentials. Nope! The only way to control the device with the initial firmware is an Android app.

You now have 2 options if you don’t own an Android phone: flash another firmware or install an Android emulator on your PC. It used Droid4X. However, I wasn’t able to connect to the device. I’m note sure if this Application supports using the WLAN connection from the Mac.

Ok, back to the start. Flash another firmware. This is usually something that I don’t do easily, but on a device that costs less than 20$ and isn’t useable for me otherwise, I tried this. Luckily the board design makes it easy to flash a new firmware. The board is already prepared with 2 headers: RX/TX/GND/3.3V and J3. Just solder headers and use your existing ESP8266 programmer.

h801-header

As software I used the Arduino sketch from Eryk.io and adapted it slightly. My sketch can be downloaded from Github.

The GPIOs are used as follows:

Pin Function
15 Output red
13 Output green
12 Output blue
14 Output white 1
4 Output white 2
1 Internal LED green / Signal
5 Internal LED red / Power

433MHz window sensor

On eBay, Alibaba or other web sites, you can find cheap Window sensors that will send a data packet to inform you about the state of your windows. They often costs less than 10$ per unit, which makes it easy to test them.

They look like this:

Newest-High-quality-1Pcs-433-MHZ-Wireless-Home-Security-Door-Window-Sensor-Detector-with-Battery-for

But what’s inside? Let’s have a look. The part that is mounted on the window itself is basically just a magnet. You might already know what will be on the other side: a reed relay. But what else:

The electronic circuit is based on the HS1527. The nice thing about this chip is the 1uA standby current. Even with a small battery, the battery life will be relatively high. It is powered by a small 12V battery – I haven’t seen this battery type before.

The good thing about the chip is that you can use a lot of cheap 433MHz receivers connected to a Raspberry Pi or Arduino to receive the signals.

However, there is one major downside: This sensor sends only a data packet when you open the window, not when you close it. This is ok if you want to use it to detect break-ins, but it won’t work if you want to detect if a window is open (e.g. if you want to turn off the heating).

Therefore I can’t recommend this sensor type for home automation use.

Raspberry Pi as a Home Automation Server

The Raspberry Pi is a credit card-sized Linux computer on a single circuit board that runs on an SD card. It is powered off a 5V supply – so it can run all day it uses very little electricity and only costs around £25 – £45. The Raspberry Pi has a graphical output with a HDMI plug and a good standard of audio processing. It has networking capabilities, so you can plug it into your home network if you want to and configure it to automatically connect in the future, or you can plug it into a USB Wi-Fi dongle. As it is wireless, you can then place this server anywhere in your house because it is so portable (in a cupboard, below your desk, in the garage – even outside). The server is low cost, high performing and as of 2015, Raspberry Pi had sold over 8 million computers after launching in just 2012). The latest model is the Raspberry Pi 3 – modified to include wireless LAN and Bluetooth; making IoT and mobile projects more accessible. They were first designed to teach children how computers are made/ work, but are increasingly being used for a variety of other projects.

Moving your home automation code and programs over to the Raspberry Pi makes is simplistic in nature. You can connect low-level electronics to it, so you can read from sensors, but at the same time run Python scripts and interface with other devices on your network such as a Philips Hue hub – as well as pulling data from the internet. You also have the ability to create a graphical display if you want to; you can plug it into a monitor and plug in a keyboard and mouse and use it like a fully graphical-interfaced computer to do the programming. And because it is a Linux server too, you can connect to it via SSH on your home network.

The Raspberry Pi Foundation is committed to helping people learn about computers and how to solve problems in the digital world, so the company’s profits go straight into funding the training of teachers to help people use the technology they offer. They are a forward-thinking company, solving the modern-day shortage of programmers and coders by educating, training and enabling people to build their own HA servers in their own homes.

Blocking sensors in Home Assistant

I really like the open source software Home Assistant. However, today I noticed that the whole system wasn’t working anymore. Ok, sometimes a Reboot helps, but not this time. Looking further into this I found the cause of this problem. One of the WiFi enabled switches wasn’t responding anymore. And Home Assistant completely blocked.

This is a major issue in a home automation software as you can’t be sure that in a complex environment every component will work as expected. An issue has been opened for this problem. I hope that there is a easy way to fix this kind of problem.

If your Home Assistant isn’t working anymore, start it from command line and check the output. You might find a subsystem that blocks the startup.

Power supplies for LED installations

If you look around on the Internet you will find a lot of interesting DIY LED installations. Most projects are stripes for lighting and Ambilight clones. Last week I stumbled across a very good guide how to build your own Ambilight clone. I won’t link to this guide as it had one big problem: safety!

Many projects use power supplies similar to this one:

pl8886134-short_circuit_protection_standard_led_display_power_supply_100w_5v_20a_ip20_60hz_en1122

Why? Because they are available quite cheap from many Chinese suppliers. I can’t say if a specific power supply itself is safe. With this type of power supply, the build quality is usually quite good because you can see most parts and people wouldn’t buy them if you can already see that parts are not soldered correctly. Note that this doesn’t say anything about the quality of the parts. But let’s just say, the manufacturer designed this power supply well and it is safe. Why shouldn’t you use something like this? Why isn’t it safe?

Many DIY installations install power supplies in places where they are hidden, but can still be accessed  from the outside. Check out this picture:

powersupply-unsafe

You won’t see the power supply from the front, however, the mains is still relatively easy accessible. Even if you don’t have kids at home, this is unsafe!

There is an easy way to deal with this problem: You should use fully capsulated power supplies with standard AC cables like this one:

laptop-adapter-ac-adapter

This type of power supplies is also available in many different voltages with a power range of up to 100W – more than enough for usual LED installations.