Giter Club home page Giter Club logo

alarmpi's Introduction

AlarmPI Build Status GitHub release (latest by date)

AlarmPI is a home security system based on Raspberry PI. It supports wired sensors (PIR, Magnetic etc.) and wireless through MQTT or Hikvision. It is controlled with a Web UI, a Android Application, or through HTTP & MQTT messages. When the alarm detects movement, it supports the following events:

  • Enables the Siren
  • Send Mail
  • VoIP Calls
  • Send MQTT message

It is written in python and supports both python 2.7 & python 3.6. There is also the option of having more than one user by editing the server.json file accordingly.

Installation

With this command on your terminal you can install and update the application with my latest commit.

bash <(curl -s "https://raw.githubusercontent.com/bkbilly/AlarmPI/master/install.sh")

Usage

Web UI

The Web Interface of the alarm has all the features that are needed to configure and use the home security. It supports real time events of the sensors, the logs and their status. It also works as an smartphone application from the browser: Add to Home screen

Mobile Application

The android application is very light and fast and it is recomended for the phone, but it has no real time updates. You can download it from here: Play Store

The source code for the application is here: https://github.com/bkbilly/AlarmPI-Android

Snips

Through voice commands from Snips platform using this application: snips console

Home-Assistant

It is also controlled with MQTT commands with the Home-Assistant component: 'MQTT Alarm Control Panel'. On Home-Assistant the configuration is like so:

alarm_control_panel:
  - platform: mqtt
    name: "AlarmPI"
    state_topic: "home/alarm"        # The State Topic from AlarmPI
    command_topic: "home/alarm/set"  # The Command Topic from AlarmPI
    payload_arm_home: "ARM_HOME"     # This is not used
    payload_arm_away: "ARM_AWAY"

API

HTTP

MQTT

These are the possible mqtt messages. First you will have to setup the MQTT state_topc & command_topic.

  • home/alarm/set [ARM_HOME,ARM_AWAY,ARM_NIGHT,DISARM,PENDING]
  • home/alarm/set/siren {"state": "ON"}
  • home/alarm/set/sensor/test1 [off,online]
  • home/alarm/sensor/test1 [off,on,error]
  • home/alarm [armed_away,disarmed,triggered]

Supports custom messages subscriptions on MQTT Sensors by filling the appropriate information about topic and payload on sensor settings. This can be used for cases like zigbee2mqtt so that zigbee devices can be used. The payload must be a python function with the payload stored as message like this:

  • message['contact'] == 'ON'

IFTTT

It can also be used with IFTTT using the Webhooks module like this: https://admin:[email protected]:5000/activateAlarmOnline https://admin:[email protected]:5000/deactivateAlarmOnline

My personal favourite is to control it with Google Assistant.

SipCall (VoIP)

I have built the sipcall for the Raspberry Pi, so hopefully you will not have to build it yourself. To test it, execute this replacing the (myserver, myusername, mypassword, mynumbertocall):

./sipcall -sd myserver -su myusername -sp mypassword -pn mynumbertocall -s 1 -mr 2 -ttsf ../play.wav

alarmpi's People

Contributors

