Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write board info to zigpy NodeInfo #230

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/PyCQA/autoflake
rev: v2.0.2
rev: v2.2.1
hooks:
- id: autoflake

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.10.1
hooks:
- id: black
args:
- --quiet
- --safe

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -33,7 +33,7 @@ repos:
- id: isort

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.6
hooks:
- id: codespell
args:
Expand All @@ -42,7 +42,7 @@ repos:
- --quiet-level=2

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.261
rev: v0.1.3
hooks:
- id: ruff
args:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ license = {text = "GPL-3.0"}
requires-python = ">=3.8"
dependencies = [
"voluptuous",
"zigpy>=0.54.1",
"zigpy>=0.60.0",
'async-timeout; python_version<"3.11"',
]

Expand Down
10 changes: 5 additions & 5 deletions tests/test_network_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def node_info():
nwk=t.NWK(0x0000),
ieee=t.EUI64.convert("93:2C:A9:34:D9:D0:5D:12"),
logical_type=zdo_t.LogicalType.Coordinator,
manufacturer="dresden elektronik",
model="ConBee II",
version="0x26580700",
)


Expand Down Expand Up @@ -60,11 +63,7 @@ def network_info(node_info):
nwk_addresses={},
stack_specific={},
source=f"zigpy-deconz@{importlib.metadata.version('zigpy-deconz')}",
metadata={
"deconz": {
"version": 0,
}
},
metadata={},
)


Expand Down Expand Up @@ -258,6 +257,7 @@ async def test_load_network_info(
("security_mode",): [zigpy_deconz.api.SecurityMode.ONLY_TCLK],
}

app._version = 0x26580700
params.update(param_overrides)

async def read_param(param, *args):
Expand Down
25 changes: 17 additions & 8 deletions zigpy_deconz/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, config: dict[str, Any]):

self._pending = zigpy.util.Requests()

self.version = 0
self._version = 0
self._reset_watchdog_task = None
self._reconnect_task = None

Expand All @@ -85,7 +85,7 @@ async def connect(self):

try:
await api.connect()
self.version = await api.version()
self._version = await api.version()
except Exception:
api.close()
raise
Expand Down Expand Up @@ -124,7 +124,7 @@ async def start_network(self):
self,
self.state.node_info.ieee,
self.state.node_info.nwk,
self.version,
self._version,
self._config[zigpy.config.CONF_DEVICE][zigpy.config.CONF_DEVICE_PATH],
)

Expand Down Expand Up @@ -277,11 +277,6 @@ async def load_network_info(self, *, load_devices=False):
network_info.source = (
f"zigpy-deconz@{importlib.metadata.version('zigpy-deconz')}"
)
network_info.metadata = {
"deconz": {
"version": self.version,
}
}

(ieee,) = await self._api[NetworkParameter.mac_address]
node_info.ieee = zigpy.types.EUI64(ieee)
Expand All @@ -294,6 +289,20 @@ async def load_network_info(self, *, load_devices=False):

(node_info.nwk,) = await self._api[NetworkParameter.nwk_address]

node_info.version = f"{self._version:#010x}"
node_info.manufacturer = "dresden elektronik"

if re.match(
r"/dev/tty(S|AMA|ACM)\d+",
self._config[zigpy.config.CONF_DEVICE][zigpy.config.CONF_DEVICE_PATH],
):
node_info.model = "RaspBee"
else:
node_info.model = "ConBee"

if (self._version & 0x0000FF00) == 0x00000700:
node_info.model += " II"

(network_info.pan_id,) = await self._api[NetworkParameter.nwk_panid]
(network_info.extended_pan_id,) = await self._api[
NetworkParameter.aps_extended_panid
Expand Down
Loading