Skip to content

Commit

Permalink
Add setting for tp-link to specify the udp broadcast address
Browse files Browse the repository at this point in the history
  • Loading branch information
LordTocs committed Aug 21, 2023
1 parent fb8c626 commit 80947e3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/castmate/src/main/plugins/tplink.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class TPLinkIoTProvider extends IoTProvider {
error: (...args) => console.log(...args),
},*/
})

this.client.on("plug-new", async (plug) => {
this._addNewPlug(new TPLinkPlug(plug, await plug.getPowerState()))
})
Expand All @@ -149,9 +150,20 @@ class TPLinkIoTProvider extends IoTProvider {
}

async initServices() {
console.log("Starting TP-Link Discovery...")
const broadcast =
this.pluginObj.settings.broadcastMask ?? "255.255.255.255"
console.log("Starting TP-Link Discovery", broadcast)
this.client.startDiscovery({
breakoutChildren: true,
broadcast,
})
}

async setBroadcastMask(newMask) {
this.client.stopDiscovery()
console.log("Starting TP-Link Discovery", newMask)
this.client.startDiscovery({
broadcast: newMask,
})
}

Expand All @@ -172,4 +184,10 @@ export default {
async init() {
this.iotProvider = new TPLinkIoTProvider(this)
},
settings: {
broadcastMask: { type: String, name: "Broadcast Mask" },
},
async onSettingsReload() {
this.iotProvider.setBroadcastMask(this.settings.broadcastMask)
},
}

0 comments on commit 80947e3

Please sign in to comment.