|
@@ -826,6 +826,7 @@ class SmartSceneView(View):
|
|
|
if not smart_scene_qs.exists():
|
|
|
return response.json(173)
|
|
|
|
|
|
+ # 下发智能场景数据
|
|
|
smart_scene_qs = smart_scene_qs.values('device_data')
|
|
|
topic_name = SMART_SCENE_TOPIC_NAME.format(serial_number)
|
|
|
for smart_scene in smart_scene_qs:
|
|
@@ -836,6 +837,26 @@ class SmartSceneView(View):
|
|
|
except AssertionError:
|
|
|
return response.json(10044)
|
|
|
time.sleep(1)
|
|
|
+
|
|
|
+ # 下发智能按钮数据
|
|
|
+ smart_button_qs = GatewaySubDevice.objects.filter(device_id=device_id, device_type=216).\
|
|
|
+ values('src_addr', 'is_tampered')
|
|
|
+ if smart_button_qs.exists():
|
|
|
+ sos_count = smart_button_qs.count()
|
|
|
+ for index, smart_button in enumerate(smart_button_qs):
|
|
|
+ msg = {
|
|
|
+ 'sos_count': sos_count, # 该网关下的智能按钮数量
|
|
|
+ 'sos_num': index + 1, # 第几个按钮
|
|
|
+ 'sensor_src': int(smart_button['src_addr'], 16),
|
|
|
+ 'sos_select': smart_button['is_tampered']
|
|
|
+ }
|
|
|
+ success = CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg, 0)
|
|
|
+ try:
|
|
|
+ assert success
|
|
|
+ except AssertionError:
|
|
|
+ return response.json(10044)
|
|
|
+ time.sleep(1)
|
|
|
+
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
return response.json(500, repr(e))
|