Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
domotikad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
domotika
domotikad
Commits
11da4ace
Commit
11da4ace
authored
Feb 28, 2014
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New clima tables
parent
3236b18f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
9 deletions
+114
-9
98_clima.sql
Databases/createdb/98_clima.sql
+72
-0
domotika.py
domotika/domotika.py
+42
-9
No files found.
Databases/createdb/98_clima.sql
0 → 100644
View file @
11da4ace
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
;
domotika/domotika.py
View file @
11da4ace
...
...
@@ -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
)])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment