just some more things
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from flask import Flask, render_template, make_response
|
||||
|
||||
app = Flask(__name__)
|
||||
@app.route("/")
|
||||
def index():
|
||||
pass
|
||||
@@ -0,0 +1,9 @@
|
||||
#! /usr/bin/python3
|
||||
|
||||
import logging
|
||||
import sys
|
||||
logging.basicConfig(stream=sys.stderr)
|
||||
sys.path.insert(0, '/home/pi/RaspberryPie/RaspberryPie/')
|
||||
from flask_backend import app as application
|
||||
|
||||
application.secret_key = "Whatever"
|
||||
@@ -19,6 +19,9 @@ import Adafruit_DHT
|
||||
from picamera import PiCamera
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
# imports from project
|
||||
import RaspberryPie.tasks
|
||||
|
||||
|
||||
config = configparser.RawConfigParser()
|
||||
config.read("config.cfg") # edit this file for your specific configuration
|
||||
@@ -105,6 +108,7 @@ class MajGenApiTelecom:
|
||||
MajGenApiTelecom.delete_mail(id)
|
||||
|
||||
def __init__(self, email_function, dropbox_function):
|
||||
# using functions so in future, the storing can "easily" made more secure (not always stored in memory hopefully)
|
||||
self.email_function = email_function
|
||||
self.dropbox_function = dropbox_function
|
||||
self.mail_config = config["Mail"]
|
||||
@@ -209,11 +213,13 @@ class MajGenGPIOController:
|
||||
GPIO.cleanup()
|
||||
|
||||
def close(self):
|
||||
self.kill()
|
||||
GPIO.output(self.pinClose, GPIO.LOW)
|
||||
GPIO.output(self.pinOpen, GPIO.HIGH)
|
||||
captScribe.info("GPIO set to closing", "MajGenGPIOControl.close")
|
||||
|
||||
def open(self):
|
||||
self.kill()
|
||||
GPIO.output(self.pinClose, GPIO.HIGH)
|
||||
GPIO.output(self.pinOpen, GPIO.LOW)
|
||||
captScribe.info("GPIO set to opening", "MajGenGPIOControl.open")
|
||||
@@ -221,6 +227,7 @@ class MajGenGPIOController:
|
||||
def kill(self):
|
||||
GPIO.output(self.pinClose, GPIO.HIGH)
|
||||
GPIO.output(self.pinOpen, GPIO.HIGH)
|
||||
time.sleep(.5) # waiting, so relay definetly has switched
|
||||
captScribe.info("GPIO switched off", "MajGenGPIOControl.kill")
|
||||
|
||||
def delayedSwitchOff(self):
|
||||
@@ -254,13 +261,6 @@ class LtGenDataCollector:
|
||||
self._archive(event, {time: data})
|
||||
|
||||
class LtGenInterpreter:
|
||||
class Task:
|
||||
def __init__(self, function, check):
|
||||
self.function = function
|
||||
self.check = check
|
||||
def test(self, email: MajGenApiTelecom.Telegram):
|
||||
return self.check
|
||||
|
||||
def __init__(self, tasks: list, communicator: MajGenApiTelecom):
|
||||
self.tasks = tasks
|
||||
self.communicator = communicator
|
||||
@@ -301,6 +301,14 @@ class GenScheduler:
|
||||
reboot_str = lambda: " -r" if reboot else ""
|
||||
os.system("shutdown{} 0".format(reboot_str()))
|
||||
|
||||
def init():
|
||||
lib = {}
|
||||
captScribe = CaptScribe(config["File Locations"]["logfile_info"], config["File Locations"]["logfile_error"])
|
||||
majGenObserver = MajGenObserver()
|
||||
majGenApiTelecom = MajGenApiTelecom(lambda: {"address": config["Secrets"]["emailaddress"], "password": config["Secrets"]["emailpassword"]}, lambda: config["Secrets"]["dropboxtoken"])
|
||||
majGenGPIOController = MajGenGPIOController(config["Hardware"]["pinopen"], config["Hardware"]["pinclose"], config["Timing"]["gpioswitchoff"])
|
||||
ltGenDataCollector = LtGenDataCollector({"air": majGenObserver.get_sensorData(), "picture": majGenObserver.get_picture()}, lib)
|
||||
ltGenInterpreter = LtGenInterpreter(RaspberryPie.tasks.tasks, majGenApiTelecom)
|
||||
|
||||
captScribe = CaptScribe("", "")
|
||||
majGenGPIOController = MajGenGPIOController(0, 0, 0)
|
||||
|
||||
init()
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class Task:
|
||||
def __init__(self, function, check):
|
||||
self.function = function
|
||||
self.check = check
|
||||
def test(self, email: MajGenApiTelecom.Telegram):
|
||||
return self.check
|
||||
|
||||
tasks = [
|
||||
Task(majGenGPIOController.open, lambda msg: 1 if ("auf" == msg.subject.lower() or "open" == msg.subject.lower()) else 0),
|
||||
Task(majGenGPIOController.close, lambda msg: 1 if ("zu" == msg.subject.lower() or "close" == msg.subject.lower()) else 0)
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>RaspberryPie</title>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.js" integrity="sha512-G8JE1Xbr0egZE5gNGyUm1fF764iHVfRXshIoUWCTPAbKkkItp/6qal5YAHXrxEu4HNfPTQs6HOu3D5vCGS1j3w==" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js" integrity="sha512-vBmx0N/uQOXznm/Nbkp7h0P1RfLSj0HQrFSzV8m7rOGyj30fYAOKHYvCNez+yM8IrfnW0TCodDEjRqf6fodf/Q==" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.css" integrity="sha512-SUJFImtiT87gVCOXl3aGC00zfDl6ggYAw5+oheJvRJ8KBXZrr/TMISSdVJ5bBarbQDRC2pR5Kto3xTR0kpZInA==" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css" integrity="sha512-/zs32ZEJh+/EO2N1b0PEdoA10JkdC3zJ8L5FTiQu82LR9S/rOQNfQN7U59U9BC12swNeRAz3HSzIL2vpp4fv3w==" crossorigin="anonymous" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>RaspberryPie</h1>
|
||||
<h2>Current Weather</h2>
|
||||
<p><a id="WeatherTime">{{ WeatherTime }}</a><br>Temperature: <a id="Temperature">{{ temp }}</a>, Humidity: <a id="Humidity">{{ humi }}</a></p>
|
||||
<canvas id="EnvironmentChart" width="400" height="200"></canvas>
|
||||
<h2>Weather Forecast</h2>
|
||||
<canvas id="ForecastChart" width="400" height="200"></canvas>
|
||||
<h2>Third party weather providers</h2>
|
||||
{% for image in urls %}
|
||||
<img src="{{ image }}">
|
||||
<h2>Webcam</h2>
|
||||
<a id="PictureTime">{{ PictureTime }}</a><br>
|
||||
<img id="Webcam" src="/latest.jpg">
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user