Category: Bash

Using Alexa (Amazon Echo / Echo Dot) with 433 Mhz remote power sockets

Requirements

Hardware

  • 433 Mhz remotely-controlled power sockets
    I am using some 10 year old “no name” power sockets. A lot of people recommend Brennenstuhl, but almost any model should just work fine.
    I also use some switches that can be hidden behind your existing wall switches (like the ITDM-250 or ITL-320). Please do not buy these hidden switches if you do not know how to install them, as you need to mess with high voltages.
  • A 433Mhz sender like one of these: https://www.amazon.de/dp/B00OLI93IC/ref=cm_sw_em_r_mt_dp_JUY-ybZXRXYXK
  • An Arduino Nano and an USB cable
  • A Raspberry Pi
    The model of the Pi should not really matter. I am using the Raspberry Pi 1 Model B. Any Raspberry Pi that can be attached to your network while still providing 1 free USB port works fine. A newer Raspberry Pi will speed up the installation of Pimatic which needs to be compiled on the Pi and can take hours.
  • Some tea / coffee and something else to do while pimatic compiles.
  • Of course an Amazon Echo / Echo Dot

Software

  • an updated version of Raspbian for the Raspberry Pi
  • Pimatic
    • Plugins
      • echo
      • homeduino
  • the Arduino IDE to flash the Arduino Nano with homeduino

Demo

Getting started

I will not cover

As there are (far too) many guides on the following points, I will not cover these:

If you follow the guides linked above, you will get some working enviroment.

What belongs where

If you followed all the guides or already have some working enviroment, the last thing to do is to put everything together.

-------------
| Raspberry |-------- Network
|     Pi    |--------
-------------       |
                    |
                -----------
                | Arduino |--------- 433 Mhz Sender
                -----------

It’s pretty simple and pretty straight forward in my opionion.

My Arduino 433MHz sender looks like this:

 

Ein Beitrag geteilt von Jan (@superseriouscat) am

Configuration of pimatic

This is the default configuration:

{
  "//": "Please only change this file when pimatic is NOT running, otherwise pimatic will overwrite your changes.",
  "settings": {
    "httpServer": {
      "enabled": true,
      "port": 80
    },
    "database": {
    }
  },
  "plugins": [
    {
      "plugin": "cron"
    },
    {
      "plugin": "mobile-frontend"
    }
  ],
  "devices": [

  ],
  "rules": [

  ],
  "pages": [
    {
      "id": "favourite",
      "name": "Favourites",
      "devices": []
    }
  ],
  "groups": [

  ],
  "users": [
    {
      "username": "admin",
      "password": "",
      "role": "admin"
    }
  ],
  "roles": [
    {
      "name": "admin",
      "permissions": {
        "pages": "write",
        "rules": "write",
        "variables": "write",
        "messages": "write",
        "events": "write",
        "devices": "write",
        "groups": "write",
        "plugins": "write",
        "updates": "write",
        "database": "write",
        "config": "write",
        "controlDevices": true,
        "restart": true
      }
    }
  ]
}

To enable the Alexa Echo and homeduino integration just add the following lines to the plugin section:

"plugins": [
  {
    "plugin": "cron"
  },
  {
    "plugin": "mobile-frontend"
  },
  {
    "plugin": "homeduino",
    "driver": "serialport",
    "driverOptions": {
      "serialDevice": "/dev/ttyUSB0",
      "baudrate": 115200
    },
    "receiverPin": 0,
    "transmitterPin": 4,
    "rfrepeats": 7,
    "active": true,
    "debug": false
  },
  {
    "plugin": "echo",
  },
],

Do not forget to add the correct serial device, receiverPinbaudrate and transmitterPin.

You should be pretty much done and ready to start pimatic.

Do not forget that pimatic takes an insane amount of time at the first start (due to npm downloading and compiling binaries).

Settings up devices

The device setup depends on your device and the device type. For me the switches were supported by Homeduino and so I used the HomeduinoRFSwitch class. You may need to use a different class or device type.

Example of the configuration of one 433MHz switch:

{
      "protocols": [
        {
          "name": "switch4",
          "options": {
            "unit": 1,
            "id": 2
          },
          "send": true
        }
      ],
      "id": "licht",
      "name": "Licht",
      "class": "HomeduinoRFSwitch",
      "echo": {
        "name": "Licht",
        "additionalNames": [],
        "active": true
      }
    }

This basically adds the switch to pimatic and tells the Echo plugin about its existence. You can do this for each switch manually even if the webinterface does not support it.

Pairing Alexa with pimatic

To pair Alexa and pimatic just go to the devices page on the webinterface:

This will enable pairing mode in pimatic:


If you did everything right, new devices will show up in your Alexa app:

Here you go: You can now control your devices using Alexa without any external API.

New tool: Outgoing port checker

Yesterday I created a new tool, that let’s you check the firewall configuration of your network and other networks for outgoing open ports.

Many public networks do not allow the full port range to be used and figuring out, which ports can be used and which cannot be used, may give you a hard time. This tool allows you to check this directly in your browser.

The host openports.jan.philippi.name listens on all ports for incoming HTTP/s connections and replies on all ports. Clear text HTTP connections will receive a “301 Permanently Moved” HTTP status code. HTTPs connections will receive a “200 OK” status code.

You can find this cool new tool here: https://openports.jan.philippi.name/

Known limitations:

  • A lot of ports are blocked by your browser. Currently it seems like there is no way around it, but you can use different tools like curl, wget, etc. to check this.