bkbilly avatar dependabot-preview[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alarmpi's Issues

System does not login

Describe the problem
I thank everyone who makes this system, I installed alarmpi without errors, I put a difficult password, but both in the login of the browser itself on localhost and of another machine with the raspibery ip I cannot log in, simply nothing happens, and not even a message from error happens, I reinstalled the system and put a simple password and still does not login

OS Version
Raspbery pi OS 32bits

AlarmPI version
4.7

Error Logs
no logs

Hardcoded secret key

Hello AlarmPI developers,

We are a cybersecurity research group from the CISPA Helmholtz Center for Information Security and Ca’ Foscari University of Venice. We recently conducted an analysis of the session management used in your web application as part of our research. We have discovered a security vulnerability that we believe requires your attention.

Vulnerability Description:

After our analysis, we have identified that your application is using a hard-coded secret key that is leaked through GitHub. If operators who install your web application do not change this secret key, they are vulnerable to cookie forgeries. The cookie forgery attack allows an attacker, knowing the key used to sign a cookie, to forge new arbitrary cookies to impersonate and take over other accounts.

self.app.secret_key = 'super secret string'

Recommendation for Mitigation:

To address this vulnerability and enhance the security posture of your web application, we highly recommend setting the secret key from an environment variable. If the environment file is not shared on GitHub then this would force operators of your application to create their own key upon installation, forcing them to set their own secure secret key.

We hope this notification helps improve your security. Should you have further questions or comments on this feel free to answer this thread or reach out to [email protected].

Kind regards,
Florian Hantke

Voip Issue

Firstly this is an amazing project.

I am running into an issue with Voip

I use a voip server using MiniSipServer running on a VPS Server I connected number 101 to my phone and 100 to the alarmpi

When an intruder alarm is activated it says Calling 101 and immediately says Call Ended. Without trying to call . Any ideas how to resolve this issue?

Also a suggest If you are interested Add a delay arm setting and allow user to set how many seconds he has until he leaves the house etc. And also door delay for example set in x zone to allow x seconds to disarm else sound alarm

Thank you very mutch and looking forward hearing from you.

Μπορεις να επικοινωνήσεις μαζι μου μέσω viber αμ χρειάζεσαι περισσότερες πληροφορίες στο 6948531588

Not running

i m getting this error
sudo service alarmpi status
cat: /var/run/alarmpi/alarmpi.pid: No such file or directory
AlarmPI not running.

Alarmpi service failed to start

Yesterday fresh installed alarmpi on raspberry pi 4, the installation went without error.
When tried to start the program the alarm pi service failed with the following error

● alarmpi.service - AlarmPI
Loaded: loaded (/etc/systemd/system/alarmpi.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-11-10 02:08:43 GMT; 6h ago
Process: 366 ExecStart=/usr/bin/python3 /opt/AlarmPI/run.py (code=exited, status=1/FAILURE)
Main PID: 366 (code=exited, status=1/FAILURE)
CPU: 1.316s

Nov 10 02:08:43 raspberrypi python3[366]: File "/opt/AlarmPI/run.py", line 7, in
Nov 10 02:08:43 raspberrypi python3[366]: from alarmcode.alarmpi import AlarmPiServer
Nov 10 02:08:43 raspberrypi python3[366]: File "/opt/AlarmPI/alarmcode/alarmpi.py", line 8, in
Nov 10 02:08:43 raspberrypi python3[366]: from flask_socketio import SocketIO, join_room
Nov 10 02:08:43 raspberrypi python3[366]: File "/usr/local/lib/python3.9/dist-packages/flask_socketio/init.py", line 24, in
Nov 10 02:08:43 raspberrypi python3[366]: from werkzeug.serving import run_with_reloader
Nov 10 02:08:43 raspberrypi python3[366]: ImportError: cannot import name 'run_with_reloader' from 'werkzeug.serving' (/usr/local/lib/python3.9/dist-packages/werkzeug/serving.py)
Nov 10 02:08:43 raspberrypi systemd[1]: alarmpi.service: Main process exited, code=exited, status=1/FAILURE
Nov 10 02:08:43 raspberrypi systemd[1]: alarmpi.service: Failed with result 'exit-code'.
Nov 10 02:08:43 raspberrypi systemd[1]: alarmpi.service: Consumed 1.316s CPU time.

I installed alarm pi on my ubuntu desktop to verify, which also failed with the same error.

Please look at the problem and I am glad to hear your suggestions.

Thanks in advance

Service won't run, can't access web interface

pi@HomeAlarm:~ $ sudo systemctl status alarmpi
● alarmpi.service - AlarmPI
Loaded: loaded (/etc/systemd/system/alarmpi.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2023-10-08 15:04:31 ADT; 41s ago
Process: 8389 ExecStart=/usr/bin/python3 /opt/AlarmPI/run.py (code=exited, status=1/FAILURE)
Main PID: 8389 (code=exited, status=1/FAILURE)
CPU: 939ms

Oct 08 15:04:31 HomeAlarm python3[8389]: from alarmcode.alarmpi import AlarmPiServer
Oct 08 15:04:31 HomeAlarm python3[8389]: File "/opt/AlarmPI/alarmcode/alarmpi.py", line 7, in
Oct 08 15:04:31 HomeAlarm python3[8389]: from flask import Flask, send_from_directory, request, Response, redirect, render_template
Oct 08 15:04:31 HomeAlarm python3[8389]: File "/usr/local/lib/python3.9/dist-packages/flask/init.py", line 5, in
Oct 08 15:04:31 HomeAlarm python3[8389]: from .app import Flask as Flask
Oct 08 15:04:31 HomeAlarm python3[8389]: File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 30, in
Oct 08 15:04:31 HomeAlarm python3[8389]: from werkzeug.urls import url_quote
Oct 08 15:04:31 HomeAlarm python3[8389]: ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.9/dist-packages/werkzeug/urls.py)
Oct 08 15:04:31 HomeAlarm systemd[1]: alarmpi.service: Main process exited, code=exited, status=1/FAILURE
Oct 08 15:04:31 HomeAlarm systemd[1]: alarmpi.service: Failed with result 'exit-code'.

I am running latest version of AlarmPI

I am running Raspian 11 Bullseye

when I first ran cd /opt/AlarmPI/ && git rev-parse HEAD
I got fatal: detected dubious ownership in repository at '/opt/AlarmPI'
To add an exception for this directory, call:
git config --global --add safe.directory /opt/AlarmPI
Which I did and then got
351a058

Error Logs
Provide the log output from the following command:
cat /opt/AlarmPI/sysrun.log
(cat: /opt/AlarmPI/sysrun.log: No such file or directory)

Configuration

Cannot connect via https

Describe the problem
Hi, I have problem right after installation - installation went OK with no issue, after that, I cannot load web page for configuring.. tryied https/http variant, various ports and logins, nothing worked.. I have raspberry 3B

localhost address giving me:
This site can’t be reached
192.168.1.110 refused to connect

Code after running main script:

pi@raspberrypi:/opt/AlarmPI $ sudo python3 run.py
Exception in thread Thread-1:
2024-03-29 23:13:57 [INFO] [notifier:__init__:445]  ------------ INIT FOR DOOR SENSOR CLASS! ----------------
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
Exception ignored in: <function Client.__del__ at 0x751f9928>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 874, in __del__
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._reset_sockets()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._target(*self._args, **self._kwargs)
  File "/opt/AlarmPI/alarmcode/logs.py", line 83, in trimLogFile
    with open(self.logfile, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/AlarmPI/alert.log'
    self._sock_close()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
2024-03-29 23:13:57 [ERROR] [run:<module>:53]  Unknown error has occured Contact Author:
Traceback (most recent call last):
  File "/opt/AlarmPI/run.py", line 50, in <module>
    myserver.startMyApp()
  File "/opt/AlarmPI/alarmcode/alarmpi.py", line 367, in startMyApp
    self.users[user]['obj'] = Worker(
  File "/opt/AlarmPI/alarmcode/Worker.py", line 44, in __init__
    self.mynotify = Notify(self.wd, self.settings, self.optsUpdateUI, self.mylogs)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 449, in __init__
    self.mqtt = notifyMQTT(self.settings, self.optsUpdateUI, self.mylogs, self.callbacks)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 103, in __init__
    self.setupMQTT()
  File "/opt/AlarmPI/alarmcode/notifier.py", line 122, in setupMQTT
    self.mqttclient = mqtt.Client(client_id=str(random.randint(1,10000)), clean_session=False)
TypeError: __init__() missing 1 required positional argument: 'callback_api_version'

OS Version

pi@raspberrypi:/opt/AlarmPI $ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

AlarmPI version

pi@raspberrypi:/opt/AlarmPI $ sudo git rev-parse HEAD
5f7beedc8e3ce2a283912becc427d21cf7b1276a

Error Logs - last run after restart

2024-03-29 23:17:22 [INFO] [notifier:__init__:445]  �[95m------------ INIT FOR DOOR SENSOR CLASS! ----------------�[0m
2024-03-29 23:17:22 [ERROR] [run:<module>:53]  Unknown error has occured Contact Author:
Traceback (most recent call last):
  File "/opt/AlarmPI/run.py", line 50, in <module>
    myserver.startMyApp()
  File "/opt/AlarmPI/alarmcode/alarmpi.py", line 367, in startMyApp
    self.users[user]['obj'] = Worker(
  File "/opt/AlarmPI/alarmcode/Worker.py", line 44, in __init__
    self.mynotify = Notify(self.wd, self.settings, self.optsUpdateUI, self.mylogs)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 449, in __init__
    self.mqtt = notifyMQTT(self.settings, self.optsUpdateUI, self.mylogs, self.callbacks)
  File "/opt/AlarmPI/alarmcode/notifier.py", line 103, in __init__
    self.setupMQTT()
  File "/opt/AlarmPI/alarmcode/notifier.py", line 122, in setupMQTT
    self.mqttclient = mqtt.Client(client_id=str(random.randint(1,10000)), clean_session=False)
TypeError: __init__() missing 1 required positional argument: 'callback_api_version'

Configuration

{
  "http": {
    "enable": false,
    "host": "",
    "https": true,
    "password": "",
    "port": 443,
    "username": "test1"
  },
  "mail": {
    "enable": false,
    "messageBody": "Alert",
    "messageSubject": "Home Security",
    "password": "",
    "recipients": [],
    "smtpPort": 587,
    "smtpServer": "smtp.gmail.com",
    "username": ""
  },
  "mqtt": {
    "authentication": false,
    "command_topic": "home/alarm2/set",
    "enable": false,
    "host": "",
    "password": "",
    "port": 1883,
    "state_topic": "home/alarm2",
    "username": "",
    "homeassistant": false
  },
  "sensors": {},
  "serene": {
    "enable": false,
    "http_start": "",
    "http_stop": "",
    "pin": 14
  },
  "settings": {
    "alarmState": "disarmed",
    "timezone": "Europe/Athens",
    "trim": 1000
  },
  "voip": {
    "domain": "",
    "enable": false,
    "numbersToCall": [],
    "password": "",
    "timesOfRepeat": "",
    "username": ""
  }
}

Thanks in advance.
I really like your work, hope I can run it sometime :) 👍

cannot import name 'run_with_reloader' from 'werkzeug.serving', rpi os bullseye 32 bit

OS Version
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

AlarmPI version
8106769
*Latest, just installed

Error Logs

 No such file
instead, I will show the output of `sudo systemctl status alarmpi`

image

Configuration

{
    "http": {
        "enable": false,
        "host": "",
        "https": true,
        "password": "",
        "port": 443,
        "username": "test1"
    },
    "mail": {
        "enable": false,
        "messageBody": "Alert",
        "messageSubject": "Home Security",
        "password": "",
        "recipients": [],
        "smtpPort": 587,
        "smtpServer": "smtp.gmail.com",
        "username": ""
    },
    "mqtt": {
        "authentication": false,
        "command_topic": "home/alarm2/set",
        "enable": false,
        "host": "",
        "password": "",
        "port": 1883,
        "state_topic": "home/alarm2",
        "username": "",
        "homeassistant": false
    },
    "sensors": {
    },
    "serene": {
        "enable": false,
        "http_start": "",
        "http_stop": "",
        "pin": 14
    },
    "settings": {
        "alarmState": "disarmed",
        "timezone": "Europe/Athens",
        "trim": 1000
    },
    "voip": {
        "domain": "",
        "enable": false,
        "numbersToCall": [],
        "password": "",
        "timesOfRepeat": "",
        "username": ""
    }
}

Mqtt and Home assistant

Describe the problem

OS Version

AlarmPI version

Error Logs

Configuration

HI.
could you be clearer how to configure the anti-theft and the mqtt file in home assistant to have all the features?
i managed to interface it once but after a raspberry reboot, mqtt communication was lost and never came back.
when there was communication, every time I entered as home assistant, the burglar alarm automatically excluded any sensor programmed inside it.
i installed the latest updated version on raspberry pi os lite 64 bit ( Raspberry Pi 3a+)
I am not getting any errors from the OS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.