-
-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extended Air Conditioning Companion support #169
Changes from 7 commits
118acaf
aa628dd
c0a182b
40ba5c8
b87307a
6c0071e
0b8197b
f7c0edb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
|
||
|
||
class OperationMode(enum.Enum): | ||
Heating = 0 | ||
Cooling = 1 | ||
Heat = 0 | ||
Cool = 1 | ||
Auto = 2 | ||
Dehumidify = 3 | ||
Ventilate = 4 | ||
|
||
|
||
class FanSpeed(enum.Enum): | ||
|
@@ -16,7 +18,56 @@ class FanSpeed(enum.Enum): | |
Auto = 3 | ||
|
||
|
||
class SwingMode(enum.Enum): | ||
On = 0 | ||
Off = 1 | ||
|
||
|
||
class Power(enum.Enum): | ||
On = 1 | ||
Off = 0 | ||
|
||
|
||
STORAGE_SLOT_ID = 30 | ||
POWER_OFF = 'off' | ||
|
||
# Command templates per model number (f.e. 0180111111) | ||
# po, mo, wi, sw, tt, t1t, t4t and t7t are markers which will be replaced | ||
DEVICE_COMMAND_TEMPLATES = { | ||
'fallback': { | ||
'deviceType': 'generic', | ||
'base': 'pomowiswtta0' | ||
}, | ||
'0180111111': { | ||
'deviceType': 'media_1', | ||
'base': 'pomowiswtt02' | ||
}, | ||
'0180222221': { | ||
'deviceType': 'gree_1', | ||
'base': 'pomowiswtt02' | ||
}, | ||
'0100010727': { | ||
'deviceType': 'gree_2', | ||
'base': 'pomowiswtt1100190t1t205002102000t7t0190t1t207002000000t4t0', | ||
'off': '01011101004000205002112000D04000207002000000A0' | ||
}, | ||
'0100004795': { | ||
'deviceType': 'gree_8', | ||
'base': 'pomowiswtt0100090900005002' | ||
}, | ||
'0180333331': { | ||
'deviceType': 'haier_1', | ||
'base': 'pomowiswtt12' | ||
}, | ||
'0180666661': { | ||
'deviceType': 'aux_1', | ||
'base': 'pomowiswtt12' | ||
}, | ||
'0180777771': { | ||
'deviceType': 'chigo_1', | ||
'base': 'pomowiswtt12' | ||
} | ||
} | ||
|
||
|
||
class AirConditioningCompanionStatus: | ||
|
@@ -109,3 +160,40 @@ def send_command(self, command: str): | |
|
||
:param str command: Command to execute""" | ||
return self.send("send_cmd", [str(command)]) | ||
|
||
def send_configuration(self, model: str, power: Power, | ||
operation_mode: OperationMode, | ||
target_temperature: float, fan_speed: FanSpeed, | ||
swing_mode: SwingMode): | ||
|
||
# Static turn off command available? | ||
if (power is False) and (model in DEVICE_COMMAND_TEMPLATES) and \ | ||
(POWER_OFF in DEVICE_COMMAND_TEMPLATES[model]): | ||
return self.send_command( | ||
model + DEVICE_COMMAND_TEMPLATES[model][POWER_OFF]) | ||
|
||
if model in DEVICE_COMMAND_TEMPLATES: | ||
configuration = model + DEVICE_COMMAND_TEMPLATES[model]['base'] | ||
else: | ||
configuration = model + DEVICE_COMMAND_TEMPLATES['fallback']['base'] | ||
|
||
configuration = configuration.replace('po', power.value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a suggestion, would it be better to replace placeholders with something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! |
||
configuration = configuration.replace('mo', operation_mode.value) | ||
configuration = configuration.replace('wi', fan_speed.value) | ||
configuration = configuration.replace('sw', swing_mode.value) | ||
configuration = configuration.replace( | ||
'tt', hex(int(target_temperature))[2:]) | ||
|
||
temperature = (1 + int(target_temperature) - 17) % 16 | ||
temperature = hex(temperature)[2:].upper() | ||
configuration = configuration.replace('t1t', temperature) | ||
|
||
temperature = (4 + int(target_temperature) - 17) % 16 | ||
temperature = hex(temperature)[2:].upper() | ||
configuration = configuration.replace('t4t', temperature) | ||
|
||
temperature = (7 + int(target_temperature) - 17) % 16 | ||
temperature = hex(temperature)[2:].upper() | ||
configuration = configuration.replace('t7t', temperature) | ||
|
||
return self.send_command(configuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)