1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 02:14:26 +01:00

display: Add request_status timer

This will cyclically reset the status to Open/Close, independent of incoming
messages

Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
Ralf Ramsauer 2018-03-18 18:21:07 +01:00
parent a6e117ffd9
commit 56ac823852
2 changed files with 8 additions and 0 deletions

View File

@ -220,6 +220,7 @@ class AuthenticationForm(FlaskForm):
return True
@socketio.on('request_status')
@socketio.on('connect')
def on_connect():
logic.emit_status()

View File

@ -5,7 +5,12 @@
<script type="text/javascript" src="static/socket.io.slim.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
function request_status() {
socket.emit('request_status');
}
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port);
var timer = setInterval(request_status, 120000);
socket.on('connect', function() {
socket.emit('connected');
@ -13,6 +18,8 @@
socket.on('status', function(status) {
$('#led').attr('src', status.led);
$('#message').html(status.message);
clearInterval(timer);
timer = setInterval(request_status, 120000);
});
});
</script>