diff --git a/src/app.py b/src/app.py index 2b64c86..d8b2432 100644 --- a/src/app.py +++ b/src/app.py @@ -48,9 +48,10 @@ app.config['MQTT_REFRESH_TIME'] = 1.0 # refresh time in seconds api = Api(app) mqtt.init_app(app) + @mqtt.on_log() def handle_logging(client, userdata, level, buf): - logger.log(level, buf) + app.logger.log(level, buf) @mqtt.on_connect() @@ -67,8 +68,6 @@ def handle_status_message_proxy(*args, **kwargs): handle_status_message(*args, **kwargs) -api.add_resource(AllDevicesOfflineResource, "/devices/offline") -api.add_resource(AllDevicesOnlineResource, "/devices/online") api.add_resource(DeviceOfflineResrouce, "/devices/{deviceid}/offline") api.add_resource(DeviceOnlineResrouce, "/devices/{deviceid}/online") api.add_resource(SensorOfflineResource, "/devices/{deviceid}/{sensorid}/offline") diff --git a/src/resources.py b/src/resources.py index da16ce3..4d1c1eb 100644 --- a/src/resources.py +++ b/src/resources.py @@ -13,30 +13,6 @@ __module_name__ = "resources" __version__text__ = "1" -class AllDevicesOfflineResource(Resource): - """ - Shut down all devices - """ - def post(self): - """ - Shut down every device - :return: - """ - mqtt.publish(f"{config.MQTT_COMMAND_TOPIC}/+", {"command": "offline"}) - - -class AllDevicesOnlineResource(Resource): - """ - Bring every device online - """ - def post(self): - """ - Bring every device online - :return: - """ - mqtt.publish(f"{config.MQTT_COMMAND_TOPIC}/+", {"command": "online"}) - - class DeviceOfflineResrouce(Resource): """ Bring a device offline