Sunteți pe pagina 1din 9

MQTT Alarm Control Panel for Home Assistant

hackster.io /thanksmister/mqtt-alarm-control-panel-for-home-assistant-a206cc

Made by Michael
Ritchie

Things used in this project

Hardware components:

1
Raspberry Pi 3 Model B

1
7" Touchscreen Display for Raspberry Pi

1/9
1
Adafruit Piezo Buzzer

1
Jumper wires (generic)

Software apps and online services:

Google Android Things

Home Assistant

Hand tools and fabrication machines:

3D Printer (generic)

Story
Overview

This project is a MQTT Alarm Control Panel for use with Home Assistant's Manual Alarm Control Panel component.
This project was built using a Raspberry Pi 3 and a 7" touch screen display running Android Things.

Android Things Alarm Control Panel

Home Assistant

Home Assistant is an open source home automation platform with the ability to integrate with many hardware
components as well as offer custom features for automation. Recently, contributor Colin O'Dell added a MQTT
Manual Control Panel which allows for communication between a custom alarm panel and the manual alarm panel
with MQTT.

I wanted an alarm panel which interfaces for Home Assistant's alarm control panel component and gives me the
functionality to control my alarm as well as be mounted near the front door. Using Android Things allowed me to
make a rich user interface and also add additional software features.

In my home I have several Z-Wave door sensors, a motion detector, and siren hooked up to Home Assistant. With
the manual alarm control panel and some automation, I can activate the siren as well send a notification using
IFTTT whenever the alarm is triggered. From my control panel I can arm/disarm the alarm through the interface as I
2/9
enter or leave.

Hardware

Raspberry Pi (needs to be compatible with Android Things)

Touchscreen display, I used a 7" screen but any touch screen compatible with Android Things would work.

Micro SD card to burn the Android Things image

Micro USB cable for power.

Piezo Buzzer (optional if you want button sounds)

Home Assistant Setup

You should be using Home Assistant (v.0.50 or above) which adds the new MQTT Manual Control Panel as well as
having a MQTT component setup and running. I won't go into detail about how to setup Home Assistant or MQTT
because the documentation provided by Home Assistant is better than I could provide. Just be sure you have the
the alarm control panel and MQTT running first, also connect any sensors you might need.

Raspberry Pi Setup

Make sure you properly setup the RPi3 with the 7" Touchscreen Display. You won't need any special software setup
if you use the The Raspberry Pi Foundation 7" Touchscreen as it's compatible with Android Things. Other
compatible touch screens may require additional configuration for Android Things.

There are two ways to setup Android Things and also load the alarm control panel application.

1) The first option is to download the latest build (zip file) from the project's Github release sectionwhich includes
Android Things Preview 0.4.1 with the application already pre-installed. This option also allows you to receive future
OTA updates.

Unzip the file to get the 'iot_rpi3.img'.

Burn image to an SD card using a tool like Etcher.

Insert the SD card into RPi3 and boot.

2) The second option is to setup your RPi3 to use Android Things 0.4.1-devpreview for Raspberry Pi 3 and then
build and install the application manually using Android Studio.

Unzip the file to get the 'iot_rpi3.img'.

