acmax24 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import time, threading
|
|
2
2
|
import asyncio
|
|
3
|
+
import copy
|
|
3
4
|
import json
|
|
4
5
|
import requests
|
|
5
6
|
import websockets
|
|
@@ -173,7 +174,7 @@ class Transport:
|
|
|
173
174
|
except websockets.ConnectionClosed:
|
|
174
175
|
LOG.warn("websocket closed, connect will automatically restablish")
|
|
175
176
|
continue
|
|
176
|
-
except e:
|
|
177
|
+
except Exception as e:
|
|
177
178
|
LOG.error(f"received error: {e}; ignoring")
|
|
178
179
|
continue
|
|
179
180
|
|
|
@@ -302,7 +303,8 @@ class ACMax24:
|
|
|
302
303
|
LOG.debug("Sending: '%s'", cmd)
|
|
303
304
|
await self._transport.send(cmd)
|
|
304
305
|
except Exception as e:
|
|
305
|
-
LOG.warn("Exception
|
|
306
|
+
LOG.warn("Exception when sending command. cmd='%s', exception='%s'", cmd, e)
|
|
307
|
+
pass
|
|
306
308
|
|
|
307
309
|
|
|
308
310
|
def get_enabled_inputs(self) -> "set[Input]":
|
|
@@ -383,6 +385,27 @@ class ACMax24:
|
|
|
383
385
|
res += "OUT" + str(output.index) + ": " + str(output) + "\n"
|
|
384
386
|
|
|
385
387
|
return res
|
|
386
|
-
|
|
387
388
|
|
|
389
|
+
async def save_state(self):
|
|
390
|
+
"""Returns a dictionary containing the current state of the inputs/outputs, which can be restored
|
|
391
|
+
using restore_state()"""
|
|
392
|
+
state = {}
|
|
393
|
+
state['inputs'] = copy.deepcopy(self._inputs)
|
|
394
|
+
state['outputs'] = copy.deepcopy(self._outputs)
|
|
395
|
+
return state
|
|
396
|
+
|
|
397
|
+
async def restore_state(self, state):
|
|
398
|
+
"""Takes a state dump, as returned by save_state(), and makes the system match the supplied state"""
|
|
399
|
+
saved_input: Input
|
|
400
|
+
for saved_input in state['inputs']:
|
|
401
|
+
# Nothing to implement for inputs right now...
|
|
402
|
+
pass
|
|
388
403
|
|
|
404
|
+
saved_output: Output
|
|
405
|
+
for saved_output in state['outputs']:
|
|
406
|
+
LOG.debug("Restoring saved output: %s", saved_output)
|
|
407
|
+
# We assume that enabled/disabled isn't changed between save/restore (since we don't support that)
|
|
408
|
+
if saved_output.enabled:
|
|
409
|
+
await self.mute_output(saved_output.index, saved_output.muted)
|
|
410
|
+
await self.set_output_volume(saved_output.index, saved_output.volume)
|
|
411
|
+
await self.change_input_for_output(saved_output.index, saved_output.input_channel)
|
|
File without changes
|
|
File without changes
|