MQTT Alarm Control Panel for Raspberry Pi and Android

That’s a great solution to the problem. At this time the code is not passed from the android alarm panel to HASS because there was nothing that HASS could do with with code. According to the docs “code (Optional): If defined, specifies a code to enable or disable the alarm in the frontend. This code is not required for MQTT interactions.” So only the front end requires the code, it makes no difference to send the code with the mqtt message.

However, there is no mechanism to process a code sent within the mqtt message by the HASS alarm component. It would require special handling of the payload so you would send {“topic”:“home/set”, “payload”:“disarm|1234”} so you are disarming the alarm with the code 1234". The system would not work now if you sent the code because there is no logic to process it and if the payload is incorrect, you can not change the state of the component.

So at this time there can be no code added to the mqtt message to be sent to home assistant without first updating the manual alarm control panel with mqtt support component to accept codes in some way.

If you want to get the envisalink to work, the code is actually not optional in the backend. In the MQTT config you’re right the code is optional but if i dont define the code in the backend for the envisalink then it wont disarm. It arms perfectly fine. When I put the code in secrets file for the envisalink then it disarms. It would be a great addition to the next release. Thanks for all your hard work.

What is the structure of your MQTT message that you send to envisalink that contains the code. I am curious how to properly structure the MQTT message with the code. Is it an extra parameter, is it contained with the payload as template? Thanks!

It’s actuall an automation script that forces the envisalink alarm to update when the MQTT message is activated. Without the script it only activates that second alarm I was referring to. I can post the script when I get home later today but’s essetially something that updates the wired alarm when the payload ARM_HOME, ARM_AWAY and DISARM are activated. State topics work well too.

If I were to use a firetab with your app, can the app itself ask the firetab to to speak when it’s been armed/disarmed?

The application uses TTS for notifications, so you would send a notification mqtt message with the text you want to speak and its handed off to TTS engine on the device. Check the notification settings in the alarm app.

Unfortunately it looks like there is now a bug in the HASS manual control panel with MQTT support. I ran some tests just looking at the incoming MQTT messages coming from HASS using the following configuration file settings for the manual_mqtt component:

# Manual Alarm
alarm_control_panel:
  - platform: manual_mqtt
    state_topic: home/alarm
    command_topic: home/alarm/set
    pending_time: 60
    trigger_time: 1800
    disarm_after_trigger: false
    delay_time: 30

I have a pending_time of 60 and a delay_time of 30. According to the documentation for the component the “delay_time” is the pending time before triggering the alarm and pending time is the time before state:

delay_time (Optional): The time in seconds of the pending time before triggering the alarm. Default is 0 seconds.
pending_time (Optional): The time in seconds of the pending time before effecting a state change. Default is 60 seconds.

Now here are the timestamps for the incoming MQTT messages with topic/payload:

05-03 10:47:28.074 MQTT topic: home/alarm - payload: disarmed
05-03 10:47:38.969 MQTT topic: home/alarm - payload: armed_home
05-03 10:47:45.668 MQTT topic: home/alarm - payload: pending
05-03 10:48:46.556 MQTT topic: home/alarm - payload: triggered

You can see by the time codes that there is a 60 second delay from the “pending” state until the “triggered” state. After calling the service “alarm_control_panel.alarm_trigger”. I would assume when calling alarm_control_panel.alarm_trigger with a delay of 30 would have 30 seconds of pending time before triggering the alarm, but instead it has 60 seconds. So is the delay time being ignored even if we set specific state values for pending or delay times for armed_away or armed_home states.

It appears that the component is using the “pending_time” rather than the “delay_time” before triggering the alarm. This would seem to be a bug in the component or someone has incorrectly documented the component features.

For now the only workaround is to use the pending time for all state changes and the alarm triggered state. So if you set pending time to 60, then also set the delay times to 60 within the application until this bug is addressed in the HASS component.

I have filed a new issue here: Manual Alarm Control Panel with MQTT Support ignores Delay Times · Issue #14268 · home-assistant/core · GitHub

That is for this @thanksmister it’s just awesome on my pi and 7" touch. Finally go around to building it last night, super easy instructions and setup so thank you!

Just a thought and apologies if I’ve missed this in the documentation. Is it possible to wake the screen over MQTT? I already have a zwave motion sensor in the same location as the panel so id like to avoid adding one to the pi headers.

Also. I’ve setup mailgun which is successfully emailing me the camera images, however I can’t get Telegram to work, checked the API key and the Chat ID but still can’t get it to work.

Also, is there a way of pulling the camera images to somewhere locally? Ftp or something? I’d like to impliment facial recognition in my hallway for a morning TTS announcement depending on who it is. Obviously another machine would be doing all the processing. That one might be a bit of a stretch but thought I’d ask anyway.

Thanks again for this great project!

You can wake the screen with an MQTT notification (speech or alert dialog), there is a setting for this. But this will either show an alert or speak the notification message using TTS. There is no built-in way to wake the screen.

I have both Telegram setup and working, so I would double check your Telegram setup. Try toggling them on or off, maybe there is a hitch some place, but I can verify that it does work.

Camera images are not accessible locally unless its within the application itself. We are running Android OS on the Pi so there may be a way to ssh into the camera storage, but I don’t know how off the top of my head. If you want to do facial recognition on the image then you can probably use the Telegram or MailGun image to send to whatever you are using for facial recognition and then send a MQTT notification back to the alarm panel.

Cool thank you I will try your suggestions. In terms of the local camera storage do you know if the images are stored locally and instantly removed on send? I only have a 8gb SD in the Pi, worried about it filling up.

That’s a good question but we are overwriting the image if I remember correctly. This is to save space and not have the camera storage fill up. I think you can use the Android adb tool to access the camera storage, take a look at this article https://stackoverflow.com/questions/39194080/how-to-pull-photos-with-adb-from-local-storage-android-device. I am assuming it works the same for Android Things but I haven’t tried it.

1 Like

@thanksmister So I got a notification that AndroidThings 1.0 was released today by Google. Anything new in there that would make it worth rebuilding the panel software?

@thanksmister I ended up creating a new Telegram Bot and it worked, for some reason it won’t use the existing one that I use in Home Assistant. Must be a Telegram thing I guess? There is a dash (-) character in my other bot though, maybe it doesn’t like that?

Screen wake works perfectly by sending an MQTT message, thank you.

I’ve noticed that any TTS is spoken 7 times. Is this expected? I can see how it might be useful to repeat an alarm state but maybe the repeat could just be done in the MQTT message? I was hoping to do away with a Chromecast Audio that I’m using in my hallway to TTS weather and traffic reports when I leave the house.

I have a feature request on top of this, sorry :slight_smile: My entire house is using Echo’s / Amazon Polly TTS, would it be possible to add Polly? Obviously this would require users to enter their AWS keys but I would love this feature, if not it would be nice to have Google TTS in other accents (all mine are British)

Thanks again for this, getting close to putting it up on the wall :slight_smile:

Are you sending your messages with retain true as a parameter? Obviously it shouldn’t repeat the message and I will have to check but it sounds like it’s registering the tts multiple times which is causing it to repeat.

For feature requests use the Github project page. The problem is always time for new features as it’s just a side project.

I will look into the TTS repeat issue but remove any retain flag for mqtt notifications and restart the application to unregister any TTS services for now until I issue a fix.

I don’t think there is much new from the latest preview 8 release. However there are some new ways to deal with screen dimming. I am working on day/night theme and updates to screen dimming based on time for the next release. I am also going to update to version 1.0 of Android Things after I have time to test everything.

Hi,

I installed this on an old android phone running Lollipop and I have to say its a great piece of work @thanksmister and a great addition to Home Assistant. And even better, my wife likes it, too!
I think I will get me a cheap Fire Tablet and install it at the wall (phone is too small, screen cracked).
I ran in the 60s delay problem but solved it by setting a 60s countdown. Love that the screen wakes up by mqtt and I also use Tts.

What I could not set up was Telegram. Put my api and the chat id in the settings but nothing…
Did I miss something there? Are there other settings within HA I must have a look at?

Anyway, I dont think Id actually use it. I read someone proposed to take the picture at a different time. Like some seconds after the door was opened, Id second that. A picture of someone who is not entering the code is more useful in my opinion.

Cheers and thanks!

Thanks for the nice comments. I think another user ran into the same Telegram issue and resolved it by generating a new key and chatid without dashes. Try this while I investigate the issue. It could be that it’s encosi the dashes.

2 Likes

I tried that - no success, though.
But as I said its not that important to me. I saw it in the settings and had the Telegram bot up and running, so I gave it a chance.
Maybe Ill setup a Mailgun account when I have some spare time, would be useful to know if that works…

I know its working for me and for others, but I don’t know why its not working in your particular case, my guess is something with the key/chatId when you setup the bot.

FYI you can only have 1 “thing” using the Telegram API at a time. So if HASS is running on a bot, you can’t use the same bot for this, you’d need a separate independent bot. Unless Telegram has changed their API recently.

I am using the same bot for both my HASS Telegram messages and the Alarm Panel Android application and I am receiving messages from both.