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:
commit
ee8866b7d1
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,5 +3,6 @@
|
||||
dist/
|
||||
wideq_state.json
|
||||
__pycache__
|
||||
.vscode/
|
||||
# Ignore Mac system files
|
||||
.DS_Store
|
||||
|
@ -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.
|
||||
|
||||
|
27
example.py
27
example.py
@ -131,10 +131,34 @@ 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."""
|
||||
|
||||
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):
|
||||
@ -163,6 +187,7 @@ EXAMPLE_COMMANDS = {
|
||||
'mon': mon,
|
||||
'ac-mon': ac_mon,
|
||||
'set-temp': set_temp,
|
||||
'set-temp-freezer': set_temp_freezer,
|
||||
'turn': turn,
|
||||
'ac-config': ac_config,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user