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

doorlockd.py: move emit status to Logic class

Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
Ralf Ramsauer 2018-03-18 17:47:50 +01:00
parent 93a34b7755
commit a6e117ffd9

View File

@ -183,8 +183,18 @@ class Logic:
def request(self, state, credentials):
err = self._request(state, credentials)
self.emit_status(err)
return err
def emit_status(self, message=None):
led = self.state.to_img()
if message is None:
message = self.state.to_html()
else:
message = message.to_html()
socketio.emit('status', {'led': led, 'message': message})
@property
def state(self):
return self.door_handler.state
@ -210,19 +220,9 @@ class AuthenticationForm(FlaskForm):
return True
def emit_status(message=None):
led = logic.state.to_img()
if message is None:
message = logic.state.to_html()
else:
message = message.to_html()
socketio.emit('status', {'led': led, 'message': message})
@socketio.on('connect')
def on_connect():
emit_status()
logic.emit_status()
@webapp.route('/display')
@ -252,8 +252,6 @@ def home():
# Don't trust python, zero credentials
user = password = credentials = None
emit_status(response)
return render_template('index.html',
authentication_form=authentication_form,
response=response,