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
bf28fdba
Commit
bf28fdba
authored
Feb 26, 2014
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial connection between thermostat gui and backend
parent
84d25f0e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
32 deletions
+88
-32
thermostat.php
Web/htdocs/gui/panels/content/thermostat.php
+3
-3
thermostat.php
Web/htdocs/gui/panels/footjs/thermostat.php
+41
-29
dmdb.py
domotika/db/dmdb.py
+8
-0
domotika.py
domotika/domotika.py
+9
-0
rest.py
domotika/web/rest.py
+27
-0
No files found.
Web/htdocs/gui/panels/content/thermostat.php
View file @
bf28fdba
...
...
@@ -65,13 +65,13 @@ if($panel && is_array($panel)) {
class=
"panel panel-theme-
<?=
$_DOMOTIKA
[
'gui_theme'
]
?>
thermo-statuspanel text-on-white-theme-
<?=
$_DOMOTIKA
[
'gui_theme'
]
?>
"
>
<div
class=
"notifylist"
>
<div
class=
"list-group theme-
<?=
$_DOMOTIKA
[
'gui_theme'
]
?>
"
data-snap-ignore=
"true"
>
<?
foreach
(
$climastatuses
as
$cs
)
{
if
(
$cs
[
'clima_status'
]
!=
$climastatus
)
{
?>
<?
foreach
(
$climastatuses
as
$cs
)
{
?>
<button
type=
"button"
style=
"width:100%;margin-top:5px;"
data-domotika-statusselect=
"
<?=
$cs
[
'clima_status'
]
?>
"
data-domotika-type=
"status
choose
"
data-domotika-type=
"status
select
"
data-domotika-panel=
"thermo-statuschooselist-
<?=
$button
[
'id'
]
.
"-"
.
$panel
[
'id'
]
?>
"
class=
"btn btn-success"
>
<?=
$cs
[
'clima_status'
]
?>
</button>
<?
}
}
?>
<?
}
?>
</div>
</div>
</div>
...
...
Web/htdocs/gui/panels/footjs/thermostat.php
View file @
bf28fdba
...
...
@@ -14,6 +14,39 @@ function thermoResetGaugeLevel(g,l) {
}
function
changeClimaStatus
(
newstatus
,
request
){
$
(
"[data-domotika-type=btn-choosestatuses]"
).
each
(
function
(){
$
(
this
).
html
(
"<b>"
+
newstatus
+
'<b> <i class="glyphicon glyphicon-chevron-down"></i>'
)
}
);
$
(
"[data-domotika-type=statusselect]"
).
each
(
function
(){
if
(
$
(
this
).
attr
(
'data-domotika-statusselect'
)
==
newstatus
)
$
(
this
).
hide
();
else
$
(
this
).
show
();
}
);
if
(
typeof
(
request
)
!=
'undefined'
)
{
console
.
debug
(
"Change status to "
+
newstatus
);
$
.
post
(
"/rest/v1.2/clima/status/json"
,
'status='
+
newstatus
);
}
}
function
changeThermostatStatus
(
newstatus
,
parts2
,
parts3
)
{
var
program
=
$
(
"#thermo-btnprogram-"
+
parts2
+
'-'
+
parts3
);
var
manual
=
$
(
"#thermo-btnmanual-"
+
parts2
+
'-'
+
parts3
);
if
(
newstatus
==
'manual'
){
program
.
alterClass
(
program
.
attr
(
'data-dmcolor-on'
),
program
.
attr
(
'data-dmcolor-off'
));
manual
.
alterClass
(
manual
.
attr
(
'data-dmcolor-off'
),
manual
.
attr
(
'data-dmcolor-on'
));
}
else
{
program
.
alterClass
(
program
.
attr
(
'data-dmcolor-off'
),
program
.
attr
(
'data-dmcolor-on'
));
manual
.
alterClass
(
manual
.
attr
(
'data-dmcolor-on'
),
manual
.
attr
(
'data-dmcolor-off'
));
}
}
function
checkSliderSet
(
slider
){
if
(
slider
.
data
(
'lastchanged'
))
{
...
...
@@ -47,16 +80,8 @@ $("[data-domotika-type=thermo-level]").each(
var
parts
=
$
(
this
).
attr
(
'id'
).
split
(
"-"
);
$
(
"#thermo-showset-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]).
text
(
parseFloat
(
$
(
this
).
val
()).
toFixed
(
1
));
thermoResetGaugeLevel
(
'gauge-'
+
parts
[
2
]
+
'-'
+
parts
[
3
],
parseFloat
(
$
(
this
).
val
()));
var
program
=
$
(
"#thermo-btnprogram-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
var
manual
=
$
(
"#thermo-btnmanual-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
program
.
alterClass
(
program
.
attr
(
'data-dmcolor-on'
),
program
.
attr
(
'data-dmcolor-off'
));
manual
.
alterClass
(
manual
.
attr
(
'data-dmcolor-off'
),
manual
.
attr
(
'data-dmcolor-on'
));
changeThermostatStatus
(
'manual'
,
parts
[
2
],
parts
[
3
]);
},
/*
set: function() {
$(this).data('lastchanged', Date.now());
}
*/
});
$
(
this
).
data
(
'oldval'
,
$
(
this
).
val
());
$
(
this
).
data
(
'lastchanged'
,
false
);
...
...
@@ -76,11 +101,7 @@ $("[data-domotika-type=thermo-level]").each(
{
$
(
'#'
+
$
(
this
).
attr
(
'id'
).
replace
(
'thermo-level-'
,
'thermo-showset-'
)).
text
(
parseFloat
(
$
(
this
).
val
()).
toFixed
(
1
));
thermoResetGaugeLevel
(
'gauge-'
+
parts
[
2
]
+
'-'
+
parts
[
3
],
parseFloat
(
$
(
this
).
val
()));
var
program
=
$
(
"#thermo-btnprogram-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
var
manual
=
$
(
"#thermo-btnmanual-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
program
.
alterClass
(
program
.
attr
(
'data-dmcolor-on'
),
program
.
attr
(
'data-dmcolor-off'
));
manual
.
alterClass
(
manual
.
attr
(
'data-dmcolor-off'
),
manual
.
attr
(
'data-dmcolor-on'
));
//$(this).data('lastchanged', Date.now());
changeThermostatStatus
(
'manual'
,
parts
[
2
],
parts
[
3
]);
}
});
...
...
@@ -92,11 +113,7 @@ $("[data-domotika-type=thermo-level]").each(
slide
.
val
(
parseFloat
(
slide
.
val
())
-
0.5
);
$
(
'#'
+
$
(
this
).
attr
(
'id'
).
replace
(
'thermo-minus-'
,
'thermo-showset-'
)).
text
(
parseFloat
(
slide
.
val
()).
toFixed
(
1
));
var
parts
=
$
(
this
).
attr
(
'id'
).
split
(
"-"
);
var
program
=
$
(
"#thermo-btnprogram-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
var
manual
=
$
(
"#thermo-btnmanual-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
program
.
alterClass
(
program
.
attr
(
'data-dmcolor-on'
),
program
.
attr
(
'data-dmcolor-off'
));
manual
.
alterClass
(
manual
.
attr
(
'data-dmcolor-off'
),
manual
.
attr
(
'data-dmcolor-on'
));
//slide.data('lastchanged', Date.now());
changeThermostatStatus
(
'manual'
,
parts
[
2
],
parts
[
3
]);
},
200
,
700
,
true
);
plus
.
continouoshold
(
function
(){
...
...
@@ -104,11 +121,7 @@ $("[data-domotika-type=thermo-level]").each(
slide
.
val
(
parseFloat
(
slide
.
val
())
+
0.5
);
$
(
'#'
+
$
(
this
).
attr
(
'id'
).
replace
(
'thermo-plus-'
,
'thermo-showset-'
)).
text
(
parseFloat
(
slide
.
val
()).
toFixed
(
1
));
var
parts
=
$
(
this
).
attr
(
'id'
).
split
(
"-"
);
var
program
=
$
(
"#thermo-btnprogram-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
var
manual
=
$
(
"#thermo-btnmanual-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
program
.
alterClass
(
program
.
attr
(
'data-dmcolor-on'
),
program
.
attr
(
'data-dmcolor-off'
));
manual
.
alterClass
(
manual
.
attr
(
'data-dmcolor-off'
),
manual
.
attr
(
'data-dmcolor-on'
));
//slide.data('lastchanged', Date.now());
changeThermostatStatus
(
'manual'
,
parts
[
2
],
parts
[
3
]);
},
200
,
700
,
true
);
}
...
...
@@ -134,6 +147,8 @@ $("[data-domotika-type=statusselect]").each(
$
(
this
).
fastClick
(
function
(){
var
panel
=
"#"
+
$
(
this
).
attr
(
'data-domotika-panel'
);
$
(
panel
).
hide
(
150
);
var
newstatus
=
$
(
this
).
attr
(
'data-domotika-statusselect'
);
changeClimaStatus
(
newstatus
,
true
);
});
}
);
...
...
@@ -143,8 +158,7 @@ $("[data-domotika-type=btnprogram]").each(
function
()
{
var
parts
=
$
(
this
).
attr
(
'id'
).
split
(
"-"
);
var
other
=
$
(
"#thermo-btnmanual-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
other
.
alterClass
(
other
.
attr
(
'data-dmcolor-on'
),
other
.
attr
(
'data-dmcolor-off'
));
$
(
this
).
alterClass
(
$
(
this
).
attr
(
'data-dmcolor-off'
),
$
(
this
).
attr
(
'data-dmcolor-on'
));
changeThermostatStatus
(
'program'
,
parts
[
2
],
parts
[
3
]);
});
}
);
...
...
@@ -153,9 +167,7 @@ $("[data-domotika-type=btnmanual]").each(
function
(){
$
(
this
).
fastClick
(
function
()
{
var
parts
=
$
(
this
).
attr
(
'id'
).
split
(
"-"
);
var
other
=
$
(
"#thermo-btnprogram-"
+
parts
[
2
]
+
'-'
+
parts
[
3
]);
other
.
alterClass
(
other
.
attr
(
'data-dmcolor-on'
),
other
.
attr
(
'data-dmcolor-off'
));
$
(
this
).
alterClass
(
$
(
this
).
attr
(
'data-dmcolor-off'
),
$
(
this
).
attr
(
'data-dmcolor-on'
));
changeThermostatStatus
(
'manual'
,
parts
[
2
],
parts
[
3
]);
});
}
);
...
...
domotika/db/dmdb.py
View file @
bf28fdba
...
...
@@ -236,6 +236,11 @@ class StatsData(DBObject):
class
StatsHistory
(
DBObject
):
TABLENAME
=
"stats_history"
class
Thermostats
(
DBObject
):
TABLENAME
=
"thermostats"
class
ThermostatsProgs
(
DBObject
):
TABLENAME
=
"thermostats_progs"
def
cleanFlags
():
...
...
@@ -269,6 +274,9 @@ def _retValueQuery(res, defval='DEFAULT'):
def
getNetStatus
():
return
Uniques
.
find
(
where
=
[
"name='netstatus'"
],
limit
=
1
)
.
addCallback
(
_retValueQuery
,
'DEFAULT'
)
def
getClimaStatus
():
return
Uniques
.
find
(
where
=
[
"name='climastatus'"
],
limit
=
1
)
.
addCallback
(
_retValueQuery
,
'OFF'
)
def
getStatusRealtime
(
stname
):
return
StatusRealtime
.
find
(
where
=
[
"status_name=?"
,
stname
],
limit
=
1
)
.
addCallback
(
_retValueQuery
,
False
)
...
...
domotika/domotika.py
View file @
bf28fdba
...
...
@@ -2322,6 +2322,15 @@ class domotikaService(service.Service):
return
'TRUE'
return
'FALSE'
def
web_on_getClimaStatus
(
self
):
return
dmdb
.
getClimaStatus
()
def
web_on_setClimaStatus
(
self
,
newstatus
):
return
dmdb
.
setUnique
(
'climastatus'
,
newstatus
);
def
web_on_getThermostat
(
self
,
thermostat
):
return
dmdb
.
Thermostats
.
find
(
where
=
[
"name='
%
s'"
%
thermostat
],
limit
=
1
)
def
web_on_voiceReceived
(
self
,
txt
,
confidence
=
0.0
,
lang
=
"it"
):
return
self
.
voiceRecognized
(
txt
,
confidence
,
lang
,
voicesrc
=
'RestAPI'
)
...
...
domotika/web/rest.py
View file @
bf28fdba
...
...
@@ -524,6 +524,32 @@ class ChartRest(RestCore):
return
self
.
callbackResponse
(
self
.
core
.
getChartData
(
chartname
),
request
)
class
ClimaRest
(
RestCore
):
path
=
"clima"
@
route
(
"/status"
,(
Http
.
GET
))
@
wrapResponse
def
getStatus
(
self
,
request
,
*
a
,
**
kw
):
return
self
.
callbackResponse
(
self
.
core
.
getClimaStatus
(),
request
)
@
route
(
"/status"
,(
Http
.
PUT
,
Http
.
POST
))
@
wrapResponse
def
setStatus
(
self
,
request
,
*
a
,
**
kw
):
r
=
self
.
_getRequestArgs
(
request
)
if
'status'
in
r
.
keys
():
statusname
=
r
[
'status'
]
return
self
.
callbackResponse
(
self
.
core
.
setClimaStatus
(
statusname
),
request
)
return
ResponseConversion
(
request
,
code
=
500
,
entity
=
"No status in request"
)
@
route
(
"/thermostat/<thermostat>"
,(
Http
.
GET
))
@
wrapResponse
def
getThermostatStatus
(
self
,
request
,
thermostat
,
*
a
,
**
kw
):
return
self
.
callbackResponse
(
self
.
core
.
getThermostat
(
thermostat
),
request
)
RESTv12LIST
=
(
UserRest
,
CronRest
,
...
...
@@ -533,6 +559,7 @@ RESTv12LIST=(
NotifyRest
,
RelayRest
,
ChartRest
,
ClimaRest
,
)
...
...
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