Xiaomi Mi Robot Vacuum

I have finally purchased a robotic vacuum cleaner. After much time trying to get the best smart / connected automated vacuum cleaner for my money, I opted for the Xiaomi Mi Robot Vacuum.

Xiaomi Mi Robot Vacuum

Xiaomi Mi Robot Vacuum

I have to say it’s excellent at navigating through the house in each and every nook it can get into, yet not once has it got stuck somewhere.

And the app is pretty good in telling you what the vacuum has done as well as sending you notifications (if you want) each time something happens (e.g. start cleaning, completed, main brush stuck, etc.)

Xiaomi Cleaning House Map

Xiaomi Cleaning House Map

The best part though is that in addition to controlling the vacuum from the Xiaomi app, it can also be integrated into Home-Assistant:

Xiaomi on Home-Assistant

Xiaomi on Home-Assistant

Clicking the button will simply start vacuuming.

I then created a simple automation to initiate the cleaning on specific days/time IF I’m not home.

If only I could also automate emptying the vacuum bin…

Kello Smart Alarm Clock

I have recently taken the plunge and jumped on the kickstarter wagon for the first time.
I successfully backed up a project called Kello.
And after months of anticipation, I finally received the product: a smart alarm clock:

Kello

Kello

Now not only does this alarm look good, but it’s also WiFi and IFTTT enabled and for me that was the major sales point. The plan was to integrate it with my automation setup.

I’ve only had it for about a month and already I’m really impressed with its prowess. The first thing I did was to connect it to IFTTT.

At the time of writing IFTTT is only a beta feature access needs to be requested ([email protected]). They are really responsive and I was granted access within 24h via the use of the TestFlight app on iOS

IFTTT integration currently offers 4 triggers:

  • alarm_start: triggers when an alarm starts ringing.
  • alarm_snooze: triggers when you press snooze.
  • alarm_stop: triggers when you stop the alarm.
  • alarm_soon_-1440, ..., alarm_soon_-120, alarm_soon_-6: the number on the right is the number of seconds before the alarm rings. Only use multiples of 60, up to 1440 seconds (24 minutes) before the alarm rings.

The other interesting bit is that the device can programatically be made to play online content with a one line piece of code:

The URL can be adjusted to play any online content (I’ve not tested all formats). The IP address needs to be the Kello’s IP address (best to set it to static on your router’s DHCP settings)

Armed with the above, I wanted to adjust my weather greeting script so as to play the audio on the Kello. The idea is to have the Kello play its set alarm sound to wake me up, then when I stop the alarm, a rule is triggered to play the weather forecast for the day (I pressed the stop button so I’m awake enough to pay attention to the forecast)

