|
@@ -907,6 +907,26 @@ class SmartSocketView(View):
|
|
|
return response.json(444)
|
|
|
# 同步数据库并下发MQTT消息到插座设备
|
|
|
try:
|
|
|
+ # 判断设备是否在线
|
|
|
+ thing_name = 'LC_' + serial_number
|
|
|
+ if 'test' == CONFIG_INFO or CONFIG_INFO == 'cn':
|
|
|
+ iot_data_plane = AWSIoTDataPlaneService(AWS_IOT_SES_ACCESS_CHINA_ID,
|
|
|
+ AWS_IOT_SES_ACCESS_CHINA_SECRET,
|
|
|
+ AWS_IOT_SES_ACCESS_CHINA_REGION)
|
|
|
+
|
|
|
+ elif 'us' == CONFIG_INFO:
|
|
|
+ iot_data_plane = AWSIoTDataPlaneService(AWS_IOT_SES_ACCESS_FOREIGN_ID,
|
|
|
+ AWS_IOT_SES_ACCESS_FOREIGN_SECRET,
|
|
|
+ AWS_IOT_SES_ACCESS_FOREIGN_REGION_AMERICA)
|
|
|
+ else:
|
|
|
+ iot_data_plane = AWSIoTDataPlaneService(AWS_IOT_SES_ACCESS_FOREIGN_ID,
|
|
|
+ AWS_IOT_SES_ACCESS_FOREIGN_SECRET,
|
|
|
+ AWS_IOT_SES_ACCESS_FOREIGN_REGION_EUROPE)
|
|
|
+ res = iot_data_plane.get_thing_shadow(thing_name)
|
|
|
+ if not res:
|
|
|
+ return response.json(173)
|
|
|
+ if not res['state']['reported']['online']:
|
|
|
+ return response.json(173)
|
|
|
socket_info_qs = SocketInfo.objects.filter(serial_number=serial_number).values('status')
|
|
|
if socket_info_qs.exists():
|
|
|
res = {
|