1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-06-01 23:10:14 -07:00

remove ac-mon command from example.py

remove ac-mon command, use only 'mon' command as generic command for any device
This commit is contained in:
pifou 2020-10-28 22:33:42 +01:00
parent db6c6f631b
commit 649299eacf

View File

@ -34,9 +34,9 @@ def ls(client):
print('{0.id}: {0.name} ({0.type.name} {0.model_id})'.format(device)) print('{0.id}: {0.name} ({0.type.name} {0.model_id})'.format(device))
def mon(client, device_id): def gen_mon(client, device_id):
"""Monitor any device, displaying generic information about its """Monitor any other device but AC device,
status. displaying generic information about its status.
""" """
device = client.get_device(device_id) device = client.get_device(device_id)
@ -72,16 +72,11 @@ def mon(client, device_id):
pass pass
def ac_mon(client, device_id): def ac_mon(ac):
"""Monitor an AC/HVAC device, showing higher-level information about """Monitor an AC/HVAC device, showing higher-level information about
its status such as its temperature and operation mode. its status such as its temperature and operation mode.
""" """
ac = client.get_device_class(device_id)
if not isinstance(ac, 'ACDevice'):
print('This is not an AC device.')
return
try: try:
ac.monitor_start() ac.monitor_start()
except wideq.core.NotConnectedError: except wideq.core.NotConnectedError:
@ -104,6 +99,8 @@ def ac_mon(client, device_id):
'on' if state.is_on else 'off' 'on' if state.is_on else 'off'
) )
) )
else:
print('no state. Wait 1 more second.')
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
@ -111,6 +108,18 @@ def ac_mon(client, device_id):
ac.monitor_stop() ac.monitor_stop()
def mon(client, device_id):
"""Monitor any device, displaying generic information about its
status.
"""
device_class = client.get_device_class(device_id)
if isinstance(device_class, wideq.ACDevice):
ac_mon(device_class)
else:
gen_mon(client, device_id)
class UserError(Exception): class UserError(Exception):
"""A user-visible command-line error. """A user-visible command-line error.
""" """
@ -183,7 +192,6 @@ def ac_config(client, device_id):
EXAMPLE_COMMANDS = { EXAMPLE_COMMANDS = {
'ls': ls, 'ls': ls,
'mon': mon, 'mon': mon,
'ac-mon': ac_mon,
'set-temp': set_temp, 'set-temp': set_temp,
'set-temp-freezer': set_temp_freezer, 'set-temp-freezer': set_temp_freezer,
'turn': turn, 'turn': turn,