Skip to content

Commit

Permalink
bd alarmas
Browse files Browse the repository at this point in the history
  • Loading branch information
afpinzon10 committed May 19, 2018
1 parent 7433f38 commit dad2ad7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion EntidadVirtual/API_REST/insercion_alarmas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask
import paho.mqtt.client as paho
from datetime import date as d

user = mqtt_connect.Client("C1")

Expand All @@ -8,7 +9,16 @@

def on_message(user, data, message):
alarmas = mongo.db.alarmas
if
data = '{"fecha":"' + d.day + '/' + d.month + '/' + d.year + ', "cerradura":1 , "immueble": 1, "conjunto": 1, "tipo": '
if "P2" in message:
data = data + '"Acceso no permitido" }'
alarmas.insert(data)
if "S1" in message:
data = data + '"Intento de apertura sospechoso" }'
alarmas.insert(data)
if "M1" in message:
data = data + '"Movimiento detectado" }'
alarmas.insert(data)


user.on_message = on_message
Expand Down
5 changes: 3 additions & 2 deletions EntidadVirtual/API_REST/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def insert_cerradura():
hora_inicio = request.json['hora_inicio']
hora_fin = request.json['hora_fin']

nuevo_candado = "0;"+password+";"+posicion;

nuevo_candado = "0;"+password+";"+posicion
user.on_message = on_message
user.loop_start()
#hl.agregar_candado(hora_inicio, hora_fin, posicion)
hl.agregar_candado(hora_inicio, hora_fin, posicion)
client.publish(topico, nuevo_candado)
Expand Down
1 change: 1 addition & 0 deletions EntidadVirtual/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time



def funt():
server.app.run()

Expand Down

0 comments on commit dad2ad7

Please sign in to comment.