|
22 | 22 | async_loop_unhandled_exception_handler, |
23 | 23 | ) |
24 | 24 | from paradox.hardware import Panel, create_panel |
| 25 | +from paradox.hardware.evo.parsers import MODULE_PGM_PACKET_SLOTS |
25 | 26 | from paradox.lib import ps |
26 | 27 | from paradox.lib.async_message_manager import ErrorMessageHandler, EventMessageHandler |
27 | 28 | from paradox.lib.handlers import PersistentHandler |
@@ -492,6 +493,22 @@ async def control_partition(self, partition: str, command: str) -> bool: |
492 | 493 |
|
493 | 494 | def _init_module_pgms(self): |
494 | 495 | for addr, pgm_count in cfg.MODULE_PGM_ADDRESSES.items(): |
| 496 | + if not isinstance(addr, int) or not (1 <= addr <= 254): |
| 497 | + logger.warning( |
| 498 | + "MODULE_PGM_ADDRESSES: invalid module address %r (expected int 1-254), skipping", |
| 499 | + addr, |
| 500 | + ) |
| 501 | + continue |
| 502 | + if not isinstance(pgm_count, int) or not ( |
| 503 | + 1 <= pgm_count <= MODULE_PGM_PACKET_SLOTS |
| 504 | + ): |
| 505 | + logger.warning( |
| 506 | + "MODULE_PGM_ADDRESSES: invalid pgm_count %r for address %d (expected int 1-%d), skipping", |
| 507 | + pgm_count, |
| 508 | + addr, |
| 509 | + MODULE_PGM_PACKET_SLOTS, |
| 510 | + ) |
| 511 | + continue |
495 | 512 | for pgm_index in range(1, pgm_count + 1): |
496 | 513 | key = f"module{addr}_pgm{pgm_index}" |
497 | 514 | self.storage.get_container("module_pgm")[key] = { |
@@ -533,15 +550,19 @@ async def control_output(self, output, command) -> bool: |
533 | 550 | out["module_address"], out["pgm_index"], command |
534 | 551 | ) |
535 | 552 | except NotImplementedError: |
536 | | - logger.error("control_module_pgm_outputs is not implemented for this alarm type") |
| 553 | + logger.error( |
| 554 | + "control_module_pgm_outputs is not implemented for this alarm type" |
| 555 | + ) |
537 | 556 | except asyncio.CancelledError: |
538 | | - logger.error("control_output canceled") |
| 557 | + logger.error("control_module_pgm_output canceled") |
539 | 558 | raise |
540 | 559 | except asyncio.TimeoutError: |
541 | 560 | logger.error("control_output timeout") |
542 | 561 | if accepted: |
543 | 562 | is_on = command in ("on", "on_override") |
544 | | - self.storage.update_container_object("module_pgm", out["key"], {"on": is_on}) |
| 563 | + self.storage.update_container_object( |
| 564 | + "module_pgm", out["key"], {"on": is_on} |
| 565 | + ) |
545 | 566 | return accepted |
546 | 567 |
|
547 | 568 | logger.error("No outputs selected") |
|
0 commit comments