This commit is contained in:
parent
10eca03eb1
commit
ad567ba2d1
@ -48,9 +48,10 @@ app.config['MQTT_REFRESH_TIME'] = 1.0 # refresh time in seconds
|
|||||||
api = Api(app)
|
api = Api(app)
|
||||||
mqtt.init_app(app)
|
mqtt.init_app(app)
|
||||||
|
|
||||||
|
|
||||||
@mqtt.on_log()
|
@mqtt.on_log()
|
||||||
def handle_logging(client, userdata, level, buf):
|
def handle_logging(client, userdata, level, buf):
|
||||||
logger.log(level, buf)
|
app.logger.log(level, buf)
|
||||||
|
|
||||||
|
|
||||||
@mqtt.on_connect()
|
@mqtt.on_connect()
|
||||||
@ -67,8 +68,6 @@ def handle_status_message_proxy(*args, **kwargs):
|
|||||||
handle_status_message(*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(DeviceOfflineResrouce, "/devices/{deviceid}/offline")
|
||||||
api.add_resource(DeviceOnlineResrouce, "/devices/{deviceid}/online")
|
api.add_resource(DeviceOnlineResrouce, "/devices/{deviceid}/online")
|
||||||
api.add_resource(SensorOfflineResource, "/devices/{deviceid}/{sensorid}/offline")
|
api.add_resource(SensorOfflineResource, "/devices/{deviceid}/{sensorid}/offline")
|
||||||
|
@ -13,30 +13,6 @@ __module_name__ = "resources"
|
|||||||
__version__text__ = "1"
|
__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):
|
class DeviceOfflineResrouce(Resource):
|
||||||
"""
|
"""
|
||||||
Bring a device offline
|
Bring a device offline
|
||||||
|
Loading…
Reference in New Issue
Block a user