Burn image to an SD card using a tool like [Etcher](https://etcher.io/).

Insert the SD card into RPi3 and boot.

Clone the repository and compile the APK using Android Studio, then sideload the APK file onto your device
using the ADB tool.

Be sure to set up network access either using WiFi or ethernet. If you setup WiFi be sure to unplug the Ethernet
cable, at this time Android Things can't use both.

3/9
# Use the adb tool to connect over ethernet to the
device
adb connect Android.local
# Then set your your WiFi SSID and password
adb shell am startservice \
-n com.google.wifisetup/.WifiSetupService \
-a WifiSetupService.Connect \
-e ssid <Network_SSID> \
-e passphrase <Network_Passcode>

You probably also want to set the time and timezone of the device:

# Reboot ADB into root mode


$ adb root
# Set the date to 2017/12/31 12:00:00
$ adb shell date 123112002017.00
# Set the time zone to US Mountain Time
$ adb shell setprop persist.sys.timezone "America/Denver"

Now connect the buzzer as shown in the sample diagram from the Android Things drivers repository. This part is
optional if you want to have sound feedback.

Connecting the PWM Speaker to Raspberry Pi 3

Alarm Application Setup

The complete code for the application running on Android Things can be found in my GitHub repository:
https://github.com/thanksmister/androidthings-mqtt-alarm-panel.

4/9
When you first start the application you will be asked to go to the setting screen and enter your pin code. You also
need to enter the MQTT information that you configured in Home Assistant for your MQTT service. Be sure you
adjust the time intervals to match those set in the Home Assistant MQTT alarm control panel.

Application Settings

The application should then connect to your MQTT broker and display the current state of the alarm control panel in
Home Assistant.

Whenever the state of the alarm control panel in Home Assistant changes, the alarm control panel will reflect those
changes via MQTT communication. In order to deactivate the alarm, you will need to enter you pin code within the
time allowed.

Disable the alarm with the code.


5/9
To set the alarm just select the main icon on the alarm screen and then select Arm Home or Arm Away options.

Select to Arm Home or Arm Away

A small countdown will appear to indicate the time remaining before the alarm is activated.

Countdown showing the time remaining before the alarm is activivated.

If you choose to get weather updates, enter your DarkSky API key and current latitude and longitude in the weather
setting screen. You can get your lat/lon by using maps.google.com and copy them from the url (they look like -
34.6156624,-58.5035102)

To use a Instagram screensaver rather than the digital clock, turn this feature on using screen saver settings. You
6/9
can load other Instagram images by changing the Instagram profile name in the settings.

Enclosure

I used an enclosure to give the alarm a small profile and also to make it wall mountable:
https://www.thingiverse.com/thing:1082431. However, be aware that this case may require extra screws as well as a
longer flex cable. There are plenty of other case options for the RPi 3 / 7" Touchscreen option available.

3D Printed Case

Notes

At this time there is an issue dimming the brightness of the backlight for the display. So for now I have included a
screen saver feature as a short-term fix until the bug is addressed by the Android Things development team. I will
update the application once this feature is working.

There have been multiple display issues using Android Things 0.5.0 and 0.5.1, therefore this application runs best
under Android Things 0.4.1.

It's important that the alarm control panel settings reflect the settings of those used in the alarm control panel
component. Initially the hardware control panel is set to the default settings of the alarm control panel component.

I also created an Android tablet version of the same project that is available on Google Play and as a downloadable
APK file for side loading.

Google Play: https://play.google.com/store/apps/details?id=com.thanksmister.iot.mqtt.alarmpanel8


7/9
Repository: https://github.com/thanksmister/android-mqtt-alarm-panel

Custom parts and enclosures

7in Portable Raspberry Pi Multi-Touch Tablet

3D printable file to enclose the 7" Raspberry Pi Touchscreen and Raspberry Pi 3


CAD file on thingiverse.com

Schematics

PWM Speaker Diagram (Buzzer)

Download
Connecting your buzzer to the Raspberry Pi 3

Code

MQTT Alarm Panel Github Repository

This is a repository with the latest code and release APK and Android Things project files.

thanksmister / androidthings-mqtt-alarm-panel

11

8/9
Android Things Alarm Control Panel for Home Assistant Read More

Latest commit to the master branch on 9-7-2017

Download as zip

Credits

Michael Ritchie

Independent software developer specializing in the development of Android mobile applications.

Contact
Thanks to Colin O'Dell.

Replications
Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

MQTT Alarm Control Panel for Home Assistant


Things
Story
Custom parts and enclosures
Schematics
Code
Credits
Comments(1)
Similar projects

I made oneGive feedback

9/9

S-ar putea să vă placă și