fix touples
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2020-07-20 18:26:49 +02:00
parent 422a7efa6f
commit 08f652d189
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -38,7 +38,8 @@ class AllDevicesResource(Resource):
Shut down every device
:return:
"""
ids = db.session.query(models.Device.id).filter(models.Device.status != models.DeviceStatusEnum.offline)
query_ids = db.session.query(models.Device.id).filter(models.Device.status != models.DeviceStatusEnum.offline)
ids = [value for value, in query_ids]
for d_id in ids:
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": d_id, "command": "offline"})
@ -47,7 +48,8 @@ class AllDevicesResource(Resource):
Bring every device online
:return:
"""
ids = db.session.query(models.Device.id).filter(models.Device.status != models.DeviceStatusEnum.online)
query_ids = db.session.query(models.Device.id).filter(models.Device.status != models.DeviceStatusEnum.online)
ids = [value for value, in query_ids]
for d_id in ids:
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": d_id, "command": "online"})
@ -73,7 +75,7 @@ class DeviceResource(Resource):
:param deviceid: UUID of device
:return:
"""
device = db.session.query(models.Device.id).filter(str(models.Device.id) == deviceid).first()
device = db.session.query(models.Device.id).filter(str(models.Device.id) == deviceid).first_or_404()[0]
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": device, "command": "offline"})
def post(self, deviceid: str):
@ -82,7 +84,7 @@ class DeviceResource(Resource):
:param deviceid: UUID of device
:return:
"""
device = db.session.query(models.Device.id).filter(str(models.Device.id) == deviceid).first()
device = db.session.query(models.Device.id).filter(str(models.Device.id) == deviceid).first_or_404()[0]
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": device, "command": "offline"})
@ -110,8 +112,8 @@ class SensorResource(Resource):
:return:
"""
sensor = db.session.query(models.Sensor.device_id, models.Sensor.id).filter(
str(models.Sensor.device_id) == deviceid & & str(models.Sensor.id) == sensorid)
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": sensor, "sensorID": sensor, "command": "offline"})
str(models.Sensor.device_id) == deviceid and str(models.Sensor.id) == sensorid).first_or_404()
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": sensor[0], "sensorID": sensor[1], "command": "offline"})
def post(self, deviceid: str, sensorid: str):
"""
@ -121,5 +123,5 @@ class SensorResource(Resource):
:return:
"""
sensor = db.session.query(models.Sensor.device_id, models.Sensor.id).filter(
str(models.Sensor.device_id) == deviceid & & str(models.Sensor.id) == sensorid)
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": sensor, "sensorID": sensor, "command": "online"})
str(models.Sensor.device_id) == deviceid and str(models.Sensor.id) == sensorid).first_or_404()
mqtt.publish(config.MQTT_COMMAND_TOPIC, {"deviceID": sensor[0], "sensorID": sensor[1], "command": "online"})