Skip to content

Commit

Permalink
Set the refrigerator target temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
ehn committed Jul 20, 2020
1 parent 2e6eed2 commit 31ba782
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
dist/
wideq_state.json
__pycache__
.vscode/
# Ignore Mac system files
.DS_Store
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ You can also specify one of several other commands:
* `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.
* `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.
* `ac-config <ID>`: Print out some configuration information about an AC device.

Expand Down
27 changes: 24 additions & 3 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,30 @@ def _force_device(client, device_id):


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))
ac.set_fahrenheit(int(temp))
device = client.get_device(device_id)

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):
Expand Down Expand Up @@ -163,6 +183,7 @@ def ac_config(client, device_id):
'mon': mon,
'ac-mon': ac_mon,
'set-temp': set_temp,
'set-temp-freezer': set_temp_freezer,
'turn': turn,
'ac-config': ac_config,
}
Expand Down

0 comments on commit 31ba782

Please sign in to comment.