Here is how I did it.

  1. IFTTT:
    1. Go to http://www.ifttt.com/maker_webhooks.
    2. Press on the gear icon on the top right of your screen.
    3. Copy your webhook ID (the text after ‘http://make.ifttt.com/use/’).
  2. Home Assistant:
    1. Add IFTTT with your webhook ID to your configuration.yaml:
    2. Add a new shell command to your configuration.yaml file. Replace the IP with your Kello’s IP address and replace the URL with the address of the weather forecast sound file you want to play (this is created and uploaded separately)
  3. Kello App:
    1. Go to the settings.
    2. Press ‘IFTTT’.
    3. Paste your webhook ID.
  4.  IFTTT:
    1. Create a new Applet.
    2. For the if THIS condition, choose Webhooks.
    3. Click on Receive a web request
    4. For the Event Name, choose one of the event as listed earlier on. I chose alarm_stop
    5. Click on Create trigger
    6. For the then THAT action, choose Webhooks.
    7. Click on Make a web request
    8. Fill in as below, replacing the URL and password with your own (*):

      IFTTT/Kello Applet Settings

      IFTTT/Kello Applet Settings

    9. Click on Create action

(*): To be able to receive events from IFTTT, your Home Assistant instance needs to be accessible from the web. This can be achieved by forwarding port 8123 from your router to the device running Home Assistant.

My next “project” is to mute or stop an alarm from playing if for any reason I’m not home so I don’t disturb anyone. Check this post to see how I did it

How to choose the right CCTV Security Camera

Having trialled “DIY” cameras (using a Webcam taped to the window, or a smartphone taped to the window), I am now looking for a proper solution for my CCTV needs.

I have spent a fair amount of time looking at various cameras and options, and I thought I’d share my findings in case someone else finds it useful.

Points to consider when buying a CCTV camera:

  1. IR Cut Filter
    1. You probably need a camera with an IR Cut Filter to cut IR light during day time, see below the difference.
    2. Some colours are more prone to becoming purple without an IR Cut filter
  2. Lens Size
    1. The biggest problem with CCTV installations is that the wrong lens is chosen. This normally results in people being too small to recognise and with CCTV pictures only being around 40k each, and not the 10 million you get on your photo camera, you cannot electronically zoom in. To be able to recognise a 1.7m person on a standard* CCTV system they must be at least 50% height of screen.
    2. Use the below links to calculate the lens size, or get a vari-focal camera that allows you to adjust the lens size.
      1. http://www.cctv-information.co.uk/i/Choosing_the_Wrong_Lens
      2. http://polarisusa.com/lens-calculator
      3. https://www.pelco.com/partners/tools-calculators/camera-lens-field-of-view-calculator-fov
  3. Resolution
    1. If you want to catch someone’s face or be able to read a number plate, you’ll need a higher resolution, especially if what you’re pointing at is far. Note however that the higher the resolution, the bigger storage space you’ll need. Realistically you’d need at least a Full HD camera so probably looking at a minimum of 2 or 3MP camera.
  4. Position
    1. If you plan on setting your cameras outside, you need to make sure they will withstand the elements. Look for IP66 rated camera
    2. The next thing to consider is how you’re going to power your camera. Even if you were to opt for Wireless cameras (I strongly recommend you don’t), they still need to be powered. I’m opting for a POE (Power Over Ethernet) camera. This means the camera is powered by the network cable, thus saving me having to run power cables to the camera (and sorting loads of extra sockets in a safe place). It also means it’ll reduce interferences due to the data and power cable being potentially too close to each other.
  5. Form Factor
    1. Do you want a dome or bullet form factor?
      Dome is less likely to be knocked off by a burglar (esp. vandal proof versions). Another positive point is that wind won’t make it shake. However depending on the installed position, you may see rain drops that would trigger motion detection. My personal reason though is you won’t see cob web on your videos during night recordings (Spiders have a knack for putting webs on Bullet CCTVs because they generate a bit of heat and are usually nicely placed to catch flies)
  6. PTZ Cameras (Pan-Tilt-Zoom)
    1. These are nice as you can manually change where the camera points at, but realistically you’d either need a compatible application that will control the PTZ movement based on motion detection, or need to set the camera so that it constantly pans back and forth. Personally I can’t see the extra price justification for this unless you have a very wide area to monitor
  7. Night monitoring
    1. Depending on where you want to monitor, if you need night vision you can either chose a camera with IR LEDs (giving you a black and white picture at night), purchase a separate IR flood light (meaning you only buy a standard camera, the IR flood light will provide night IR light based on a photo sensor or movement sensor (PIR). You can always get a regular flood light that will just switch on with movement. LED ones are a bit more pricey but save you money on the long run as they need less power, this is especially interesting if you’re pointing at a busy area like kerb in town
  8. Wireless or Networked, POE?
    1. I personally would not recommend WiFi cameras. They are prone to signal drops and interferences, meaning you’ll end up with green squares / lines every so often which could come at a crucial moment. They can also be hacked or at least made inefficient if targeted by a Wifi jammer/scrambler.
    2. In addition, you will most likely have to drill a hole through the wall if the camera is fixed outside, you may as well run a network cable. If indeed the camera is placed outside, the power adapter connector can be much bigger than the cable itself, requiring a fairly big hole to pass it through.
    3. With this in mind it’s better to opt for a POE (Power Over Ethernet) camera and your hole is the diameter of your cable (you cut the cable to pass it through, then crimp a network connector to plug into the camera). POE will mean a single cable providing power and network connection. It does require a POE switch or at least a POE injector. Depending on how many cameras your setup will be made of, a POE switch might make more commercial sense.
  9. Where to record the videos?
    1. While many CCTV providers and website will try and sell you an NVR (Network Video Recording) device, I personally opted for a camera with a built-in SD card. The video gets recorded on the SD Card, thus decluttering the network and removing potential bottlenecks, while remaining accessible via the network. It also means that should the worst happen, it’s unlikely that the evidence will be stolen: it’s easy to take the NVR box away, much harder to climb up the wall, open the camera and get the SD out or take the camera altogether.
    2. And before you ask, a decent camera will reuse the card once filled, so you don’t run out of space, meaning once the card is full, the older video is deleted to make space for the newer one. The amount of videos recorded (or how far back in time you can go) is only limited by the size of the SD camera. I find my  128GB SD Card on my 4MP camera gives me ~1 month worth of data when only recording motion detected videos (e.g. no 24/7).
    3. You can still use the camera feed for live monitoring. And since most recent cameras offer dual channel, you can use the full resolution to record on the SD card and use a lower resolution for live monitoring so once again you don’t use all your network bandwidth.
  10. Which software to use?
    1. Well this is the million dollar question. Depending on where you save the videos, you may have to use the camera manufacturer’s software (usually browser based application) or you can use third party application that take the video feed in and then perform analysis on it (like motion detection, face recognition etc.). Some manufacturers will also provide an app for your smartphone. I personally use motion which is a good free Linux application. And with a simple web page, you can have a live feed on you computer or smartphone. There are plenty of alternative software options out there if “motion” is not your cup of tea.
  11. Additional guides on how to choose a CCTV based on your needs
    1. http://topcctvcameras.co.uk/buyers-guide-home-cctv-cameras-2015/
    2. http://www.wikihow.com/Choose-a-Suitable-Security-Camera

LED Strip Lights

For a while now I’ve been wanting to add some LED Strips to my setup.

I wanted to get colour changeable strips that I could remotely control via DomotiGa.

I ended up getting 2 controllers based on the customisable H801 chip from AliExpress:

H801

H801

The downside is that I needed an Android Phone to set it up (Connect to my WiFi network), but once done, I no longer need the Android Phone.

In the future I’ll update the firmware to customise it and make it more secure, but for now it works relatively easy.

With advice taken from this post, I managed to create a simple script to send commands to the controller:

  • The first IP address is the address the command is sent from
  • The second IP address is the address of the H801 controller
  • The actual command is made of several parts: 0xfbeb 0000000000 79979d 00:
    • 0xfbeb is constant
    • Next come the hex values for the colours R G B W1 W2 (0000000000)
    • Then comes part of the controller’s MAC Address, in reverse order. The MAC Address is 18:fe:34:9d:97:79
    • The last bit (00) is again constant

This simple method allows me to easily switch the strip on and off and change its colour, and the results are quite impressive:

LED Strip Under TV Cabinet

LED Strip Under TV Cabinet

LED Strip Staircase

LED Strip Staircase

 

Because I have 2 controllers, I wanted to use a single script and parse as an argument the controller number that I wanted to communicate with.

The end result is the below script:

Note: I only soldered the RGB and Vcc pins as I’m not looking to use the white channels, hence the hard coded 0000 in the above script

All I need to do now to change the colour [to purple on the 1st controller) is to call the script as follows:

 

Now to take it to the next level, I created a separate script to slowly run through the colour spectrum. I mainly run it at Christmas so called it LEDStripXmas.py (hence the command in previous script to kill this one if running):

For the below movie, I’ve reduced the wait time (normal cycle takes about 1 min)

I then added the strips as devices in DomotiGa.

They are added as virtual devices, with Value1 being the strip’s status (on|off) and values 2,3,4 carrying the decimal value of the R G B colours respectively:

LED Strips - DomotiGa

LED Strips – DomotiGa

Then all I had to do is to call an action when one of the values of the device changes:

And finally in SmartVISU I added a device:

LED Strip SmartVisu

LED Strip SmartVisu

Clicking on the colour brings the colour picker:

ED Strip SmartVisu Colour Picker

ED Strip SmartVisu Colour Picker

Repurposing an old LCD TV into an interactive wall calendar

Now that I’ve upgraded the living room TV, I’ve moved my old 42” Plasma into our bedroom and I’m now left with a spare 22′ LCD TV.

Until now we had an old school paper wall calendar, mainly for birthdays and anniversaries, but let’s be honest we don’t look at it that often as it’s pretty much static (albeit with the monthly page flip)

I’ve stumbled upon DAKBoard and decided to repurpose my old tv into an interactive wall Calendar.

It’s free to sign up and create your own dashboard. I set up a family calendar in Google, set my location for the weather, and changed the picture setting to pull the live feed from my CCTV.

First I bought a Raspberry Pi Zero W as the “brain” of the new calendar. It would really only be opening the DAKBoard site and that’s pretty much all. No need for a big Raspberry Pi.

Then I installed Raspbian Jessie on it, mounted it so I could edit the WiFi settings thanks to David Maitland’s post. (I have no micro USB to USB adapter so no way of interacting with the Raspberry Pi other than via WiFi, which needs setting up manually).

Once connected to WiFi, I SSH’ed on it to setup the usual VPN (I use TightVNC, not the built in VNC server) and Samba.

Now it’s time to set up DAKBoard to open automatically at startup:

  1. Edit /home/pi/.config/lxsession/LXDE-pi/autostart and add this line. (replace ########### with the key from DAKBoard under Account):

     
  2. install unclutter to hide the mouse:

     
  3. Disable screen blanking so the TV always shows the dashboard:

    insert the below line in the [SeatDefault] block:

     
  4. Disable the screensaver
  5. I then use DomotiGa and one of my LightWaveRF sockets to switch the TV on and off based on motion detection on my PIR
DAKBoard

DAKBoard

In the future I might look into dismantling the TV to get it to fit into a custom frame as per this instructable

[17th March 2017]

If you also plan on using VNC, there’s a chance that DAKBoard launched on the VNC display and not the HDMI display. If that’s the case, stop VNC from starting automatically. With my setup I set:

(see this post for more info on how to setup TightVNC)

Then I simply added a line in /home/pi/.config/lxsession/LXDE-pi/autostart :

 

Syncing Home-Assistant.io and DomotiGa

Having tried Home-Assistant I can see how it can be really powerful once setup (and that’s probably where the issue lies, configuration is too much code driven with no UI at all).

However there are devices that are not yet supported by Home-Assistant (e.g. CurrentCost) and in addition, I can’t have both Home-Assistant and DomotiGa connected to my RFXTrx.

This means I’m looking to use both platforms and find a way to get them to talk to each other.
I already know how to send commands/updates to DomotiGa via JSON-RPC so that will be my first approach.

I’ve created a simple shell command that I use to update devices in DomotiGa:

then in my automations, I call this function with the correct parameters. See below example for my Nest Thermostat (virtual) Device on DomotiGa:

I’ve also tried to install Home-Assistant on my Raspberry Pi as I do like the Web interface, but it’s overkill and take too much overhead when I only need to monitor my GPIO ports. My own script is better in that effect.

Controlling a Sky+HD box

Now that I can reasonably control my TV and my AV Amplifier, I wanted to check whether I could also control my Sky+HD box for further automation (e.g. switch the box off if I switch the TV Off).

Sky+HD Box

Sky+HD Box

After little research I stumbled upon a repository from dalhundal that could do almost exactly that. Only issue at the moment is that this is pretty much a one way function, just like using a physical remote control: I can send commands but don’t receive a status back.

I then added a simple Shell Actions in DomotiGa to send the on/off command:

and the TV Guide button:

 

Next step is to look at this page to see if I can retrieve the box’s status.