Skip to content

Commit

Permalink
fix: mic_mac was not being used for bulbs
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticrake committed May 26, 2020
1 parent 63f643a commit dd74621
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
12 changes: 0 additions & 12 deletions src/devices/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,10 @@ class Base {
this.data.system.sysinfo.longitude_i = Math.round(value * 10000);
}

get mac() {
return this.data.system.sysinfo.mac;
}

set mac(value) {
this.data.system.sysinfo.mac = value;
}

initDefaults() {
this.alias = this.data.alias || `Mock ${this.data.model}`;
if (this.data.deviceId) this.deviceId = this.data.deviceId;
if (this.data.mac) this.mac = this.data.mac;

if (!this.mac) {
this.mac = utils.randomMac();
}
if (!this.deviceId) {
this.deviceId = utils.generateId(40);
}
Expand Down
18 changes: 18 additions & 0 deletions src/devices/hs.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ class Hs extends Base {
return this.data.count_down;
}

get mac() {
return this.data.system.sysinfo.mac;
}

set mac(value) {
this.data.system.sysinfo.mac = value;
}

get onTime() {
if (this.relayState === 1) {
return Math.round((Date.now() - this.onSince) / 1000); // in seconds
Expand All @@ -361,6 +369,16 @@ class Hs extends Base {
this.onSince = value;
}
}

initDefaults() {
super.initDefaults();

if (this.data.mac) this.mac = this.data.mac;

if (!this.mac) {
this.mac = utils.randomMac();
}
}
}

module.exports = Hs;
12 changes: 10 additions & 2 deletions src/devices/lb.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ const defaultsDeep = require('lodash.defaultsdeep');
const utils = require('../utils');

const { errCode } = utils;
const Base = require('./base');
const Hs = require('./hs');

const defaultData = require('./data/base');

class Lb {
class Lb extends Base {
constructor(data) {
super(data);
this.hs = new Hs(data);
this.data = defaultsDeep(data, defaultData);

Expand Down Expand Up @@ -105,7 +107,13 @@ class Lb {
}

initDefaults() {
this.hs.initDefaults();
super.initDefaults();

if (this.data.mac) this.mac = this.data.mac;

if (!this.mac) {
this.mac = utils.randomMac();
}
}
}

Expand Down

0 comments on commit dd74621

Please sign in to comment.