-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 852b78d
Showing
17 changed files
with
17,879 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0x55 0x0 0xa 0x7 0x1 0xeb 0xa5 0x0 0xd6 0xa4 0xa 0x5 0xc 0x4c 0x4e 0x0 0x1 0xff 0xff 0xff 0xff 0x31 0x0 0x4 | ||
State: T: 33.4 H: 36 SP: 0 SW: 0 | ||
4BS teach-in accepted EEP A5-04-01 Manufacturer: ID-RF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"serialPort": "COM3", | ||
"baudrate": 57600, | ||
"devices": [ | ||
{ | ||
"id": "050c4c4e", | ||
"eep": "A5-04-01", | ||
"name": "Temperature" | ||
}, { | ||
"id": "0030E4A3", | ||
"eep": "F6-02-01", | ||
"name": "Rocker" | ||
}, { | ||
"id": "050a3158", | ||
"eep": "D2-01-0E", | ||
"name": "Smart Plug" | ||
}, { | ||
"id": "05115c58", | ||
"eep": "D5-00-01", | ||
"name": "Desk-Window" | ||
},{ | ||
"id": "05115c4f", | ||
"eep": "D5-00-01", | ||
"name": "Workbench-Window" | ||
},{ | ||
"id": "05115c56", | ||
"eep": "D5-00-01", | ||
"name": "Kitchen-Window" | ||
},{ | ||
"id": "050988F7", | ||
"eep": "A5-07-03", | ||
"name": "Motion detector" | ||
},{ | ||
"id": "01a8c6a6", | ||
"eep": "A5-30-03", | ||
"name": "Smoke Detector" | ||
} | ||
|
||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
''' | ||
Created on 14.01.2018 | ||
@author: Stefan Rossmann | ||
''' | ||
import json | ||
from warnings import catch_warnings | ||
import threading | ||
from collections import OrderedDict | ||
import copy | ||
import datetime | ||
import traceback | ||
import os | ||
|
||
|
||
class config(object): | ||
''' | ||
classdocs | ||
''' | ||
# Here will be the instance stored. | ||
__instance = None | ||
|
||
@staticmethod | ||
def getInstance(): | ||
""" Static access method. """ | ||
if config.__instance == None: | ||
config() | ||
return config.__instance | ||
|
||
def __init__(self): | ||
""" Virtually private constructor. """ | ||
if config.__instance != None: | ||
raise Exception("This class is a singleton!") | ||
else: | ||
config.__instance = self | ||
self.serialPort = 'COM12' | ||
self.baudrate = 57600 | ||
self.pythonswversion = 'error' | ||
self.devices = list() | ||
|
||
def readconfig(self): | ||
with open('config.json') as json_data: | ||
d = json.load(json_data) | ||
self.baudrate = (d['baudrate']) | ||
self.serialPort = (d['serialPort']) | ||
if ('devices' in d): | ||
self.devices = (d['devices']) | ||
|
||
def readVersion(self): | ||
try: | ||
with open('version.json') as json_data: | ||
d = json.load(json_data) | ||
self.pythonswversion = (d['pythonswversion']) | ||
|
||
except Exception: | ||
self.pythonswversion = 'error' | ||
|
||
def writePythonSWVersion(self): | ||
try: | ||
with open('version.json', 'w') as f: | ||
data = OrderedDict() | ||
data['pythonswversion'] = '{0:%Y-%m-%d}'.format(datetime.datetime.now()) | ||
json.dump(data, f, indent=2) | ||
f.write("\n") | ||
except Exception: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import os,sys, sqlite3 | ||
import datetime | ||
|
||
def writedata(datetime,deviceid, packet): | ||
if not (os.path.exists("receive.db")): | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'CREATE TABLE receive(datetime STRING, deviceid STRING, packet STRING)' | ||
cursor.execute(sql) | ||
else: | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'INSERT INTO receive VALUES("' + str(datetime) + '", "' +str(deviceid)+ '", "' + str(packet) + '");' | ||
cursor.execute(sql) | ||
connection.commit() | ||
connection.close() | ||
|
||
def readdata(): | ||
if (os.path.exists("receive.db")): | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'SELECT * FROM receive' | ||
cursor.execute(sql) | ||
connection.close() | ||
|
||
def geteventcountertotal(): | ||
if (os.path.exists("receive.db")): | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'SELECT * FROM receive' | ||
cursor.execute(sql) | ||
returnvalue = (len(cursor.fetchall())) | ||
connection.close() | ||
return returnvalue | ||
|
||
def geteventcounterlasthour(): | ||
returnvalue = 0 | ||
if (os.path.exists("receive.db")): | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'SELECT * FROM receive ORDER BY datetime DESC' | ||
cursor.execute(sql) | ||
for entry in cursor: | ||
dt = datetime.datetime.strptime(entry[0], "%Y-%m-%d %H:%M:%S.%f") | ||
if (dt.hour == datetime.datetime.now().hour): | ||
returnvalue = returnvalue + 1 | ||
else: | ||
break | ||
return returnvalue | ||
|
||
def geteventcounter(hour): | ||
returnvalue = 0 | ||
if (os.path.exists("receive.db")): | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'SELECT * FROM receive ORDER BY datetime DESC' | ||
cursor.execute(sql) | ||
for entry in cursor: | ||
dt = datetime.datetime.strptime(entry[0], "%Y-%m-%d %H:%M:%S.%f") | ||
if (dt.hour == hour): | ||
returnvalue = returnvalue + 1 | ||
if (dt.hour < hour): | ||
break | ||
return returnvalue | ||
|
||
def geteventcounterdeviceid(): | ||
eventcounters = dict() | ||
if (os.path.exists("receive.db")): | ||
connection = sqlite3.connect("receive.db") | ||
cursor = connection.cursor() | ||
sql = 'SELECT * FROM receive ORDER BY deviceid DESC' | ||
cursor.execute(sql) | ||
for entry in cursor: | ||
if not ('deviceid'+str(entry[1]) in eventcounters): | ||
eventcounters['deviceid'+entry[1]] = int() | ||
eventcounters['deviceid'+entry[1]] = eventcounters['deviceid'+entry[1]]+1 | ||
return eventcounters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
''' | ||
Created on 12.01.2018 | ||
@author: Stefan Rossmann | ||
''' | ||
import csv | ||
import logging | ||
from logging.handlers import RotatingFileHandler | ||
import os | ||
import traceback | ||
import datetime | ||
|
||
LOG_FILENAME = 'logdata.txt' | ||
|
||
my_logger1 = logging.getLogger('MyLogger') | ||
my_logger1.setLevel(logging.DEBUG) | ||
my_logger1.propagate = False | ||
|
||
# Add the log message handler to the logger | ||
handler1 = logging.handlers.RotatingFileHandler( | ||
LOG_FILENAME, maxBytes=20000000, backupCount=5) | ||
formatter1 = logging.Formatter("%(asctime)s;%(message)s", | ||
"%Y-%m-%d %H:%M:%S") | ||
handler1.setFormatter(formatter1) | ||
my_logger1.addHandler(handler1) | ||
|
||
def logData(dataToWrite): | ||
try: | ||
# Set up a specific logger with our desired output level | ||
|
||
my_logger1.debug(dataToWrite) | ||
|
||
print (dataToWrite) | ||
|
||
except: | ||
pass | ||
|
||
|
||
|
Oops, something went wrong.