Randomize thread network names (#108302)
* Randomize thread network names * Use PAN ID as network name suffix * Apply suggestions from code review Co-authored-by: Stefan Agner <stefan@agner.ch> * Update tests * Format code * Change format of network name again --------- Co-authored-by: Stefan Agner <stefan@agner.ch>
This commit is contained in:
parent
d8f16c14ab
commit
823f268054
5 changed files with 47 additions and 9 deletions
|
@ -16,7 +16,13 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from .const import DEFAULT_CHANNEL, DOMAIN
|
||||
from .util import OTBRData, get_allowed_channel, update_issues
|
||||
from .util import (
|
||||
OTBRData,
|
||||
compose_default_network_name,
|
||||
generate_random_pan_id,
|
||||
get_allowed_channel,
|
||||
update_issues,
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -99,10 +105,13 @@ async def websocket_create_network(
|
|||
connection.send_error(msg["id"], "factory_reset_failed", str(exc))
|
||||
return
|
||||
|
||||
pan_id = generate_random_pan_id()
|
||||
try:
|
||||
await data.create_active_dataset(
|
||||
python_otbr_api.ActiveDataSet(
|
||||
channel=channel, network_name="home-assistant"
|
||||
channel=channel,
|
||||
network_name=compose_default_network_name(pan_id),
|
||||
pan_id=pan_id,
|
||||
)
|
||||
)
|
||||
except HomeAssistantError as exc:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue