1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-05-16 07:10:09 -07:00

Merge pull request #114 from ehn/master

Set the refrigerator target temperature
This commit is contained in:
Adrian Sampson 2020-07-20 08:56:26 -04:00 committed by GitHub
commit ee8866b7d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 4 deletions

1
.gitignore vendored
View File

@ -3,5 +3,6 @@
dist/ dist/
wideq_state.json wideq_state.json
__pycache__ __pycache__
.vscode/
# Ignore Mac system files # Ignore Mac system files
.DS_Store .DS_Store

View File

@ -23,7 +23,8 @@ You can also specify one of several other commands:
* `ls`: List devices (the default). * `ls`: List devices (the default).
* `mon <ID>`: Monitor a device continuously, printing out status information until you type control-C. Provide a device ID obtained from listing your devices. * `mon <ID>`: Monitor a device continuously, printing out status information until you type control-C. Provide a device ID obtained from listing your devices.
* `ac-mon <ID>`: Like `mon`, but only for AC devices---prints out specific climate-related information in a more readable form. * `ac-mon <ID>`: Like `mon`, but only for AC devices---prints out specific climate-related information in a more readable form.
* `set-temp <ID> <TEMP>`: Set the target temperature for an AC device. * `set-temp <ID> <TEMP>`: Set the target temperature for an AC or refrigerator device.
* `set-temp-freezer <ID> <TEMP>`: Set the target freezer temperature for a refrigerator.
* `turn <ID> <ONOFF>`: Turn an AC device on or off. Use "on" or "off" as the second argument. * `turn <ID> <ONOFF>`: Turn an AC device on or off. Use "on" or "off" as the second argument.
* `ac-config <ID>`: Print out some configuration information about an AC device. * `ac-config <ID>`: Print out some configuration information about an AC device.

View File

@ -131,10 +131,34 @@ def _force_device(client, device_id):
def set_temp(client, device_id, temp): def set_temp(client, device_id, temp):
"""Set the configured temperature for an AC device.""" """Set the configured temperature for an AC or refrigerator device."""
ac = wideq.ACDevice(client, _force_device(client, device_id)) device = client.get_device(device_id)
ac.set_fahrenheit(int(temp))
if device.type == wideq.client.DeviceType.AC:
ac = wideq.ACDevice(client, _force_device(client, device_id))
ac.set_fahrenheit(int(temp))
elif device.type == wideq.client.DeviceType.REFRIGERATOR:
refrigerator = wideq.RefrigeratorDevice(
client, _force_device(client, device_id))
refrigerator.set_temp_refrigerator_c(int(temp))
else:
raise UserError(
'set-temp only suported for AC or refrigerator devices')
def set_temp_freezer(client, device_id, temp):
"""Set the configured freezer temperature for a refrigerator device."""
device = client.get_device(device_id)
if device.type == wideq.client.DeviceType.REFRIGERATOR:
refrigerator = wideq.RefrigeratorDevice(
client, _force_device(client, device_id))
refrigerator.set_temp_freezer_c(int(temp))
else:
raise UserError(
'set-temp-freezer only suported for refrigerator devices')
def turn(client, device_id, on_off): def turn(client, device_id, on_off):
@ -163,6 +187,7 @@ EXAMPLE_COMMANDS = {
'mon': mon, 'mon': mon,
'ac-mon': ac_mon, 'ac-mon': ac_mon,
'set-temp': set_temp, 'set-temp': set_temp,
'set-temp-freezer': set_temp_freezer,
'turn': turn, 'turn': turn,
'ac-config': ac_config, 'ac-config': ac_config,
} }