Skip to content

Commit

Permalink
fix(activity): incorrect this usage in onoff capability
Browse files Browse the repository at this point in the history
DeviceDataId was read from `this` variable, which in that specific
closure is undefined. By specifying the DeviceDataId as a `const` hit
issue was resolved.
  • Loading branch information
rkokkelk committed Feb 26, 2023
1 parent 145562a commit f1c0639
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/harmony_activity_driver/device.js
Expand Up @@ -41,15 +41,15 @@ class HarmonyActivity extends Homey.Device {
});

this.registerCapabilityListener('onoff', async (turnon, opts) => {
console.log(`ON/OFF triggered on ${this._deviceData.label}`);
const foundHub = this.hub;
const deviceDataId = this._deviceData.id;
console.log(`ON/OFF triggered on ${this._deviceData.label}(${deviceDataId})`);

if (foundHub === undefined)
if (this.hub === undefined)
return;

hubManager.connectToHub(foundHub.ip).then((hub) => {
hubManager.connectToHub(this.hub.ip).then((hub) => {
if (turnon)
hub.startActivity(this._deviceData.id).catch((err) => {
hub.startActivity(deviceDataId).catch((err) => {
console.log(err);
return Promise.reject(err);
});
Expand Down

0 comments on commit f1c0639

Please sign in to comment.