-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLutron_DB.py
More file actions
executable file
·118 lines (89 loc) · 3.7 KB
/
Copy pathLutron_DB.py
File metadata and controls
executable file
·118 lines (89 loc) · 3.7 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Script Name : Lutron_DB
# Author : William Berriel
# Created : Oct 26 2016
# Last Modified :
# Version : 0.01
# Modifications :
# Description : Contrary to the name, this is not a database. It's a simple
# object representing the XML database for a Lutron Processor.
class Lutron_DB(object):
"""Stores a representation of a Lutron XML Database."""
def __init__(self, name=None):
self.name = name
self.areas = {}
self.devices = {}
self.outputs = {}
def __repr__(self):
return "<Lutron_DB Name: %s" % (self.name)
def __str__(self):
return_string = "Lutron_DB: %s" % (self.name)
if(self.areas.keys()):
return_string += "\nAreas:"
for key in self.areas.keys():
return_string += "\n%s" % self.areas[key]
return return_string
class Lutron_Area(object):
""" Stores the Metadata, sub areas, devices, and outputs for an area."""
def __init__(self, IntegrationID=0, name=0):
"""Init will have an optional Integration_ID and name."""
self.IntegrationID = IntegrationID
self.name = name
self.parent = None
self.areas = {}
self.devices = {}
self.outputs = {}
def __repr__(self):
return "<Lutron_Area Name: %s IntegrationID: %s>" % \
(self.name, self.IntegrationID)
def __str__(self):
return_string = "Area: %s-%s" % (self.name, self.IntegrationID)
if(self.devices.keys()):
return_string += "\nDevices:"
for key in self.devices.keys():
return_string += "\n%s" % self.devices[key]
if(self.outputs.keys()):
return_string += "\nOutputs:"
for key in self.outputs.keys():
return_string += "\n%s" % self.outputs[key]
return return_string
class Lutron_Device(object):
""" Stores the Device Metadata and State"""
def __init__(self, IntegrationID=0, name=None, area=None):
""" Constructor takes an optional Integration_ID, name, and area."""
# Integration_ID is an unsigned integer
self.IntegrationID = IntegrationID
# Pointer to the containing area object.
self.area = area
# Name should be a string.
self.name = name
# LED_status stores the status of up to 10 LEDS
# (current keypads use 7).
self.LED_status = [0] * 10
# button_status stores the status of up to 20 buttons. (current keypads
# use 10).
self.button_status = [0] * 20
def __repr__(self):
return "<Lutron_Device Name: %s IntegrationID: %s>" % \
(self.name, self.IntegrationID)
def __str__(self):
return "%s-%s" % (self.name, self.IntegrationID)
class Lutron_Output(object):
""" Stores Output Metadata and state."""
def __init__(self, IntegrationID=0, name=None, area=None):
""" Constructor takes an optional Integration_ID, name, and area."""
self.IntegrationID = IntegrationID
# Pointer to the area object containing the device.
self.area = area
# Name should be a string.
self.name = name
# level is from 0.0 to 100.0
self.level = 0.0
# tilt is from 0.0 to 100.0
self.tilt = 0.0
# fade is an integer in secods from 0 to 14400 (4 hours)
self.fade = 0
def __repr__(self):
return "<Lutron_Output Name: %s IntegrationID: %s Level: %s>" % \
(self.name, self.IntegrationID, self.level)
def __str__(self):
return "%s-%s: %s" % (self.name, self.IntegrationID, self.level)