-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfakeDomoticz.py
68 lines (55 loc) · 2.19 KB
/
fakeDomoticz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# Fake Domoticz - Domoticz Python plugin stub
#
# With thanks to Frank Fesevur, 2017
#
# Very simple module to make local testing easier
# It "emulates" Domoticz.Log(), Domoticz.Error and Domoticz.Debug()
# It also emulates the Device and Unit from the Ex framework
#
from datetime import datetime
Devices = dict()
Parameters = {"Mode1": 200, "Mode2": 6, "Mode3" : 2200, "Mode4": "Debug", "Mode5": "", "Mode6": "Debug", "Port": 8443, "Username": "[email protected]" , "Password": "aNicerp@ssword", "Version" : "0.0.0", "HomeFolder":"/home/pi/domoticz/plugins/SessyBattery/", "Name": "fakeDomoticz"}
config = dict()
class myUnit:
def __init__(self,Name="label", Unit=0, Type=0, TypeName ="", Subtype=0, Switchtype="", Options="", DeviceID="deviceURL", Used=0):
self.Name=Name
self.Unit=Unit
self.Type=Type
self.TypeName=TypeName
self.Subtype=Subtype
self.Switchtype=Switchtype
self.DeviceID=DeviceID
self.Used=Used
def Create(self):
print("Creating unit "+str(self.Name)+" for deviceID "+str(self.DeviceID))
@property
def LastUpdate(self):
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
class Domoticz:
def __init__(self):
self.Units = []
self.Devices = dict()
return
def Log(self, s):
print(s)
def Status(self, s):
print(s)
def Error(self, s):
print(s)
def Debug(self, s):
print(s)
def Debugging(self, level):
print("debugging set to "+ str(level))
def Heartbeat(self, level):
print("heartbeat set to "+ str(level))
def Device(self, DeviceID=""):
self.Devices[DeviceID] = DeviceID
print("creating DeviceID: "+ DeviceID)
def Unit(self, Name="label", Unit=0, Type=0, TypeName="", Subtype=0, Switchtype="", Options="", DeviceID="deviceURL", Used=0):
newUnit = myUnit(Name, Unit, Type, TypeName, Subtype, Switchtype, Options, DeviceID, Used)
#self.Devices[DeviceID].Units.append(newUnit)
self.Units.append(newUnit)
return newUnit
def Configuration(self):
return config