diff --git a/.gitignore b/.gitignore index d4f68ed..71be0c3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ dist/ wideq_state.json __pycache__ +.vscode/ # Ignore Mac system files .DS_Store diff --git a/README.md b/README.md index cf71f0e..415e53a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/example.py b/example.py index f2ab39d..4de6e9a 100755 --- a/example.py +++ b/example.py @@ -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): @@ -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, }