Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.DS_Store
/node_modules
/.node-persist
/.vscode
7 changes: 4 additions & 3 deletions accessories/outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ class OutletAccessory extends SwitchAccessory {
const { config, state, serviceManager } = this;
const newState = active ? true : false;

const previousState = state.outletInUse;

// Only update Homkit if the switch state haven changed.
if (previousState === newState) return
if (previousState != undefined && previousState === newState) return

state.outletInUse = newState;
if (config.pingIPAddressStateOnly) {
state.outletInUse = newState;
serviceManager.refreshCharacteristicUI(Characteristic.OutletInUse)

return
}

Expand Down
20 changes: 20 additions & 0 deletions test/helpers/fakeHomebridge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class FakeUser{
constructor(){
this.storage = "../sotragePath";
}

storagePath (){
return this.storage;
}
}

class FakeHomebridge{

constructor () {
this.user = new FakeUser();
}


}

module.exports = FakeHomebridge;
4 changes: 3 additions & 1 deletion test/helpers/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const hap = require('hap-nodejs');

const FakeHomebridge = require('./fakeHomebridge')
const BroadlinkRMPlatform = require('../../platform');
const FakeDevice = require('./fakeDevice')
const { addDevice } = require('../../helpers/getDevice')
Expand All @@ -16,6 +16,8 @@ const log = (message, more) => {
};

const setup = (config) => {
const homebridge = new FakeHomebridge();
BroadlinkRMPlatform.setHomebridge(homebridge);
const platform = new BroadlinkRMPlatform(log, config);

const device = new FakeDevice()
Expand Down
2 changes: 1 addition & 1 deletion test/light.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ describe('lightAccessory', () => {

// Check that only one code has been sent
sentHexCodeCount = device.getSentHexCodeCount();
expect(sentHexCodeCount).to.equal(2);
expect(sentHexCodeCount).to.equal(1);
});


Expand Down