|
@@ -407,15 +407,15 @@ class GatewayView(View):
|
|
|
智能插座开关状态推送
|
|
|
"""
|
|
|
try:
|
|
|
- switch_key = 'LOOCAM:SOCKET:SERIAL:NUMBER:{}'
|
|
|
+ switch_key = 'LOOCAM:SOCKET:SERIAL:NUMBER:{}:{}:{}'
|
|
|
redis_obj = RedisObject(db=7)
|
|
|
serial_number = request_dict.get('serialNumber', None)
|
|
|
device_time = request_dict.get('deviceTime', None)
|
|
|
status = request_dict.get('status', None)
|
|
|
- if not all([serial_number, status]):
|
|
|
+ if not all([serial_number, status, device_time]):
|
|
|
return response.json(444)
|
|
|
status = int(status)
|
|
|
- switch_key = switch_key.format(serial_number)
|
|
|
+ switch_key = switch_key.format(serial_number, status, device_time)
|
|
|
switch = redis_obj.get_data(switch_key)
|
|
|
if switch and int(switch) == status:
|
|
|
return response.json(0, "电源开关状态重复上报")
|
|
@@ -428,7 +428,7 @@ class GatewayView(View):
|
|
|
'created_time': now_time,
|
|
|
}
|
|
|
SceneLog.objects.create(**log_dict)
|
|
|
- redis_obj.set_data(switch_key, status, 60 * 3)
|
|
|
+ redis_obj.set_data(switch_key, status, 60 * 10)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
LOGGER.info('---插座开关日志推送接口异常--- {}'.format(repr(e)))
|