update to PIT script and README
This commit is contained in:
@@ -16,7 +16,7 @@ Please also, in a developer's text editor e.g. NotePad++ or Microsoft Visual Stu
|
|||||||
* Register for [DuckDNS](https://www.duckdns.org/) and have your subdomain name and token ready
|
* Register for [DuckDNS](https://www.duckdns.org/) and have your subdomain name and token ready
|
||||||
* Make sure ports 80 and 443 are accessible on your host machine and your machine has a connection to the Internet
|
* Make sure ports 80 and 443 are accessible on your host machine and your machine has a connection to the Internet
|
||||||
* Copy .env.template to .env with `cp .env.template .env` *DO NOT COMMIT AND PUSH .env TO A PUBLIC GIT REPOSITORY UNLESS YOU WANT TO GET HACKED!!!*
|
* Copy .env.template to .env with `cp .env.template .env` *DO NOT COMMIT AND PUSH .env TO A PUBLIC GIT REPOSITORY UNLESS YOU WANT TO GET HACKED!!!*
|
||||||
* Edit the files .env, .configs/traefik.toml, and .configs/grafana.ini, updating configuration values with your desired configuration
|
* Edit the files .env and .configs/grafana.ini, updating configuration values with your desired configuration
|
||||||
* Run `docker-compose config` from this directory to doublecheck that docker-compose.yaml file contains no syntax errors and that all your options from .env were correctly filled in
|
* Run `docker-compose config` from this directory to doublecheck that docker-compose.yaml file contains no syntax errors and that all your options from .env were correctly filled in
|
||||||
|
|
||||||
## Creating Your Stack
|
## Creating Your Stack
|
||||||
@@ -32,6 +32,7 @@ To Stop or (re)Start a container in your stack without removing it, run `docker-
|
|||||||
Run the following commands to update the images your containers use and recreate/restart the containers using them
|
Run the following commands to update the images your containers use and recreate/restart the containers using them
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
docker-compose build
|
||||||
docker-compose pull
|
docker-compose pull
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import sys
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from concurrent.futures import ThreadPoolExecutor, CancelledError, wait
|
from concurrent.futures import ThreadPoolExecutor, CancelledError, wait
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from queue import Queue
|
from queue import SimpleQueue
|
||||||
|
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
|
||||||
@@ -30,11 +30,11 @@ Base = declarative_base()
|
|||||||
class PIR_Detection(Base):
|
class PIR_Detection(Base):
|
||||||
__tablename__ = "PIRSTATS"
|
__tablename__ = "PIRSTATS"
|
||||||
|
|
||||||
time = Column('datetime', DateTime, nullable=False, primary_key=True)
|
timestamp = Column('timestamp', DateTime, nullable=False, primary_key=True)
|
||||||
count = Column('count', Integer, nullable=False)
|
count = Column('count', Integer, nullable=False)
|
||||||
|
|
||||||
|
|
||||||
Detection=collections.namedtuple("Detection", ['time','count'])
|
Detection=collections.namedtuple("Detection", ['timestamp','count'])
|
||||||
|
|
||||||
class PIRgate:
|
class PIRgate:
|
||||||
def __init__(self, hostname, username, password, database):
|
def __init__(self, hostname, username, password, database):
|
||||||
@@ -46,7 +46,7 @@ class PIRgate:
|
|||||||
GPIO.setup(self.PIR_PIN, GPIO.IN)
|
GPIO.setup(self.PIR_PIN, GPIO.IN)
|
||||||
# End GPIO setup
|
# End GPIO setup
|
||||||
self._pool=ThreadPoolExecutor()
|
self._pool=ThreadPoolExecutor()
|
||||||
self._detection_queue=Queue()
|
self._detection_queue=SimpleQueue()
|
||||||
if not hostname:
|
if not hostname:
|
||||||
stdout,stderr = subprocess.Popen(['docker',
|
stdout,stderr = subprocess.Popen(['docker',
|
||||||
'inspect',
|
'inspect',
|
||||||
@@ -80,7 +80,7 @@ class PIRgate:
|
|||||||
try:
|
try:
|
||||||
detection = self._detection_queue.get()
|
detection = self._detection_queue.get()
|
||||||
session = self.Session()
|
session = self.Session()
|
||||||
session.add(PIR_Detection(time=detection.datetime, count=detection.count))
|
session.add(PIR_Detection(timestamp=detection.timestamp, count=detection.count))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
create table if not exists PIRSTATS (
|
|
||||||
datetime DATETIME not NULL,
|
|
||||||
gatecount INT,
|
|
||||||
PRIMARY KEY (datetime)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table if not exists ULTRASTATS (
|
|
||||||
datetime DATETIME not NULL,
|
|
||||||
gatecount INT,
|
|
||||||
PRIMARY KEY (datetime)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table if not exists LDRSTATS (
|
|
||||||
datetime DATETIME not NULL,
|
|
||||||
gatecount INT,
|
|
||||||
PRIMARY KEY (datetime)
|
|
||||||
);
|
|
||||||
Reference in New Issue
Block a user