|
@@ -1365,10 +1365,12 @@ class SmartSceneView(View):
|
|
|
def int_to_weeks(repeat, is_next_day=False):
|
|
|
"""
|
|
|
十进制转星期周期
|
|
|
- @param repeat: 星期周期二进制的十进制数,低到高位表示周一到周日,如64 -> 100 0000 -> 周日
|
|
|
+ @param repeat: 星期周期的十进制数,如127 -> 每天 -> 0,1,2,3,4,5,6或*
|
|
|
@param is_next_day: 是否隔天
|
|
|
@return: weeks
|
|
|
"""
|
|
|
+ if repeat == 127:
|
|
|
+ return '*'
|
|
|
# 十进制转为7位的二进制并倒序
|
|
|
bin_str = bin(repeat)[2:].zfill(7)[::-1]
|
|
|
# 生成星期周期字符串
|
|
@@ -1376,9 +1378,10 @@ class SmartSceneView(View):
|
|
|
next_day = 1 if is_next_day else 0
|
|
|
for i, bit in enumerate(bin_str):
|
|
|
if bit == '1':
|
|
|
- week = i + 1 + next_day
|
|
|
- if week == 8:
|
|
|
- week = 1
|
|
|
+ # 7 -> 0
|
|
|
+ week = i + next_day
|
|
|
+ if week == 7:
|
|
|
+ week = 0
|
|
|
weeks += str(week) + ','
|
|
|
# 删除最后一个逗号并返回结果
|
|
|
return weeks[:-1]
|