diff --git a/app/device_manager.py b/app/device_manager.py index c870da6..eef6fad 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -1628,10 +1628,11 @@ class DeviceManager: if not contact: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: - timeout = contact.get('timeout', 0) or 30 + # Pass timeout=0 to let library use device's suggested_timeout + contact_timeout = contact.get('timeout', 0) or 0 event = self.execute( - self.mc.commands.req_status_sync(contact, timeout), - timeout=timeout + 5 + self.mc.commands.req_status_sync(contact, contact_timeout), + timeout=120 ) if event and hasattr(event, 'payload'): return {'success': True, 'data': event.payload} @@ -1648,10 +1649,10 @@ class DeviceManager: if not contact: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: - timeout = contact.get('timeout', 0) or 30 + contact_timeout = contact.get('timeout', 0) or 0 event = self.execute( - self.mc.commands.req_regions_sync(contact, timeout), - timeout=timeout + 5 + self.mc.commands.req_regions_sync(contact, contact_timeout), + timeout=120 ) if event and hasattr(event, 'payload'): return {'success': True, 'data': event.payload} @@ -1668,10 +1669,10 @@ class DeviceManager: if not contact: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: - timeout = contact.get('timeout', 0) or 30 + contact_timeout = contact.get('timeout', 0) or 0 event = self.execute( - self.mc.commands.req_owner_sync(contact, timeout), - timeout=timeout + 5 + self.mc.commands.req_owner_sync(contact, contact_timeout), + timeout=120 ) if event and hasattr(event, 'payload'): return {'success': True, 'data': event.payload} @@ -1688,10 +1689,10 @@ class DeviceManager: if not contact: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: - timeout = contact.get('timeout', 0) or 30 + contact_timeout = contact.get('timeout', 0) or 0 event = self.execute( - self.mc.commands.req_acl_sync(contact, timeout), - timeout=timeout + 5 + self.mc.commands.req_acl_sync(contact, contact_timeout), + timeout=120 ) if event and hasattr(event, 'payload'): return {'success': True, 'data': event.payload} @@ -1708,10 +1709,10 @@ class DeviceManager: if not contact: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: - timeout = contact.get('timeout', 0) or 30 + contact_timeout = contact.get('timeout', 0) or 0 event = self.execute( - self.mc.commands.req_basic_sync(contact, timeout), - timeout=timeout + 5 + self.mc.commands.req_basic_sync(contact, contact_timeout), + timeout=120 ) if event and hasattr(event, 'payload'): return {'success': True, 'data': event.payload} @@ -1728,10 +1729,10 @@ class DeviceManager: if not contact: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: - timeout = contact.get('timeout', 0) or 30 + contact_timeout = contact.get('timeout', 0) or 0 event = self.execute( - self.mc.commands.req_mma_sync(contact, from_secs, to_secs, timeout), - timeout=timeout + 5 + self.mc.commands.req_mma_sync(contact, from_secs, to_secs, contact_timeout), + timeout=120 ) if event and hasattr(event, 'payload'): return {'success': True, 'data': event.payload} diff --git a/app/main.py b/app/main.py index 1b94038..0f4b897 100644 --- a/app/main.py +++ b/app/main.py @@ -702,18 +702,20 @@ def _execute_console_command(args: list) -> str: elif cmd == 'clock': if len(args) >= 2 and args[1] == 'sync': import time as _time + import datetime as _dt epoch = int(_time.time()) result = device_manager.set_clock(epoch) if result.get('success'): - return f"Clock synced to {epoch}" + dt_str = _dt.datetime.fromtimestamp(epoch).strftime("%Y-%m-%d %H:%M:%S") + return f"Clock synced to {dt_str} ({epoch})" return f"Error: {result.get('error')}" result = device_manager.get_clock() if result.get('success'): + import datetime as _dt data = result['data'] - lines = ["Device clock:"] - for k, v in data.items(): - lines.append(f" {k}: {v}") - return "\n".join(lines) + timestamp = data.get('time', 0) + dt_str = _dt.datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S") + return f"Current time: {dt_str} ({timestamp})" return f"Error: {result.get('error')}" elif cmd == 'time' and len(args) >= 2: