This project has the following functionalities:
- Read GPIO to check for alert on DME station
- Request Divera24/7 WebAPI
Reads GPIO that is specified in config file as input. If GPIO changes from low to high, an alert will be triggered at DIVERA24/7.
A HTTPS GET request is sent to the DIVERA24/7 Web API to trigger an alert. I used the python3 requests bib (installation: pip3 install requests).
The config file is located in the static directory
- hardware: Reading GPIO Port
- webapi: DIVERA24/7 API Key
- request: HTTP GET
The path of the config file is hard coded into the Python script: /opt/divera-pi_alert/static/config.json
This project is using a Raspberry PI3 that is connected with an Oelmann LX4 home station. One GPIO has to be in reading mode and is connected to the relay output of the LX4 home station. If the relay is closed by an alert, the GPIO state changes from LOW to high and a request to DIVERA24/7 Web API is triggered. The reading/input GPIO must be connected to a pull down resistor (e.g. 100kOhm) that connects the GPIO to the Raspberry PI Ground. The GPIO Pin is configured in the config file.
- Git clone Repository into /opt directory
- Execute /opt/divera-pi_alert/static/setup.sh with sudo
- Check SystemD service: systemctl status pialert service
- Change config file and add Auth Token: /opt/divera-pi_alert/static/config.json
- Service restart: systemctl restart pialert
SystemD is used to manage the pialert service. The script setup.sh enables the service to start automatically after booting (systemctl enable pialert).
- Service stop: systemctl stop pialert
- Service start: systemctl start pialert
- Service restart: systemctl restart pialert
A log file should be generated in /opt/divera-pi_alert/pialert.log
.
- After calling the Web API a 120 seconds sleep is implemented
- Alert Type is not set by the API if you use the free version (you have to configure in web GUI)
- RPi ** GPIO: https://de.pinout.xyz/
- DIVERA24/7 ** API: https://www.divera247.com/downloads/divera247_webschnittstelle_zur_alarmierung.pdf
- Python ** Requests: http://www.pythonforbeginners.com/requests/using-requests-in-python ** GPIO: http://raspberrypiguide.de/howtos/raspberry-pi-gpio-how-to/