mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-07 16:14:01 +02:00
Space API SFTP upload config
This commit is contained in:
parent
de2e46d6d3
commit
534afb2d8c
4 changed files with 56 additions and 1 deletions
|
@ -34,11 +34,12 @@ You need just to run `make`. Additional dependencies:
|
|||
- [SWIG](http://www.swig.org/)
|
||||
- [WiringPi2 pythonic binding](https://github.com/WiringPi/WiringPi2-Python) (for switching lock on Raspberry)
|
||||
- [python-irc](https://pypi.python.org/pypi/irc) >= 16.0, use "pip install irc", the one in repos is old
|
||||
- [pysftp](https://pypi.org/project/pysftp/) - for uploading SpaceAPI-formatted status to some host
|
||||
|
||||
All dependencies can be installed on Ubuntu or Debian/Raspbian via:
|
||||
|
||||
apt install libnfc-dev libfreefare-bin libfreefare-dev python-axolotl-curve25519 swig2.0 python-dev
|
||||
pip install irc wiringpi2
|
||||
pip install irc wiringpi2 pysftp
|
||||
|
||||
To build, just run make:
|
||||
|
||||
|
|
|
@ -66,7 +66,28 @@ reconnect_delay = 300
|
|||
# fi
|
||||
#
|
||||
# python -c "import wiringpi; wiringpi.wiringPiSetupGpio(); wiringpi.pinMode($PIN, wiringpi.INPUT); wiringpi.pullUpDnControl($PIN, wiringpi.PUD_UP)"
|
||||
#
|
||||
# SpaceAPI upload is to upload JSON-formatted status to a SFTP server where it can be hosted via web.
|
||||
#
|
||||
# spaceapi_status_upload = True/False whether to use SFTP upload
|
||||
# spaceapi_sftp_host = hostname where to upload the key
|
||||
# spaceapi_sftp_port = port of sftp server
|
||||
# spaceapi_sftp_username = username for the sftp server
|
||||
# spaceapi_sftp_key = full path to SFTP (SSH) key
|
||||
# spaceapi_dest_file = path relative to SFTP root, including final the filename (it's recommended to use chroot with internal-sftp)
|
||||
# spaceapi_template_file = full path to JSON template file, where status (open/closed) will be added
|
||||
#
|
||||
# Note: for sftp upload to work, you need to have the server in ~/.ssh/known_hosts, otherwise you'll get exception
|
||||
|
||||
|
||||
enabled = False
|
||||
status_file = /sys/class/gpio/gpio22/value
|
||||
open_value = 0
|
||||
spaceapi_status_upload = False
|
||||
spaceapi_sftp_host = some.fqdn.com
|
||||
spaceapi_sftp_port = 22
|
||||
spaceapi_sftp_username = brmdoor-web
|
||||
spaceapi_sftp_key = /path/to/key
|
||||
spaceapi_dest_filen= /path/on/target/host/to/dest/file
|
||||
spaceapi_template_file = /full/path/to/spaceapi_template.json
|
||||
|
||||
|
|
|
@ -71,6 +71,14 @@ class BrmdoorConfig(object):
|
|||
if self.useOpenSwitch:
|
||||
self.switchStatusFile = self.config.get("open_switch", "status_file")
|
||||
self.switchOpenValue = self.config.get("open_switch", "open_value")
|
||||
self.useStatusUpload = self.config.getboolean("open_switch", "spaceapi_status_upload ")
|
||||
if self.useStatusUpload:
|
||||
self.sftpHost = self.config.get("open_switch", "spaceapi_sftp_host")
|
||||
self.sftpPort= self.config.getint("open_switch", "spaceapi_sftp_port")
|
||||
self.sftpUsername = self.config.get("open_switch", "spaceapi_sftp_username")
|
||||
self.sftpKey = self.config.get("open_switch", "spaceapi_sftp_key")
|
||||
self.sftpDestFile = self.config.get("open_switch", "spaceapi_sftp_key")
|
||||
self.sftpTemplateFile = self.config.get("open_switch", "spaceapi_template_file")
|
||||
|
||||
def convertLoglevel(self, levelString):
|
||||
"""Converts string 'debug', 'info', etc. into corresponding
|
||||
|
@ -355,6 +363,14 @@ class IrcThread(threading.Thread):
|
|||
logging.exception("Exception in IRC thread")
|
||||
time.sleep(self.reconnectDelay)
|
||||
|
||||
class SpaceAPIUploader(object):
|
||||
"""
|
||||
Class for uploading JSON-formatted SpaceAPI status via SFTP
|
||||
"""
|
||||
|
||||
def __init__(self, config):
|
||||
pass
|
||||
|
||||
class OpenSwitchThread(threading.Thread):
|
||||
"""
|
||||
Class for watching OPEN/CLOSED switch that
|
||||
|
|
17
spaceapi_template.json
Normal file
17
spaceapi_template.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"api": "0.13",
|
||||
"space": "Brmlab",
|
||||
"logo": "https://brmlab.cz/brmlab.png",
|
||||
"url": "https://brmlab.cz/",
|
||||
"location": {
|
||||
"address": "Pod Kaplickou 3149/18, 13000 Praha 3",
|
||||
"lon": 50.08346,
|
||||
"lat": 14.48032
|
||||
},
|
||||
"contact": {
|
||||
"irc": "irc://freenode.net/#brmlab",
|
||||
"phone": "+420 608 801 582",
|
||||
"facebook": "https://www.facebook.com/brmlab",
|
||||
"ml": "brmlab@brmlab.cz"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue