Skip to content

Commit

Permalink
Tie the runtime stack config to the EZSP object
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Jul 21, 2024
1 parent edfd1d0 commit 59ff4d3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions bellows/ezsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import bellows.config as conf
from bellows.exception import EzspError, InvalidCommandError
from bellows.ezsp.config import DEFAULT_CONFIG, RuntimeConfig, ValueConfig
from bellows.ezsp.config import RuntimeConfig, ValueConfig
import bellows.types as t
import bellows.uart

Expand Down Expand Up @@ -543,7 +543,7 @@ async def write_config(self, config: dict) -> None:
ezsp_config = {}
ezsp_values = {}

for cfg in DEFAULT_CONFIG[self._ezsp_version]:
for cfg in self.CONFIG:
if isinstance(cfg, RuntimeConfig):
ezsp_config[cfg.config_id.name] = dataclasses.replace(
cfg, config_id=t.EzspConfigId[cfg.config_id.name]
Expand Down
15 changes: 0 additions & 15 deletions bellows/ezsp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,3 @@ class ValueConfig:
value=t.uint8_t(1),
),
]


DEFAULT_CONFIG = {
4: DEFAULT_CONFIG_LEGACY,
5: DEFAULT_CONFIG_LEGACY,
6: DEFAULT_CONFIG_LEGACY,
7: DEFAULT_CONFIG_NEW,
8: DEFAULT_CONFIG_NEW,
9: DEFAULT_CONFIG_NEW,
10: DEFAULT_CONFIG_NEW,
11: DEFAULT_CONFIG_NEW,
12: DEFAULT_CONFIG_NEW,
13: DEFAULT_CONFIG_NEW,
14: DEFAULT_CONFIG_NEW,
}
2 changes: 2 additions & 0 deletions bellows/ezsp/v4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import zigpy.state

import bellows.config
from bellows.ezsp.config import DEFAULT_CONFIG_LEGACY
import bellows.types as t
from bellows.zigbee.util import ezsp_key_to_zigpy_key

Expand All @@ -26,6 +27,7 @@ class EZSPv4(protocol.ProtocolHandler):
bellows.config.CONF_EZSP_CONFIG: vol.Schema(config.EZSP_SCHEMA),
bellows.config.CONF_EZSP_POLICIES: vol.Schema(config.EZSP_POLICIES_SCH),
}
CONFIG = DEFAULT_CONFIG_LEGACY

def _ezsp_frame_tx(self, name: str) -> bytes:
"""Serialize the frame id."""
Expand Down
2 changes: 2 additions & 0 deletions bellows/ezsp/v7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import voluptuous

import bellows.config
from bellows.ezsp.config import DEFAULT_CONFIG_NEW
import bellows.types as t

from . import commands, config
Expand All @@ -24,6 +25,7 @@ class EZSPv7(EZSPv6):
bellows.config.CONF_EZSP_CONFIG: voluptuous.Schema(config.EZSP_SCHEMA),
bellows.config.CONF_EZSP_POLICIES: voluptuous.Schema(config.EZSP_POLICIES_SCH),
}
CONFIG = DEFAULT_CONFIG_NEW

async def read_child_data(
self,
Expand Down

0 comments on commit 59ff4d3

Please sign in to comment.