View on GitHub

androidthings-mqtt-alarm-panel

Android Things Alarm Control Panel for Home Assistant

Android Things Alarm Panel for Home Assistant

NOTE: This project is no longer being developed. Google has decided not to support the RPi for Android Things. Android Things no longer works on the new RPi 3 B+ and will only work on RPi 3 devices. Google has also shifted away from Android Things to Chrome OS, which they use for their new Google Home tablet devices. However, this project will continue to work for the older RPi 3 devices.

Join the ThanksMister Community to ask questions or share any helpful information about this project.


This project is a MQTT Alarm Control Panel for use with Home Assistant’s Manual Alarm Control Panel component. However, the application can be used with any home automation platform that supports the MQTT messaging protocol such as OpenHab, Node-RED, or cloud-based MQTT services. This project was built using a Raspberry Pi 3 and a 7” Touchscreen display running Android Things.

alarm_panel

The alarm control panel acts as an interface for your own home alarm system and allows for two way communication using MQTT messaging. You can set the alarm state to away or home, or disarm the alarm using a code. Your home automation system will controls the sensors or automation that triggers the siren or notifies users of possible intrusion.

To use the application with Home Assistant, you need to use the Home Assistant’s Manual Alarm Control Panel component and have the MQTT service setup and configured. In the alarm control panel application you enter your MQTT broker address, port number, and credentials if necessary. If you are using an automation system other than Home Assistant, you will need to use the same publish states and commands in your setup.

Support

For issues, feature requests, comments or questions, use the Github issues tracker. For HASS specific questions, you can join the Home Assistant Community Dsicussion page which already has a lot information from the community.

Features

Supported Command and Publish States

Hardware

Software to Build from Codebase (only if building from code)

Home Assistant Setup

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 options for installing the setting up your RPi 3 and installing the application.

# 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>
# 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"

Device Settings

Alarm Setup

Alarm Application Setup

When you first start the application you will be asked to go to the setting screen to setup the device. 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. Alsop reset your alarm pin code, the default is 1234.

alarm_settings

The application should then connect to your MQTT broker. Whenever the state of the alarm control panel in in Home Assistant chances, the alarm control panel will reflect those changes. You need to enter you pin code whenever you want to disarm the alarm or if the alarm has been triggered.

alarm_home

alarm_disarm

alarm_triggered

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

alarm_arm

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

alarm_pending

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).

alarm_weather

You can also load your home automation platfgorm website by entering the address with port into the settings. It slides from the right on the main screen.

platform_panel

To use a screen saver other than the black, turn this feature on in the screen saver settings.

PIR Sensor (Optional)

If you would like the alarm panel to awake when motion is detected then add a PIR sensor following the Fritzing diagram provided.

pir_rpi3_bb

Weather Updates (Darksky)

If you would like to get weather updates, create and enter a Dark Sky API key and your current latitude and longitude into the weather setting screen. You can get your current location by using maps.google.com in a web browser and copying the lat/lon from the url (they look like -34.6156624,-58.5035102 in the url).

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

Capture Images (Telegram/Mailgun)

If you would like to capture and email images when the alarm is deactivated then you will need a camera that works with Raspberry Pi 3 (I am using the Raspberry Pi Camera Module v2).

To receive an email with the captured image, you also need to setup a Mailgun account. You will need to enter the domain address and API key from your Mailgun account into the application setting screen along with other information.

You may also use Telegram to receive a notification with the image when the alarm is deactivated. To use Telegram you need a chat Id and a Telegram Bot API token. Follow the Telegram guide on Home Assistant to setup Telegram. Enter the chat Id and token into the application settings screen.

The camera only captures images when activated in the settings and MailGun is setup properly. Images are captured each time the alarm is deactivated. You may use either Mailgun, Telegram, or both to send notifications.

Screensaver

To use a screen saver other than the digital clock, turn this feature on in the screen saver settings. You will need an Imgur key and a tag for which images you would like to use from Imgur Client Id

Platform Screen

You can load your Home Assistant (or any web page) as alternative view by entering your Home Assistant address. The address shuold be in the format http://192.168.86.240:8123 and include the port number. You can use HADashboard or Home Assistant kiosk mode as well.

This feature uses an Android web view component and may not work on older SDK versions. There is also a limitation when saving username/passwords and screen reloading. The username/passwords are not rememebered, and you will need to login again. I recommend using this application as on a dedicated tablet rather than your day-to-day device for best results.

Enclosure

Originally I 3D printed an enclosure: https://www.thingiverse.com/thing:1082431. However, I ended up you want to buying a SmartPi Touch case which is a great option especially if you have the Camera Module v2.

Notes

Acknowledgements

Special thanks to Colin O’Dell who’s work on the Home Assistant Manual Alarm Control Panel component and his MQTT Alarm Panel helped make this project possible. Thanks to Juan Manuel Vioque for Spanish translations and Gerben Bol for Dutch translations and Jorge Assunção for Portuguese.