加入空调控制
This commit is contained in:
parent
c702c85468
commit
e81fd65ae9
@ -27,6 +27,7 @@ class Config:
|
|||||||
ACTION_water_heater = '08f9e07db383'
|
ACTION_water_heater = '08f9e07db383'
|
||||||
ACTION_wen_xiang = '5ccf7fd6178a'
|
ACTION_wen_xiang = '5ccf7fd6178a'
|
||||||
ACTION_light = '840d8e9989dc'
|
ACTION_light = '840d8e9989dc'
|
||||||
|
ACTION_kongtiao = 'kongtiao'
|
||||||
|
|
||||||
# 程序变量
|
# 程序变量
|
||||||
RUN_FLAG = 1
|
RUN_FLAG = 1
|
||||||
|
|||||||
@ -28,6 +28,12 @@
|
|||||||
打开:CC AF
|
打开:CC AF
|
||||||
关闭:DD BF
|
关闭:DD BF
|
||||||
|
|
||||||
|
空调:
|
||||||
|
打开:FF 11
|
||||||
|
关闭:FF 22
|
||||||
|
遥控打开空调并开启制冷:FF 66(口令:打开制冷;对应红外第三组)
|
||||||
|
遥控关闭空调:FF 88 (口令:关闭制冷;对应红外第四组)
|
||||||
|
|
||||||
485 红外2:
|
485 红外2:
|
||||||
第一组:68 08 00 FF 12 00 11 16
|
第一组:68 08 00 FF 12 00 11 16
|
||||||
第二组:68 08 00 FF 12 01 12 16
|
第二组:68 08 00 FF 12 01 12 16
|
||||||
|
|||||||
33
main.py
33
main.py
@ -60,6 +60,11 @@ run = bytearray([0xAA, 0x55, 0x05, 0x55, 0xAA])
|
|||||||
# 校验整除
|
# 校验整除
|
||||||
check_code = bytearray([0xAA, 0x55, 0x04, 0x55, 0xAA])
|
check_code = bytearray([0xAA, 0x55, 0x04, 0x55, 0xAA])
|
||||||
|
|
||||||
|
# 打开制冷(第三组)
|
||||||
|
refrigeration_on = bytearray([0x68, 0x08, 0x00, 0xFF, 0x12, 0x02, 0x13, 0x16])
|
||||||
|
# 关闭制冷(第四组)
|
||||||
|
refrigeration_off = bytearray([0x68, 0x08, 0x00, 0xFF, 0x12, 0x03, 0x14, 0x16])
|
||||||
|
|
||||||
control = master_control.open_serial(Config.CONTROL_OPEN_SERIAL, 9600, 0.5)
|
control = master_control.open_serial(Config.CONTROL_OPEN_SERIAL, 9600, 0.5)
|
||||||
|
|
||||||
|
|
||||||
@ -119,7 +124,9 @@ def run_start_main(mqtt_client):
|
|||||||
|
|
||||||
elif (ser_cmd == 'd388') or (client.callback_result == 'd388'):
|
elif (ser_cmd == 'd388') or (client.callback_result == 'd388'):
|
||||||
master_control.infrared_sensor(control, infrared_control_off)
|
master_control.infrared_sensor(control, infrared_control_off)
|
||||||
|
glc.info('已关闭', gd)
|
||||||
client.callback_result = 'xxx'
|
client.callback_result = 'xxx'
|
||||||
|
|
||||||
# WIFI插座
|
# WIFI插座
|
||||||
elif (ser_cmd == 'bba1') or (client.callback_result == 'bba1'):
|
elif (ser_cmd == 'bba1') or (client.callback_result == 'bba1'):
|
||||||
action_cmd.action(client, Config.ACTION_socket, 'a1')
|
action_cmd.action(client, Config.ACTION_socket, 'a1')
|
||||||
@ -144,12 +151,35 @@ def run_start_main(mqtt_client):
|
|||||||
action_cmd.action(client, Config.ACTION_wen_xiang, 'a1')
|
action_cmd.action(client, Config.ACTION_wen_xiang, 'a1')
|
||||||
glc.info('电蚊香已打开', gd)
|
glc.info('电蚊香已打开', gd)
|
||||||
client.callback_result = 'xxx'
|
client.callback_result = 'xxx'
|
||||||
# 关闭热水器
|
# 关闭电蚊香
|
||||||
elif (ser_cmd == 'bbdf') or (client.callback_result == 'bbdf'):
|
elif (ser_cmd == 'bbdf') or (client.callback_result == 'bbdf'):
|
||||||
action_cmd.action(client, Config.ACTION_wen_xiang, 'b1')
|
action_cmd.action(client, Config.ACTION_wen_xiang, 'b1')
|
||||||
glc.info('电蚊香已关闭', gd)
|
glc.info('电蚊香已关闭', gd)
|
||||||
client.callback_result = 'xxx'
|
client.callback_result = 'xxx'
|
||||||
|
|
||||||
|
# 打开空调
|
||||||
|
elif (ser_cmd == 'ff11') or (client.callback_result == 'ff11'):
|
||||||
|
action_cmd.action(client, Config.ACTION_kongtiao, 'a1')
|
||||||
|
glc.info('空调已打开', gd)
|
||||||
|
client.callback_result = 'xxx'
|
||||||
|
# 关闭空调
|
||||||
|
elif (ser_cmd == 'ff22') or (client.callback_result == 'ff22'):
|
||||||
|
action_cmd.action(client, Config.ACTION_kongtiao, 'b1')
|
||||||
|
glc.info('空调已关闭', gd)
|
||||||
|
client.callback_result = 'xxx'
|
||||||
|
# 打开制冷
|
||||||
|
elif (ser_cmd == 'ff66') or (client.callback_result == 'ff66'):
|
||||||
|
su = master_control.infrared_sensor(control, refrigeration_on)
|
||||||
|
if su == 1:
|
||||||
|
glc.info('制冷模式已打开', gd)
|
||||||
|
client.callback_result = 'xxx'
|
||||||
|
# 关闭制冷
|
||||||
|
elif (ser_cmd == 'ff88') or (client.callback_result == 'ff88'):
|
||||||
|
su = master_control.infrared_sensor(control, refrigeration_off)
|
||||||
|
if su == 1:
|
||||||
|
glc.info('制冷模式已关闭', gd)
|
||||||
|
client.callback_result = 'xxx'
|
||||||
|
|
||||||
# 校验语音模块串口是否运行异常
|
# 校验语音模块串口是否运行异常
|
||||||
elif (ser_cmd == 'ffffffffff') or (client.callback_result == 'ffffffffff'):
|
elif (ser_cmd == 'ffffffffff') or (client.callback_result == 'ffffffffff'):
|
||||||
master_control.run_flage(voice, check_code, ser_cmd)
|
master_control.run_flage(voice, check_code, ser_cmd)
|
||||||
@ -188,6 +218,7 @@ if __name__ == '__main__':
|
|||||||
client.subscribe(Config.ACTION_socket)
|
client.subscribe(Config.ACTION_socket)
|
||||||
client.subscribe(Config.ACTION_water_heater)
|
client.subscribe(Config.ACTION_water_heater)
|
||||||
client.subscribe(Config.ACTION_wen_xiang)
|
client.subscribe(Config.ACTION_wen_xiang)
|
||||||
|
client.subscribe(Config.ACTION_kongtiao)
|
||||||
client.light_subscribe(Config.ACTION_light)
|
client.light_subscribe(Config.ACTION_light)
|
||||||
action_cmd.action(client, Config.ACTION_light, 'qc')
|
action_cmd.action(client, Config.ACTION_light, 'qc')
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,23 @@ def get_voice_data(ser_data):
|
|||||||
elif com_input.hex() == 'bbdf':
|
elif com_input.hex() == 'bbdf':
|
||||||
save_log.info(f'关闭电蚊香指令处理完返回,command:{com_input.hex()}')
|
save_log.info(f'关闭电蚊香指令处理完返回,command:{com_input.hex()}')
|
||||||
glc.info(f'关闭电蚊香指令处理完返回,command:{com_input.hex()}',gd)
|
glc.info(f'关闭电蚊香指令处理完返回,command:{com_input.hex()}',gd)
|
||||||
|
# 打开空调
|
||||||
|
elif com_input.hex() == 'ff11':
|
||||||
|
save_log.info(f'打开空调指令处理完返回,command:{com_input.hex()}')
|
||||||
|
glc.info(f'打开空调指令处理完返回,command:{com_input.hex()}', gd)
|
||||||
|
# 关闭电蚊香
|
||||||
|
elif com_input.hex() == 'ff22':
|
||||||
|
save_log.info(f'关闭空调指令处理完返回,command:{com_input.hex()}')
|
||||||
|
glc.info(f'关闭空调指令处理完返回,command:{com_input.hex()}', gd)
|
||||||
|
# 打开制冷
|
||||||
|
elif com_input.hex() == 'ff66':
|
||||||
|
save_log.info(f'打开制冷指令处理完返回,command:{com_input.hex()}')
|
||||||
|
glc.info(f'打开制冷指令处理完返回,command:{com_input.hex()}', gd)
|
||||||
|
# 关闭制冷
|
||||||
|
elif com_input.hex() == 'ff88':
|
||||||
|
save_log.info(f'关闭制冷指令处理完返回,command:{com_input.hex()}')
|
||||||
|
glc.info(f'关闭制冷指令处理完返回,command:{com_input.hex()}', gd)
|
||||||
|
|
||||||
elif com_input.hex() in ('', 'aa15', 'aa19', 'aa12', 'ffffffffff'):
|
elif com_input.hex() in ('', 'aa15', 'aa19', 'aa12', 'ffffffffff'):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user