Last active
January 18, 2022 17:41
-
-
Save depau/29d93eb59def8e9be339631fa930866a to your computer and use it in GitHub Desktop.
Kelon AC IR command decoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
MODES = { | |
0: "heat", | |
1: "smart", | |
2: "cool", | |
3: "dehum", | |
4: "fan" | |
} | |
FAN_SPEEDS = { | |
0: "auto", | |
1: "max", | |
2: "medium", | |
3: "min" | |
} | |
if __name__ == "__main__": | |
numstr = sys.argv[1] | |
num = int(numstr, 0) | |
num >>= 16 # Strip preamble | |
print(f"Fan speed: {FAN_SPEEDS[num & 0b11]}") | |
num >>= 2 | |
print(f"Power: {'pressed' if num & 1 else 'not pressed'}") | |
num >>= 1 | |
print(f"Sleep: {'on' if num & 1 else 'off'}") | |
num >>= 1 | |
print(f"Dehum intensity: {'-' if num & 0b100 == 0b100 else '+'}{num & 0b11}") | |
num >>= 3 | |
print(f"Swing: {'pressed' if num & 1 else 'not pressed'}") | |
num >>= 1 | |
print(f"Mode: {MODES[num & 0b111]}") | |
num >>= 3 | |
print(f"Timer: {'on' if num & 1 else 'off'}") | |
num >>= 1 | |
print(f"Temperature: {(num & 0b1111) + 18}°C") | |
num >>= 4 | |
timer_half = num & 1 | |
num >>= 1 | |
timer_hour = num & 0b111111 | |
num >>= 6 | |
timer_time = 0 | |
if timer_hour >= 10: | |
timer_time = (timer_hour << 1 | timer_half) - 10 | |
else: | |
timer_time = timer_hour + (0.5 if timer_half else 0) | |
print(f"Timer duration: {timer_time}h") | |
print(f"Smart mode: {'on' if num & 1 else 'off'}") | |
num >>= 5 # Also strip unknown always-zero bits | |
if num & 0b1001 == 0b1001: | |
print(f"Supercool mode: on") | |
elif num & 0b1000 == 0b1000 or num & 0b0001 == 0b0001: | |
print(f"Supercool mode might be on but wtf") | |
else: | |
print(f"Supercool mode: off") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment