Commit 11da4ace authored by nextime's avatar nextime

New clima tables

parent 3236b18f
ALTER TABLE `ioconf_analogs` ADD `take_in_sync` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `status_name` ,
ADD `sync_direction` ENUM( 'board2domotika', 'domotika2board' ) NOT NULL DEFAULT 'domotika2board' AFTER `take_in_sync` ,
ADD `sync_interval` INT UNSIGNED NOT NULL AFTER `sync_direction` ,
ADD INDEX ( `take_in_sync` , `sync_direction` ) ;
ALTER TABLE `ioconf_outputs` ADD `take_in_sync` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `outnum` ,
ADD `sync_direction` ENUM( 'board2domotika', 'domotika2board' ) NOT NULL DEFAULT 'domotika2board' AFTER `take_in_sync` ,
ADD `sync_interval` INT UNSIGNED NOT NULL AFTER `sync_direction` ,
ADD INDEX ( `take_in_sync` , `sync_direction` ) ;
ALTER TABLE `ioconf_inputs` ADD `take_in_sync` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `status_name` ,
ADD `sync_direction` ENUM( 'board2domotika', 'domotika2board' ) NOT NULL DEFAULT 'domotika2board' AFTER `take_in_sync` ,
ADD `sync_interval` INT UNSIGNED NOT NULL AFTER `sync_direction` ,
ADD INDEX ( `take_in_sync` , `sync_direction` ) ;
CREATE TABLE IF NOT EXISTS `thermostats_progs` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`thermostat_name` varchar(32) NOT NULL,
`clima_status` varchar(32) NOT NULL,
`day` enum('mon','tue','wed','thu','fri','sat','sun') NOT NULL DEFAULT 'mon',
`position` int(11) unsigned NOT NULL DEFAULT '0',
`h00` decimal(3,1) NOT NULL DEFAULT '20.0',
`h01` decimal(3,1) NOT NULL DEFAULT '20.0',
`h02` decimal(3,1) NOT NULL DEFAULT '20.0',
`h03` decimal(3,1) NOT NULL DEFAULT '20.0',
`h04` decimal(3,1) NOT NULL DEFAULT '20.0',
`h05` decimal(3,1) NOT NULL DEFAULT '20.0',
`h06` decimal(3,1) NOT NULL DEFAULT '20.0',
`h07` decimal(3,1) NOT NULL DEFAULT '20.0',
`h08` decimal(3,1) NOT NULL DEFAULT '20.0',
`h09` decimal(3,1) NOT NULL DEFAULT '20.0',
`h10` decimal(3,1) NOT NULL DEFAULT '20.0',
`h11` decimal(3,1) NOT NULL DEFAULT '20.0',
`h12` decimal(3,1) NOT NULL DEFAULT '20.0',
`h13` decimal(3,1) NOT NULL DEFAULT '20.0',
`h14` decimal(3,1) NOT NULL DEFAULT '20.0',
`h15` decimal(3,1) NOT NULL DEFAULT '20.0',
`h16` decimal(3,1) NOT NULL DEFAULT '20.0',
`h17` decimal(3,1) NOT NULL DEFAULT '20.0',
`h18` decimal(3,1) NOT NULL DEFAULT '20.0',
`h19` decimal(3,1) NOT NULL DEFAULT '20.0',
`h20` decimal(3,1) NOT NULL DEFAULT '20.0',
`h21` decimal(3,1) NOT NULL DEFAULT '20.0',
`h22` decimal(3,1) NOT NULL DEFAULT '20.0',
`h23` decimal(3,1) NOT NULL DEFAULT '20.0',
PRIMARY KEY (`id`),
KEY `thermostat_name` (`thermostat_name`),
KEY `clima_status` (`clima_status`,`day`),
KEY `position` (`position`),
KEY `active` (`day`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
ALTER TABLE `thermostats_progs`
ADD CONSTRAINT `thermostats_progs_ibfk_1` FOREIGN KEY (`thermostat_name`) REFERENCES `thermostats` (`name`) ON DELETE CASCADE ON UPDATE CASCADE;
CREATE TABLE IF NOT EXISTS `thermostats` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
`button_name` varchar(255) NOT NULL,
`position` int(10) unsigned NOT NULL,
`sensor_type` enum('analog','digital','statuses','uniques') NOT NULL DEFAULT 'analog',
`sensor_domain` varchar(32) NOT NULL DEFAULT '*',
`function` enum('manual','program') NOT NULL DEFAULT 'manual',
`minslide` decimal(3,1) NOT NULL DEFAULT '14.5',
`maxslide` decimal(3,1) NOT NULL DEFAULT '40.0',
`active` enum('yes','no') NOT NULL DEFAULT 'yes',
`setval` decimal(3,1) NOT NULL DEFAULT '20.0',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `active` (`active`),
KEY `button_name` (`button_name`,`position`),
KEY `function` (`function`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
......@@ -484,23 +484,56 @@ class domotikaService(service.Service):
return dmdb.DMBoards.find(where=['online=1']).addCallback(self._syncBoards)
return dmdb.DMBoards.find(where=['online=1 and id="%s"' % str(bid)]).addCallback(self._syncBoards)
def _pushBoards(self, res): # XXX Make which i/o/a is pushed selectively
def _pushBoards(self, res, analogs=False, inputs=False, outputs=False, pwms=False): # XXX Make which i/o/a is pushed selectively
if res:
for b in res:
p=pluggableBoards.getBoardPlugin(b.type, ConvenienceCaller(lambda c: self._callback('board', c)))
if b:
pboard = p.getBoard(b.ip, b.webport, self.boardsyspwd, str(self.config.get('general', 'language')))
pboard.pushAnalogs()
pboard.pushInputs()
pboard.pushOutputs()
#pboard.pushPwm()
if analogs and analogs=='*':
pboard.pushAnalogs()
elif type(analogs).__name__ in ['list','tuple']:
for an in analogs:
if type(an).__name__ == 'dict':
if 'num' in an.keys() and 'status' in an.keys():
pboard.pushAnalogs(ananum=an['num'], status=an['status'])
elif genutils.is_number(an):
pboard.pushAnalogs(ananum=int(an))
elif type(analogs).__name__ in ['int','str']:
pboard.pushAnalogs(ananum=analogs)
if inputs and inputs=='*':
pboard.pushInputs()
elif type(inputs).__name__ in ['list','tuple']:
for inp in inputs:
if type(inp).__name__ == 'dict':
if 'num' in inp.keys() and 'status' in inp.keys():
pboard.pushInputs(inpnum=inp['num'], status=inp['status'])
elif genutils.is_number(inp):
pboard.pushInputs(inpnum=int(inp))
elif type(inputs).__name__ in ['int','str']:
pboard.pushInputs(inpnum=inputs)
if outputs and outputs=='*':
pboard.pushOutputs()
elif type(outputs).__name__ in ['list','tuple']:
for out in outputs:
if genutils.is_number(out):
pboard.pushOutputs(outnum=int(out))
elif type(outputs).__name__ in ['int','str']:
pboard.pushOutputs(outnum=outputs)
#if not pwms:
# pboard.pushPwm()
return True
def pushBoards(self, bid=False, *a, **kw):
def pushBoards(self, bid=False, analogs=False, inputs=False, outputs=False, pwms=False, *a, **kw):
if not bid:
return dmdb.DMBoards.find(where=['online=1']).addCallback(self._pushBoards)
return dmdb.DMBoards.find(where=['online=1 and id="%s"' % str(bid)]).addCallback(self._pushBoards)
return dmdb.DMBoards.find(where=['online=1']).addCallback(self._pushBoards, analogs, inputs, outputs, pwms)
return dmdb.DMBoards.find(where=['online=1 and id="%s"' % str(bid)]).addCallback(self._pushBoards, analogs, inputs, outputs, pwms)
def autoDetectBoards(self, *a, **kw):
log.info("Start building boardlist")
......@@ -2185,7 +2218,7 @@ class domotikaService(service.Service):
return self.syncBoards(bid=bid)
def web_on_startPush(self, bid=False):
return self.pushBoards(bid=bid)
return self.pushBoards(bid=bid, analogs='*',inputs='*',outputs='*',pwms='*')
def web_on_getAuth(self, usr, pwd):
return dmdb.Users.find(where=["username='%s' AND passwd='%s' AND active=1" % ( usr, pwd)])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment