Fix command selection for OTBRs without dataset (#22318)

Typically, the Home Assistant OTBR integration makes sure that we
either setup or read the current dataset. However, in some cases,
e.g. when reinstalling the add-on, deleting the dataset, and starting
the add-on while keeping the OTBR config entry, the dataset is not
available and a new one is not being created (since the config entry
is not recreated).

Just support this particular case as well.

Fixes: #22306
This commit is contained in:
Stefan Agner 2024-10-10 16:50:44 +02:00 committed by GitHub
parent a8bbd8ab90
commit 92165d776a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -482,7 +482,9 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
const network = (ev.currentTarget as any).network as ThreadNetwork; const network = (ev.currentTarget as any).network as ThreadNetwork;
const router = (ev.currentTarget as any).router as ThreadRouter; const router = (ev.currentTarget as any).router as ThreadRouter;
const otbr = (ev.currentTarget as any).otbr as OTBRInfo; const otbr = (ev.currentTarget as any).otbr as OTBRInfo;
const index = Number(ev.detail.index); const index = network.dataset
? Number(ev.detail.index)
: Number(ev.detail.index) + 1;
switch (index) { switch (index) {
case 0: case 0:
this._setPreferredBorderAgent(network.dataset!, router); this._setPreferredBorderAgent(network.dataset!, router);