def read_temp(_buff): _temp = [] _temp.append((_buff[14] >> 1) & 0x01) _temp.append((_buff[14] >> 2) & 0x01) _temp.append((_buff[14] >> 3) & 0x01) _temp.append((_buff[14] >> 4) & 0x01) _temp.append((_buff[14] >> 5) & 0x01) _temp.append((_buff[14] >> 6) & 0x01) temp = AC_IR.bit_to_int(_temp, 6, 0) return AC_IR.bit_to_int(_temp, 6, 0)
def read_fan(_buff): _fan = [None] * 3 _fan[0] = (_buff[6] >> 4) & 0x01 _fan[1] = (_buff[6] >> 5) & 0x01 _fan[2] = (_buff[6] >> 6) & 0x01 fan = AC_IR.bit_to_int(_fan, 3, 0) return fan
def read_fan(_buff): _fan = [None] * 3 _fan[0] = (_buff[8] >> 0) & 0x01 _fan[1] = (_buff[8] >> 1) & 0x01 _fan[2] = (_buff[8] >> 2) & 0x01 fan = AC_IR.bit_to_int(_fan, 3, 0) return fan
def read_mode(_buff): _mode = [None] * 3 _mode[0] = (_buff[6] >> 0) & 0x01 _mode[1] = (_buff[6] >> 1) & 0x01 _mode[2] = (_buff[6] >> 2) & 0x01 mode = AC_IR.bit_to_int(_mode, 3, 0) return mode
def read_mode(_buff): _mode = [] _mode.append((int)(_buff[12] >> 4) & 0x01) _mode.append((int)(_buff[12] >> 5) & 0x01) _mode.append((int)(_buff[12] >> 6) & 0x01) mode = AC_IR.bit_to_int(_mode, 3, 0) return mode
def read_mode(_buff): _mode = [] _mode[0] = ((_buff[12] >> 4) & 0x01) _mode[1] = ((_buff[12] >> 5) & 0x01) _mode[2] = ((_buff[12] >> 6) & 0x01) mode = AC_IR.bit_to_int(_mode, 3, 0) return mode
def read_swing(_buff): _swing = [None] * 3 _swing[0] = (_buff[8] >> 3) & 0x01 _swing[1] = (_buff[8] >> 4) & 0x01 _swing[2] = (_buff[8] >> 5) & 0x01 swing = AC_IR.bit_to_int(_swing, 3, 0) return swing
def read_swing(_buff): _swing = [None] * 3 _swing[0] = (_buff[4] >> 0) & 0x01 _swing[1] = (_buff[4] >> 1) & 0x01 _swing[2] = (_buff[4] >> 2) & 0x01 swing = AC_IR.bit_to_int(_swing, 3, 0) return swing
def read_fan(_buff): _fan = [] _fan.append(int((_buff[12] >> 1) & 0x01)) _fan.append(int((_buff[12] >> 2) & 0x01)) _fan.append(int((_buff[12] >> 3) & 0x01)) fan = AC_IR.bit_to_int(_fan, 3, 0) return fan
def read_mode(_buff): _mode = [None] * 3 _mode[0] = (_buff[12] >> 4) & 0x01 _mode[1] = (_buff[12] >> 5) & 0x01 _mode[2] = (_buff[12] >> 6) & 0x01 mode = AC_IR.bit_to_int(_mode, 3, 0) return _mode
def read_mode(_buff): _mode = [None] * 4 _mode[0] = (_buff[13] >> 4) & 0x01 _mode[1] = (_buff[13] >> 5) & 0x01 _mode[2] = (_buff[13] >> 6) & 0x01 _mode[3] = (_buff[13] >> 7) & 0x01 mode = AC_IR.bit_to_int(_mode, 4, 0) return mode
def read_swing(_buff): _swing = [] _swing.append((int)((_buff[9] >> 4) & 0x01)) _swing.append((int)((_buff[9] >> 5) & 0x01)) _swing.append((int)((_buff[9] >> 6) & 0x01)) _swing.append((int)((_buff[9] >> 7) & 0x01)) swing = AC_IR.bit_to_int(_swing, 4, 0) return swing
def read_temp(_buff): _temp = [None] * 4 _temp[0] = (_buff[2] >> 4) & 0x01 _temp[1] = (_buff[2] >> 5) & 0x01 _temp[2] = (_buff[2] >> 6) & 0x01 _temp[3] = (_buff[2] >> 7) & 0x01 temp = 15 + AC_IR.bit_to_int(_temp, 4, 0) return temp
def read_swing(_buff): _swing = [] _swing[0] = (int)((_buff[13] >> 4) & 0x01) _swing[1] = (int)((_buff[13] >> 5) & 0x01) _swing[2] = (int)((_buff[13] >> 6) & 0x01) _swing[3] = (int)((_buff[13] >> 7) & 0x01) swing = AC_IR.bit_to_int(_swing, 4, 0) return swing
def read_fan(_buff): _fan = [] _fan[0] = (int)((_buff[17] >> 0) & 0x01) _fan[1] = (int)((_buff[17] >> 1) & 0x01) _fan[2] = (int)((_buff[17] >> 2) & 0x01) _fan[3] = (int)((_buff[17] >> 3) & 0x01) fan = AC_IR.bit_to_int(_fan, 4, 0) return fan
def read_fan(_buff): _fan = [] _fan.append((_buff[16] << 4) & 0x01) _fan.append((_buff[16] << 5) & 0x01) _fan.append((_buff[16] << 6) & 0x01) _fan.append((_buff[16] << 7) & 0x01) fan = AC_IR.bit_to_int(_fan, 4, 0) return fan
def read_temp(_buff): _temp = [None] * 4 _temp[0] = (_buff[1] >> 0) & 0x01 _temp[1] = (_buff[1] >> 1) & 0x01 _temp[2] = (_buff[1] >> 2) & 0x01 _temp[3] = (_buff[1] >> 3) & 0x01 temp = 16 + AC_IR.bit_to_int(_temp, 4, 0) return temp
def read_swing(_buff): _swing = [None] * 4 _swing[0] = (_buff[16] >> 0) & 0x01 _swing[1] = (_buff[16] >> 1) & 0x01 _swing[2] = (_buff[16] >> 2) & 0x01 _swing[3] = (_buff[16] >> 3) & 0x01 swing = AC_IR.bit_to_int(_swing, 4, 0) return swing
def read_fan(_buff): _fan = [None] * 4 _fan[0] = (_buff[16] >> 4) & 0x01 _fan[1] = (_buff[16] >> 5) & 0x01 _fan[2] = (_buff[16] >> 6) & 0x01 _fan[3] = (_buff[16] >> 7) & 0x01 fan = AC_IR.bit_to_int(_fan, 4, 0) return fan
def read_fan(_buff): _fan = [] _fan.append((_buff[17] >> 0) & 0x01) _fan.append((_buff[17] >> 1) & 0x01) _fan.append((_buff[17] >> 2) & 0x01) _fan.append((_buff[17] >> 3) & 0x01) fan = AC_IR.bit_to_int(_fan, 4, 0) return fan
def read_swing(_buff): _swing = [] _swing.append((_buff[16] >> 0) & 0x01) _swing.append((_buff[16] >> 1) & 0x01) _swing.append((_buff[16] >> 2) & 0x01) _swing.append((_buff[16] >> 3) & 0x01) swing = AC_IR.bit_to_int(_swing, 4, 0) return swing
def read_temp(_buff): _temp = [] _temp.append((int)((_buff[11] >> 4) & 0x01)) _temp.append((int)((_buff[11] >> 5) & 0x01)) _temp.append((int)((_buff[11] >> 6) & 0x01)) _temp.append((int)((_buff[11] >> 7) & 0x01)) temp = 16 + AC_IR.bit_to_int(_temp, 4, 0) #print(temp) return temp
def read_temp(_buff): _temp = [None] * 5 _temp[0] = (_buff[1] >> 3) & 0x01 _temp[1] = (_buff[1] >> 4) & 0x01 _temp[2] = (_buff[1] >> 5) & 0x01 _temp[3] = (_buff[1] >> 6) & 0x01 _temp[4] = (_buff[1] >> 7) & 0x01 temp = 8 + AC_IR.bit_to_int(_temp, 5, 0) return temp
def read_temp(_buff): _temp = [] _temp.append((_buff[16] >> 1) & 0x01) _temp.append((_buff[16] >> 2) & 0x01) _temp.append((_buff[16] >> 3) & 0x01) _temp.append((_buff[16] >> 4) & 0x01) _temp.append((_buff[16] >> 5) & 0x01) temp = AC_IR.bit_to_int(_temp, 5, 0) temp = temp + 10 return temp
def read_temp(_buff): _temp = [] _temp[0] = (int)((_buff[16] >> 1) & 0x01) _temp[1] = (int)((_buff[16] >> 2) & 0x01) _temp[2] = (int)((_buff[16] >> 3) & 0x01) _temp[3] = (int)((_buff[16] >> 4) & 0x01) _temp[4] = (int)((_buff[16] >> 5) & 0x01) temp = AC_IR.bit_to_int(_temp, 5, 0) temp = temp + 10 return temp
def encode_daikin1(device): Daikin_template = "885BE40F0000004011DA2700003130007F000000000000C00000B2" DAIKIN_HDR_MARK_USER = "******" DAIKIN_HDR_SPACE_USER = "******" DAIKIN_BIT_MARK_USER = "******" DAIKIN_ONE_SPACE_USER = "******" DAIKIN_ZERO_SPACE_USER = "******" if device.swing == 0: _swing = 15 elif device.swing == 1: _swing = 0 else: _swing = 15 if device.mode == 0: _mode = 0 elif device.mode == 1: _mode = 4 elif device.mode == 2: _mode = 3 elif device.mode == 3: _mode = 2 elif device.mode == 4: _mode = 6 else: _mode = 0 if device.fan == 0: _fan = 10 elif device.fan == 1: _fan = 3 elif device.fan == 2: _fan = 4 elif device.fan == 3: _fan = 5 elif device.fan == 4: _fan = 6 elif device.fan == 5: _fan = 7 else: _fan = 10 _buff = AC_IR.hex_string_to_byte_array(Daikin_template) if device.mode == "off": _buff = switch_off(_buff) _buff = change_mode(_buff, _mode) if int(device.temp) == 0: _buff = temp_down(_buff) elif int(device.temp) == 1: _buff = temp_up(_buff) elif int(device.temp) == 2: pass elif ((int(device.temp) > 17) & (int(device.temp) < 33)): _buff = change_temp(_buff) else: pass _buff = change_fan(_buff, _fan) _buff = change_swing(_buff, _swing) else: _buff = switch_on(_buff) _buff = change_mode(_buff, _mode) if int(device.temp) == 0: _buff = temp_down(_buff) elif int(device.temp) == 1: _buff = temp_up(_buff) elif int(device.temp) == 2: pass elif ((int(device.temp) > 17) & (int(device.temp) < 33)): _buff = change_temp(_buff) else: pass _buff = change_fan(_buff, _fan) _buff = change_swing(_buff, _swing) cs = check_sum(_buff, 8, 26) str_raw = "" str_bin = "" for i in range(0, 8): str_bin += AC_IR.byte_to_string(_buff[i].to_bytes(1, 'big'), 1) for i in range(8, len(_buff)): str_bin += AC_IR.byte_to_string(_buff[i].to_bytes(1, 'big'), 0) str_bin += AC_IR.byte_to_string(cs.to_bytes(1, 'big'), 0) str_raw += DAIKIN_HDR_MARK_USER str_raw += ',' str_raw += DAIKIN_HDR_SPACE_USER str_raw += ',' for i in range(0, 8 * 8): str_raw += DAIKIN_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += DAIKIN_ONE_SPACE_USER str_raw += ',' else: str_raw += DAIKIN_ZERO_SPACE_USER str_raw += ',' str_raw += DAIKIN_BIT_MARK_USER str_raw += ',' str_raw += "29500" str_raw += ',' str_raw += DAIKIN_HDR_MARK_USER str_raw += ',' str_raw += DAIKIN_HDR_SPACE_USER str_raw += ',' for i in range(8 * 8, 27 * 8): str_raw += DAIKIN_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += DAIKIN_ONE_SPACE_USER str_raw += ',' else: str_raw += DAIKIN_ZERO_SPACE_USER str_raw += ',' str_raw += DAIKIN_BIT_MARK_USER str_raw += ',' str_raw += "0" str_raw = AC_IR.gz_base64_compress(str_raw) return str_raw
def encode_sumikura(device): Sumikura_template = "56740000210600000C000C2529114B" SUMIKURA_HDR_MARK_USER = "******" SUMIKURA_HDR_SPACE_USER = "******" SUMIKURA_BIT_MARK_USER = "******" SUMIKURA_ONE_SPACE_USER = "******" SUMIKURA_ZERO_SPACE_USER = "******" state = 1 if device.swing == "auto": _swing = 26 elif device.swing == "1": _swing = 6 elif device.swing == "2": _swing = 10 elif device.swing == "3": _swing = 14 elif device.swing == "4": _swing = 18 elif device.swing == "5": _swing = 22 else: _swing = 26 if device.mode == "cool": _mode = 2 elif device.mode == "heat": _mode = 3 elif device.mode == "fan_only": _mode = 5 else: _mode = 2 if device.fan == "auto": _fan = 0 elif device.fan == "1": _fan = 2 elif device.fan == "2": _fan = 3 elif device.fan == "3": _fan = 1 else: _fan = 0 str_raw = "" str_bin = "" _buff = AC_IR.hex_string_to_byte_array(Sumikura_template) if device.mode == "off": _buff = switch_off(_buff) _buff = change_mode(_buff, _mode) if (int)(device.temp) == 0: _buff = temp_down(_buff) elif (int)(device.temp) == 1: _buff = temp_up(_buff) elif (int)(device.temp) == 2: pass elif (int(device.temp) > 15) and (int(device.temp) < 33): _buff = change_temp(_buff, int(device.temp)) else: pass _buff = change_fan(_buff, _fan) _buff = change_swing(_buff, _swing) else: _buff = switch_on(_buff) _buff = change_mode(_buff, _mode) if int(device.temp) == 0: _buff = temp_down(_buff) elif int(device.temp) == 1: _buff = temp_up(_buff) elif int(device.temp) == 2: pass elif ((int(device.temp) > 15) and (int(device.temp) < 32)): _buff = change_temp(_buff, int(device.temp)) else: pass _buff = change_fan(_buff, _fan) _buff = change_swing(_buff, _swing) cs = check_sum(_buff, 0, len(_buff) - 1) _buff_temp = _buff _buff_temp.pop(len(_buff) - 1) str_bin = AC_IR.byte_to_string(_buff_temp, 0) str_bin += AC_IR.byte_to_string(cs.to_bytes(1, 'big'), 0) str_raw += SUMIKURA_HDR_MARK_USER str_raw += ',' str_raw += SUMIKURA_HDR_SPACE_USER str_raw += ',' for i in range(0, 15 * 8): str_raw += SUMIKURA_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SUMIKURA_ONE_SPACE_USER str_raw += ',' else: str_raw += SUMIKURA_ZERO_SPACE_USER str_raw += ',' str_raw += SUMIKURA_BIT_MARK_USER str_raw += ',' str_raw += "0" str_raw = AC_IR.gz_base64_compress(str_raw) return str_raw
def encode_funiki(device): Funiki_template = "38080060000100001020" FUNIKI_HDR_MARK_USER = "******" FUNIKI_HDR_SPACE_USER = "******" FUNIKI_BIT_MARK_USER = "******" FUNIKI_ONE_SPACE_USER = "******" FUNIKI_ZERO_SPACE_USER = "******" state = 1 _swing = device.swing _temp = (int)(device.temp) _fan = device.fan _mode = device.mode if _swing == "auto": _swing = 1 elif _swing == "1": _swing = 2 elif _swing == "2": _swing = 3 elif _swing == "3": _swing = 4 elif _swing == "4": _swing = 5 elif _swing == "5": _swing = 6 else: _swing = 1 if _mode == "heat": _mode = 2 elif _mode == "cool": _mode = 0 elif _mode == "dry": _mode = 3 elif _mode == "fan_only": _mode = 1 else: _mode = 0 if _fan == "auto": _fan = 0 elif _fan == "1": _fan = 1 elif _fan == "2": _fan = 2 elif _fan == "3": _fan = 3 else: _fan = 0 _buff = AC_IR.hex_string_to_byte_array(Funiki_template) if __debug__: print(_buff) if device.mode == "off": _buff = switch_off(_buff) _buff = change_mode(_buff, _mode) if _temp == 0: _buff = temp_down(_buff) elif _temp == 1: _buff = temp_up(_buff) elif _temp == 2: pass elif (_temp > 15) and (_temp < 32): _buff = change_temp(_buff, _temp) else: pass _buff = change_fan(_buff, _fan) _buff = change_swing(_buff, _swing) else: _buff = switch_on(_buff) _buff = change_mode(_buff, _mode) if _temp == 0: _buff = temp_down(_buff) elif _temp == 1: _buff = temp_up(_buff) elif _temp == 2: pass elif (_temp > 15) and (_temp < 32): _buff = change_temp(_buff, _temp) else: pass _buff = change_fan(_buff, _fan) _buff = change_swing(_buff, _swing) str_raw = "" str_bin = "" for i in range(0, len(_buff)): str_bin += AC_IR.byte_to_string(_buff[i].to_bytes(1, 'big'), 0) str_raw += FUNIKI_HDR_MARK_USER str_raw += ',' str_raw += FUNIKI_HDR_SPACE_USER str_raw += ',' for i in range(0, 8 * 10): str_raw += FUNIKI_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += FUNIKI_ONE_SPACE_USER str_raw += ',' else: str_raw += FUNIKI_ZERO_SPACE_USER str_raw += ',' str_raw += FUNIKI_BIT_MARK_USER str_raw += ',' str_raw += FUNIKI_ONE_SPACE_USER str_raw += ',' str_raw += FUNIKI_BIT_MARK_USER str_raw += ',' str_raw += FUNIKI_ZERO_SPACE_USER str_raw += ',' str_raw += FUNIKI_BIT_MARK_USER str_raw += ',' str_raw += FUNIKI_ONE_SPACE_USER str_raw += ',' str_raw += FUNIKI_BIT_MARK_USER str_raw += ',' str_raw += "0" str_raw = AC_IR.gz_base64_compress(str_raw) return str_raw
def read_mode(_buff): _mode = [None] * 2 _mode[0] = (_buff[0] >> 6) & 0x01 _mode[1] = (_buff[0] >> 7) & 0x01 mode = AC_IR.bit_to_int(_mode, 2, 0) return mode
def encode_samsung(device): samsung_template = "02920F000000F001D2FE718019F001C2FE71C015F0" samsung_template_on = "02920F000000F001D20E0000000001C2FE71C015F0" samsung_template_off = "02B20F000000C001D20F0000000001E2FE719015C0" SAMSUNG_HDR_MARK_USER = "******" SAMSUNG_HDR_SPACE_USER = "******" SAMSUNG_BIT_MARK_USER = "******" SAMSUNG_ONE_SPACE_USER = "******" SAMSUNG_ZERO_SPACE_USER = "******" state = 1 if device.swing == "off": _swing = 10 elif device.swing == "swing": _swing = 15 else: _swing = 15 if device.mode == "auto": _mode = 0 elif device.mode == "fan_only": _mode = 4 elif device.mode == "dry": _mode = 1 elif device.mode == "cool": _mode = 2 elif device.mode == "heat": _mode = 3 else: _mode = 0 if device.fan == "auto": _fan = 0 elif device.fan == "1": _fan = 2 elif device.fan == "2": _fan = 4 elif device.fan == "3": _fan = 5 else: _fan = 0 str_raw = "" str_bin = "" _buff_header = AC_IR.hex_string_to_byte_array(samsung_template) _buff_on = AC_IR.hex_string_to_byte_array(samsung_template_on) _buff_off = AC_IR.hex_string_to_byte_array(samsung_template_off) if device.mode == "off": _buff_off = switch_off(_buff_off) for i in range(0, len(_buff_off)): str_bin += AC_IR.byte_to_string(_buff_off[i].to_bytes(1, 'big'), 0) str_raw += SAMSUNG_HDR_MARK_USER str_raw += ',' str_raw += SAMSUNG_HDR_SPACE_USER str_raw += ',' for i in range(7 * 8): str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SAMSUNG_ONE_SPACE_USER str_raw += ',' else: str_raw += SAMSUNG_ZERO_SPACE_USER str_raw += ',' str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' str_raw += "3000" str_raw += ',' str_raw += SAMSUNG_HDR_MARK_USER str_raw += ',' str_raw += SAMSUNG_HDR_SPACE_USER str_raw += ',' for i in range(7 * 8, 14 * 8): str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SAMSUNG_ONE_SPACE_USER str_raw += ',' else: str_raw += SAMSUNG_ZERO_SPACE_USER str_raw += ',' str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' str_raw += "3000" str_raw += ',' str_raw += SAMSUNG_HDR_MARK_USER str_raw += ',' str_raw += SAMSUNG_HDR_SPACE_USER str_raw += ',' for i in range(14 * 8, 21 * 8): str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SAMSUNG_ONE_SPACE_USER str_raw += ',' else: str_raw += SAMSUNG_ZERO_SPACE_USER str_raw += ',' str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' str_raw += "0" else: _buff_on = switch_on(_buff_on) _buff_on = change_mode(_buff_on, _mode) if (int)(device.temp) == 0: _buff_on = temp_down(_buff_on) elif (int)(device.temp) == 1: _buff_on = temp_up(_buff_on) elif (int)(device.temp) == 2: pass elif (((int)(device.temp) > 15) and ((int)(device.temp) < 31)): _buff_on = change_temp(_buff_on, (int)(device.temp)) else: pass _buff_on = change_fan(_buff_on, _fan) _buff_on = change_swing(_buff_on, _swing) checksum = 0x00 samsungByte = [] for j in range(10, 14): samsungByte = _buff_on[j] if j == 2: samsungByte &= 0b11111110 for i in range(0, 8): if ((samsungByte & 0x01) == 1): checksum += 1 samsungByte >> 1 checksum = 28 - checksum checksum << 4 checksum |= 0x02 _buff_on[8] = checksum str_bin = AC_IR.byte_to_string(_buff_on, 0) str_raw += SAMSUNG_HDR_MARK_USER str_raw += ',' str_raw += SAMSUNG_HDR_SPACE_USER str_raw += ',' for i in range(0, 7 * 8): str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SAMSUNG_ONE_SPACE_USER str_raw += ',' else: str_raw += SAMSUNG_ZERO_SPACE_USER str_raw += ',' str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' str_raw += "3000" str_raw += ',' str_raw += SAMSUNG_HDR_MARK_USER str_raw += ',' str_raw += SAMSUNG_HDR_SPACE_USER str_raw += ',' for i in range(7 * 8, 14 * 8): str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SAMSUNG_ONE_SPACE_USER str_raw += ',' else: str_raw += SAMSUNG_ZERO_SPACE_USER str_raw += ',' str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' str_raw += "3000" str_raw += ',' str_raw += SAMSUNG_HDR_MARK_USER str_raw += ',' str_raw += SAMSUNG_HDR_SPACE_USER str_raw += ',' for i in range(14 * 8, 21 * 8): str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' if str_bin[i] == '1': str_raw += SAMSUNG_ONE_SPACE_USER str_raw += ',' else: str_raw += SAMSUNG_ZERO_SPACE_USER str_raw += ',' str_raw += SAMSUNG_BIT_MARK_USER str_raw += ',' str_raw += "0" str_raw = AC_IR.gz_base64_compress(str_raw) return str_raw