|
@@ -67,10 +67,11 @@ class SmartSwitchView(View):
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@staticmethod
|
|
|
- def get_switch_setting(request_dict, response):
|
|
|
+ def get_switch_setting(request_dict, response, user_id):
|
|
|
"""
|
|
|
获取智能开关设备设置信息
|
|
|
@param request_dict: 请求参数
|
|
|
+ @param user_id: 用戶user_id
|
|
|
@request_dict deviceId: 设备id
|
|
|
@param response: 响应对象
|
|
|
@return: response
|
|
@@ -99,6 +100,17 @@ class SmartSwitchView(View):
|
|
|
|
|
|
@staticmethod
|
|
|
def edit_switch_setting(request_dict, response):
|
|
|
+ """
|
|
|
+ 修改智能开关设备设置
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @request_dict deviceId: 设备id
|
|
|
+ @request_dict deviceNickname: 设备名称
|
|
|
+ @request_dict location: 位置
|
|
|
+ @request_dict led: LED指示灯
|
|
|
+ @request_dict dimmingCorrection: 调光校正
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
device_id = request_dict.get('deviceId', None)
|
|
|
device_nick_name = request_dict.get('deviceNickname', None)
|
|
|
location = request_dict.get('location', None)
|
|
@@ -110,12 +122,110 @@ class SmartSwitchView(View):
|
|
|
try:
|
|
|
switch_setting_data = {
|
|
|
'device_id': device_id,
|
|
|
- 'device_nick_name': device_nick_name,
|
|
|
- 'location': location,
|
|
|
'led': led,
|
|
|
'dimming_correction': dimming_correction,
|
|
|
}
|
|
|
- SwitchChronopher.objects.filter(device_id=device_id).update(**switch_setting_data)
|
|
|
+ SwitchDimmingSettings.objects.filter(device_id=device_id).update(**switch_setting_data)
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def edit_dimming_setting(request_dict, response):
|
|
|
+ """
|
|
|
+ 修改智能开关调光设置
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @request_dict deviceId: 设备id
|
|
|
+ @request_dict clickTurnOnSpeed: 单击开启速度
|
|
|
+ @request_dict clickTurnOffSpeed: 单击关闭速度
|
|
|
+ @request_dict doubleClick: 双击
|
|
|
+ @request_dict press: 长按
|
|
|
+ @request_dict doublePressClickTurnOnSpeed: 双击/长按开启速度
|
|
|
+ @request_dict doublePressClickTurnOffSpeed: 双击/长按单击关闭速度
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
+ device_id = request_dict.get('deviceId', None)
|
|
|
+ click_turn_on_speed = request_dict.get('clickTurnOnSpeed', None)
|
|
|
+ click_turn_off_speed = request_dict.get('clickTurnOffSpeed', None)
|
|
|
+ double_click = request_dict.get('doubleClick', None)
|
|
|
+ press = request_dict.get('press', None)
|
|
|
+ double_press_click_turn_on_speed = request_dict.get('doublePressClickTurnOnSpeed', None)
|
|
|
+ double_press_click_turn_off_speed = request_dict.get('doublePressClickTurnOffSpeed', None)
|
|
|
+
|
|
|
+ if not device_id:
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
+ dimming_setting_data = {
|
|
|
+ 'device_id': device_id,
|
|
|
+ 'click_turn_on_speed': click_turn_on_speed,
|
|
|
+ 'click_turn_off_speed': click_turn_off_speed,
|
|
|
+ 'double_click': double_click,
|
|
|
+ 'press': press,
|
|
|
+ 'double_press_click_turn_on_speed': double_press_click_turn_on_speed,
|
|
|
+ 'double_press_click_turn_off_speed': double_press_click_turn_off_speed
|
|
|
+ }
|
|
|
+ SwitchDimmingSettings.objects.filter(device_id=device_id).update(**dimming_setting_data)
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def get_location_list(request_dict, response):
|
|
|
+ """
|
|
|
+ 获取房间列表
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @request_dict deviceId: 设备id
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
+ device_id = request_dict.get('deviceId', None)
|
|
|
+ if not device_id:
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
+ room_list_qs = SwitchDimmingSettings.objects.filter(device_id=device_id).values('location', 'location_list')
|
|
|
+ res = {
|
|
|
+ 'location': room_list_qs[0]['location'],
|
|
|
+ 'locationList': room_list_qs[0]['location_list']
|
|
|
+ }
|
|
|
+ return response.json(0, res)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def add_location(request_dict, response):
|
|
|
+ """
|
|
|
+ 添加房间
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @request_dict deviceId: 设备id
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
+ room_name = request_dict.get('roomName', None)
|
|
|
+ if not room_name:
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def delete_location(request_dict, response):
|
|
|
+ """
|
|
|
+ 删除房间
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @request_dict deviceId: 设备id
|
|
|
+ @param response: 响应对象
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
+ room_name = request_dict.get('roomName', None)
|
|
|
+ if not room_name:
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
print(e)
|