Skip to content
Merged
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
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,29 @@ Channel energy (mean of 1 / 5):
- 26* 81.96% #################################################################################
```

## Reset a radio

```console
$ zigpy radio --baudrate 115200 ezsp /dev/serial/by-id/some-radio reset
```

## Permit joins

Mainly useful for testing requests.

```console
$ zigpy radio deconz /dev/ttyUSB0 permit -t 60
```

## Changing the network channel

Note that not all devices will migrate. This is currently only supported on deCONZ and ZNP coordinators.
Other radios will successfully broadcast the change to other devices but you will need to perform a network backup, change the channel, and then restore the backup.

```console
$ zigpy radio znp /dev/ttyUSB0 change-channel --channel 25
```

# OTA
## Display basic information about OTA files
```console
Expand Down
49 changes: 49 additions & 0 deletions zigpy_cli/radio.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

import json
import asyncio
import logging
import importlib
import itertools
import collections
import importlib.util

import click
import zigpy.zdo
import zigpy.state
import zigpy.types
import zigpy.zdo.types
Expand Down Expand Up @@ -142,6 +144,24 @@ async def form(app):
await app.form_network()


@radio.command()
@click.pass_obj
@click_coroutine
async def reset(app):
await app.connect()
await app.reset_network_info()


@radio.command()
@click.pass_obj
@click.option("-t", "--join-time", type=int, default=250)
@click_coroutine
async def permit(app, join_time):
await app.startup(auto_form=True)
await app.permit(join_time)
await asyncio.sleep(join_time)


@radio.command()
@click.pass_obj
@click.option("--nwk", type=HEX_OR_DEC_INT, default=0x0000)
Expand Down Expand Up @@ -209,3 +229,32 @@ async def energy_scan(app, nwk, num_scans):
)

print()


@radio.command()
@click.pass_obj
@click.option("-c", "--channel", type=int)
@click_coroutine
async def change_channel(app, channel):
await app.startup()

await zigpy.zdo.broadcast(
app=app,
command=zigpy.zdo.types.ZDOCmd.Mgmt_NWK_Update_req,
grpid=None,
radius=0,
broadcast_address=zigpy.types.BroadcastAddress.ALL_DEVICES,
NwkUpdate=zigpy.zdo.types.NwkUpdate(
ScanChannels=zigpy.types.Channels.from_channel_list([channel]),
ScanDuration=zigpy.zdo.types.NwkUpdate.CHANNEL_CHANGE_REQ,
nwkUpdateId=app.state.network_info.nwk_update_id + 1,
),
)

await app.get_device(nwk=0x0000).zdo.Mgmt_NWK_Update_req(
zigpy.zdo.types.NwkUpdate(
ScanChannels=zigpy.types.Channels.from_channel_list([channel]),
ScanDuration=zigpy.zdo.types.NwkUpdate.CHANNEL_CHANGE_REQ,
nwkUpdateId=app.state.network_info.nwk_update_id + 1,
),
)