-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessanaFanCoil.py
129 lines (104 loc) · 5.45 KB
/
MessanaFanCoil.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
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
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python3
import polyinterface
from subprocess import call
LOGGER = polyinterface.LOGGER
#self, controller, primary, address, name, nodeType, nodeNbr, messana
class messanaFanCoil(polyinterface.Node):
def __init__(self, controller, primary, address, name, fanCoilNbr):
super().__init__(controller, primary, address, name)
LOGGER.info('_init_ Messana FanCoil ' + str(fanCoilNbr) )
self.fanCoilNbr = fanCoilNbr
self.name = name
self.address = address
self.messana = self.parent.messana
self.id = self.messana.getFanCoilAddredd(fanCoilNbr)
self.fanCoil_GETKeys = self.messana.fanCoilPullKeys(self.fanCoilNbr)
self.fanCoil_PUTKeys = self.messana.fanCoilPushKeys(self.fanCoilNbr)
self.fanCoil_ActiveKeys = self.messana.fanCoilActiveKeys(self.fanCoilNbr)
self.ISYforced = False
self.drivers = []
for key in self.fanCoil_GETKeys:
self.temp = self.messana.getFanCoilISYdriverInfo(key, self.fanCoilNbr)
if self.temp != {}:
self.drivers.append(self.temp)
#LOGGER.debug( 'driver: ' + self.temp['driver'])
self.messana.updateFanCoilData('all', self.fanCoilNbr)
self.updateISYdrivers('all')
self.ISYforced = True
def start(self):
return True
def updateISYdrivers(self, level):
#LOGGER.debug('FanCoil updateISYdrivers')
for ISYdriver in self.drivers:
ISYkey = ISYdriver['driver']
if level == 'active':
temp = self.messana.getFanCoilMessanaISYkey(ISYkey, self.fanCoilNbr)
if temp in self.fanCoil_ActiveKeys:
#LOGGER.debug('Messana FanCoil ISYdrivers ACTIVE ' + temp)
status, value = self.messana.getFanCoilISYValue(ISYkey, self.fanCoilNbr)
if status:
if self.ISYforced:
self.setDriver(ISYdriver, value, report = True, force = False)
else:
self.setDriver(ISYdriver, value, report = True, force = True)
#LOGGER.debug('driver updated :' + ISYdriver['driver'] + ' = '+str(value))
else:
LOGGER.error('Error getting ' + ISYdriver['driver'])
elif level == 'all':
temp = self.messana.getFanCoilMessanaISYkey(ISYkey, self.fanCoilNbr)
status, value = self.messana.getFanCoilISYValue(ISYkey, self.fanCoilNbr)
#LOGGER.debug('Messana FanCoil ISYdrivers ALL ' + temp)
if status:
if self.ISYforced:
self.setDriver(ISYdriver, value, report = True, force = False)
else:
self.setDriver(ISYdriver, value, report = True, force = True)
#LOGGER.debug('driver updated :' + ISYdriver['driver'] + ' = '+str(value))
else:
LOGGER.error('Error getting ' + ISYdriver['driver'])
else:
LOGGER.error('Error! Unknow level: ' + level)
def stop(self):
LOGGER.info('stop - Messana FanCoil Cleaning up')
def shortPoll(self):
#LOGGER.debug('Messana FanCoil shortPoll - fanCoil '+ str(self.fanCoilNbr))
self.messana.updateFanCoilData('active', self.fanCoilNbr)
self.updateISYdrivers('active')
def longPoll(self):
#LOGGER.debug('Messana FanCoil longPoll - fanCoil ' + str(self.fanCoilNbr))
self.messana.updateFanCoilData('all', self.fanCoilNbr)
self.updateISYdrivers('all')
self.reportDrivers()
def query(self, command=None):
LOGGER.info('TOP querry')
def setStatus(self, command):
#LOGGER.debug('setStatus Called')
value = int(command.get('value'))
#LOGGER.debug('FanCoil'+str(self.fanCoilNbr)+' setStatus Received:' + str(value))
if self.messana.fanCoilSetStatus(value, self.fanCoilNbr):
ISYdriver = self.messana.getFanCoilStatusISYdriver(self.fanCoilNbr)
self.setDriver(ISYdriver, value, report = True)
def fanCoilUpdate(self, command):
#LOGGER.debug('fanCoilUpdate called')
self.messana.updateFanCoilData('all', self.fanCoilNbr)
self.updateISYdrivers('all')
self.reportDrivers()
def setCoolingSpeed(self, command):
#LOGGER.debug('setHeatingSpeed Called')
value = int(command.get('value'))
#LOGGER.debug('FanCoil'+str(self.fanCoilNbr)+' setHeatingSpeed Received:' + str(value))
if self.messana.fanCoilSetCoolingSpeed(value, self.fanCoilNbr):
ISYdriver = self.messana.getFanCoilCoolingSpeedISYdriver(self.fanCoilNbr)
self.setDriver(ISYdriver, value, report = True)
def setHeatingSpeed(self, command):
#LOGGER.debug('setHeatingSpeed Called')
value = int(command.get('value'))
#LOGGER.debug('FanCoil'+str(self.fanCoilNbr)+' setHeatingSpeed Received:' + str(value))
if self.messana.fanCoilSetHeatingSpeed(value, self.fanCoilNbr):
ISYdriver = self.messana.getFanCoilHeatingSpeedISYdriver(self.fanCoilNbr)
self.setDriver(ISYdriver, value, report = True)
commands = { 'UPDATE': fanCoilUpdate
,'SET_STATUS': setStatus
,'SET_COOLING_SPEED': setHeatingSpeed
,'SET_HEATING_SPEED' : setHeatingSpeed
}