From 29eb1804c5305d06fd2aab2b81e8aa5b30878253 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 8 Jan 2018 14:47:27 -0800 Subject: [PATCH] Run monitor loop indefinitely --- example.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/example.py b/example.py index 7c41084..f12f32e 100644 --- a/example.py +++ b/example.py @@ -100,13 +100,17 @@ def example(args): device_id = args[1] with wideq.Monitor(session, device_id) as mon: - for i in range(4): - time.sleep(1) - print('Polling...') - res = mon.poll() - if res: - print('setting: {}°C'.format(res['TempCfg'])) - print('current: {}°C'.format(res['TempCur'])) + try: + while True: + time.sleep(1) + print('Polling...') + res = mon.poll() + if res: + print('setting: {}°C'.format(res['TempCfg'])) + print('current: {}°C'.format(res['TempCur'])) + + except KeyboardInterrupt: + pass elif args[0] == 'set-temp': temp = args[1]