Skip to content

Commit

Permalink
v1.1.9 minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxmudjon committed Nov 23, 2020
1 parent 55c2016 commit fc7e96e
Show file tree
Hide file tree
Showing 76 changed files with 3,005 additions and 2,727 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Added support for Mi Gateways child devices.

## Version 1.1.8 - Supported devices:
## Version 1.1.9 - Supported devices:

### Zigbee subdevices Xiaomi Gateway

Expand Down Expand Up @@ -128,6 +128,11 @@ Added support for Mi Gateways child devices.

## Version logs

### 1.1.9 (24.11.2020)

1. fix Air Fresh VA4.
2. minor fixes.

### 1.1.8 (23.10.2020)

1. added Xiaomi Air Fresh VA4.
Expand Down
14 changes: 12 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.maxmudjon.mihomey",
"version": "1.1.8",
"version": "1.1.9",
"compatibility": ">=2.0.0",
"sdk": 2,
"name": {
Expand Down Expand Up @@ -9286,7 +9286,8 @@
"alarm_main_brush_work_time",
"alarm_side_brush_work_time",
"alarm_filter_work_time",
"alarm_sensor_dirty_time"
"alarm_sensor_dirty_time",
"button.consumable"
],
"energy": {
"batteries": ["OTHER"]
Expand All @@ -9306,6 +9307,15 @@
"title": {
"en": "Speed"
}
},
"button.consumable": {
"maintenanceAction": true,
"title": {
"en": "Reset consumable"
},
"desc": {
"en": "Reset the vacuum cleaner consumables."
}
}
},
"mobile": {
Expand Down
10 changes: 5 additions & 5 deletions drivers/button_switch.aq2/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class AqaraButtonSwitch extends Homey.Device {

let gateways = Homey.app.mihub.gateways;
for (let sid in gateways) {
gateways[sid]["childDevices"].forEach(deviceSid => {
gateways[sid]["childDevices"].forEach((deviceSid) => {
if (this.data.sid == deviceSid) {
this.setSettings({
deviceFromGatewaySid: sid
deviceFromGatewaySid: sid,
});
}
});
Expand All @@ -52,7 +52,7 @@ class AqaraButtonSwitch extends Homey.Device {
this.setSettings({
deviceSid: device.sid,
deviceModelName: "lumi." + device.model,
deviceModelCodeName: device.modelCode
deviceModelCodeName: device.modelCode,
});
}

Expand All @@ -78,7 +78,7 @@ class AqaraButtonSwitch extends Homey.Device {
.then(() => {
this.log("[" + this.data.sid + "] [" + name + "] [" + value + "] Capability successfully updated");
})
.catch(error => {
.catch((error) => {
this.log("[" + this.data.sid + "] [" + name + "] [" + value + "] Capability not updated because there are errors: " + error.message);
});
this.triggerFlow(trigger, name, value);
Expand All @@ -104,7 +104,7 @@ class AqaraButtonSwitch extends Homey.Device {
onDeleted() {
this.unregisterAuthChangeListener();
this.unregisterStateChangeListener();
this.log("Device deleted deleted");
this.log("Device deleted");
}
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/button_switch.aq3/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class AqaraButtonSwitch extends Homey.Device {

let gateways = Homey.app.mihub.gateways;
for (let sid in gateways) {
gateways[sid]["childDevices"].forEach(deviceSid => {
gateways[sid]["childDevices"].forEach((deviceSid) => {
if (this.data.sid == deviceSid) {
this.setSettings({
deviceFromGatewaySid: sid
deviceFromGatewaySid: sid,
});
}
});
Expand All @@ -60,7 +60,7 @@ class AqaraButtonSwitch extends Homey.Device {
this.setSettings({
deviceSid: device.sid,
deviceModelName: "lumi." + device.model,
deviceModelCodeName: device.modelCode
deviceModelCodeName: device.modelCode,
});
}

Expand All @@ -86,7 +86,7 @@ class AqaraButtonSwitch extends Homey.Device {
.then(() => {
this.log("[" + this.data.sid + "] [" + name + "] [" + value + "] Capability successfully updated");
})
.catch(error => {
.catch((error) => {
this.log("[" + this.data.sid + "] [" + name + "] [" + value + "] Capability not updated because there are errors: " + error.message);
});
this.triggerFlow(trigger, name, value);
Expand Down Expand Up @@ -120,7 +120,7 @@ class AqaraButtonSwitch extends Homey.Device {
onDeleted() {
this.unregisterAuthChangeListener();
this.unregisterStateChangeListener();
this.log("Device deleted deleted");
this.log("Device deleted");
}
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/button_switch/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class ButtonSwitch extends Homey.Device {

let gateways = Homey.app.mihub.gateways;
for (let sid in gateways) {
gateways[sid]["childDevices"].forEach(deviceSid => {
gateways[sid]["childDevices"].forEach((deviceSid) => {
if (this.data.sid == deviceSid) {
this.setSettings({
deviceFromGatewaySid: sid
deviceFromGatewaySid: sid,
});
}
});
Expand All @@ -52,7 +52,7 @@ class ButtonSwitch extends Homey.Device {
this.setSettings({
deviceSid: device.sid,
deviceModelName: "lumi.sensor_" + device.model,
deviceModelCodeName: device.modelCode
deviceModelCodeName: device.modelCode,
});
}

Expand All @@ -78,7 +78,7 @@ class ButtonSwitch extends Homey.Device {
.then(() => {
this.log("[" + this.data.sid + "] [" + name + "] [" + value + "] Capability successfully updated");
})
.catch(error => {
.catch((error) => {
this.log("[" + this.data.sid + "] [" + name + "] [" + value + "] Capability not updated because there are errors: " + error.message);
});
this.triggerFlow(trigger, name, value);
Expand All @@ -104,7 +104,7 @@ class ButtonSwitch extends Homey.Device {
onDeleted() {
this.unregisterAuthChangeListener();
this.unregisterStateChangeListener();
this.log("Device deleted deleted");
this.log("Device deleted");
}
}

Expand Down
50 changes: 25 additions & 25 deletions drivers/cgllc_airmonitor_b1/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class MiAirQualityMonitor2Gen extends Homey.Device {
}

getAirFreshStatus() {
var that = this;
miio
.device({ address: this.getSetting("deviceIP"), token: this.getSetting("deviceToken") })
.then(device => {
.then((device) => {
if (!this.getAvailable()) {
this.setAvailable();
}
Expand All @@ -22,45 +21,46 @@ class MiAirQualityMonitor2Gen extends Homey.Device {

this.device
.call("get_air_data", [])
.then(result => {

that.updateCapabilityValue("measure_pm25", parseInt(result.result.pm25));
that.updateCapabilityValue("measure_co2", parseInt(result.result.co2e));
that.updateCapabilityValue("measure_humidity", parseInt(result.result.humidity));
that.updateCapabilityValue("measure_temperature", parseInt(result.result.temperature));
that.updateCapabilityValue("measure_voc", parseInt(result.result.tvoc))
.then((result) => {
this.updateCapabilityValue("measure_pm25", parseInt(result.result.pm25));
this.updateCapabilityValue("measure_co2", parseInt(result.result.co2e));
this.updateCapabilityValue("measure_humidity", parseInt(result.result.humidity));
this.updateCapabilityValue("measure_temperature", parseInt(result.result.temperature));
this.updateCapabilityValue("measure_voc", parseInt(result.result.tvoc));
})
.catch(error => that.log("Sending commmand 'get_air_data' error: ", error));
.catch((error) => this.log("Sending commmand 'get_air_data' error: ", error));

var update = this.getSetting("updateTimer") || 60;
const update = this.getSetting("updateTimer") || 60;
this.updateTimer(update);
})
.catch(error => {
this.log(error);
this.setUnavailable(Homey.__("reconnecting"));
.catch((error) => {
this.setUnavailable(error.message);
clearInterval(this.updateInterval);
setTimeout(() => {
this.getAirFreshStatus();
}, 10000);
});
}

updateTimer(interval) {
var that = this;
clearInterval(this.updateInterval);
this.updateInterval = setInterval(() => {
this.device
.call("get_air_data", [])
.then(result => {
that.updateCapabilityValue("measure_pm25", parseInt(result.result.pm25));
that.updateCapabilityValue("measure_co2", parseInt(result.result.co2e));
that.updateCapabilityValue("measure_humidity", parseInt(result.result.humidity));
that.updateCapabilityValue("measure_temperature", parseInt(result.result.temperature));
that.updateCapabilityValue("measure_voc", parseInt(result.result.tvoc))
.then((result) => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.updateCapabilityValue("measure_pm25", parseInt(result.result.pm25));
this.updateCapabilityValue("measure_co2", parseInt(result.result.co2e));
this.updateCapabilityValue("measure_humidity", parseInt(result.result.humidity));
this.updateCapabilityValue("measure_temperature", parseInt(result.result.temperature));
this.updateCapabilityValue("measure_voc", parseInt(result.result.tvoc));
})
.catch(error => {
.catch((error) => {
this.log("Sending commmand 'get_air_data' error: ", error);
clearInterval(this.updateInterval);
this.setUnavailable(Homey.__("unreachable"));
this.setUnavailable(error.message);
setTimeout(() => {
this.getAirFreshStatus();
}, 1000 * interval);
Expand All @@ -74,7 +74,7 @@ class MiAirQualityMonitor2Gen extends Homey.Device {
.then(() => {
this.log("[" + this.data.id + "] [" + capabilityName + "] [" + value + "] Capability successfully updated");
})
.catch(error => {
.catch((error) => {
this.log("[" + this.data.id + "] [" + capabilityName + "] [" + value + "] Capability not updated because there are errors: " + error.message);
});
}
Expand All @@ -92,7 +92,7 @@ class MiAirQualityMonitor2Gen extends Homey.Device {
}

onDeleted() {
this.log("Device deleted deleted");
this.log("Device deleted");
clearInterval(this.updateInterval);
if (typeof this.device !== "undefined") {
this.device.destroy();
Expand Down
67 changes: 34 additions & 33 deletions drivers/cgllc_airmonitor_s1/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ class MiClearGlassAirDetector extends Homey.Device {
async onInit() {
this.driver = this.getDriver();
this.data = this.getData();
this.getAirFreshStatus();
this.getAirMonitorStatus();
this.log("MiJia device init | name: " + this.getName() + " - class: " + this.getClass() + " - data: " + JSON.stringify(this.data));
}

getAirFreshStatus() {
var that = this;
getAirMonitorStatus() {
miio
.device({ address: this.getSetting("deviceIP"), token: this.getSetting("deviceToken") })
.then(device => {
.then((device) => {
if (!this.getAvailable()) {
this.setAvailable();
}
Expand All @@ -22,50 +21,52 @@ class MiClearGlassAirDetector extends Homey.Device {

this.device
.call("get_prop", ["battery", "battery_state", "co2", "humidity", "pm25", "temperature", "tvoc"])
.then(result => {
that.updateCapabilityValue("measure_pm25", parseInt(result.pm25));
that.updateCapabilityValue("measure_co2", parseInt(result.co2));
that.updateCapabilityValue("measure_humidity", parseFloat(result.humidity));
that.updateCapabilityValue("measure_temperature", parseFloat(result.temperature));
that.updateCapabilityValue("measure_voc", parseInt(result.tvoc));
that.updateCapabilityValue("battery", parseInt(result.battery));
that.updateCapabilityValue("battery_state", parseInt(result.battery) > 20 ? false : true);
.then((result) => {
this.updateCapabilityValue("measure_pm25", parseInt(result.pm25));
this.updateCapabilityValue("measure_co2", parseInt(result.co2));
this.updateCapabilityValue("measure_humidity", parseFloat(result.humidity));
this.updateCapabilityValue("measure_temperature", parseFloat(result.temperature));
this.updateCapabilityValue("measure_voc", parseInt(result.tvoc));
this.updateCapabilityValue("measure_battery", parseInt(result.battery));
this.updateCapabilityValue("alarm_battery", parseInt(result.battery) > 20 ? false : true);
})
.catch(error => that.log("Sending commmand 'get_prop' error: ", error));
.catch((error) => this.log("Sending commmand 'get_prop' error: ", error));

var update = this.getSetting("updateTimer") || 60;
const update = this.getSetting("updateTimer") || 60;
this.updateTimer(update);
})
.catch(error => {
this.log(error);
this.setUnavailable(Homey.__("reconnecting"));
.catch((error) => {
clearInterval(this.updateInterval);
this.setUnavailable(error.message);
setTimeout(() => {
this.getAirFreshStatus();
this.getAirMonitorStatus();
}, 10000);
});
}

updateTimer(interval) {
var that = this;
clearInterval(this.updateInterval);
this.updateInterval = setInterval(() => {
this.device
.call("get_prop", ["battery", "battery_state", "co2", "humidity", "pm25", "temperature", "tvoc"])
.then(result => {
that.updateCapabilityValue("measure_pm25", parseInt(result.pm25));
that.updateCapabilityValue("measure_co2", parseInt(result.co2));
that.updateCapabilityValue("measure_humidity", parseFloat(result.humidity));
that.updateCapabilityValue("measure_temperature", parseFloat(result.temperature));
that.updateCapabilityValue("measure_voc", parseInt(result.tvoc));
that.updateCapabilityValue("battery", parseInt(result.battery));
that.updateCapabilityValue("battery_state", parseInt(result.battery) > 20 ? false : true);
.then((result) => {
if (!this.getAvailable()) {
this.setAvailable();
}
this.updateCapabilityValue("measure_pm25", parseInt(result.pm25));
this.updateCapabilityValue("measure_co2", parseInt(result.co2));
this.updateCapabilityValue("measure_humidity", parseFloat(result.humidity));
this.updateCapabilityValue("measure_temperature", parseFloat(result.temperature));
this.updateCapabilityValue("measure_voc", parseInt(result.tvoc));
this.updateCapabilityValue("measure_battery", parseInt(result.battery));
this.updateCapabilityValue("alarm_battery", parseInt(result.battery) > 20 ? false : true);
})
.catch(error => {
.catch((error) => {
this.log("Sending commmand 'get_prop' error: ", error);
clearInterval(this.updateInterval);
this.setUnavailable(Homey.__("unreachable"));
this.setUnavailable(error.message);
setTimeout(() => {
this.getAirFreshStatus();
this.getAirMonitorStatus();
}, 1000 * interval);
});
}, 1000 * interval);
Expand All @@ -77,15 +78,15 @@ class MiClearGlassAirDetector extends Homey.Device {
.then(() => {
this.log("[" + this.data.id + "] [" + capabilityName + "] [" + value + "] Capability successfully updated");
})
.catch(error => {
.catch((error) => {
this.log("[" + this.data.id + "] [" + capabilityName + "] [" + value + "] Capability not updated because there are errors: " + error.message);
});
}
}

onSettings(oldSettings, newSettings, changedKeys, callback) {
if (changedKeys.includes("updateTimer") || changedKeys.includes("deviceIP") || changedKeys.includes("deviceToken")) {
this.getAirFreshStatus();
this.getAirMonitorStatus();
callback(null, true);
}
}
Expand All @@ -95,7 +96,7 @@ class MiClearGlassAirDetector extends Homey.Device {
}

onDeleted() {
this.log("Device deleted deleted");
this.log("Device deleted");
clearInterval(this.updateInterval);
if (typeof this.device !== "undefined") {
this.device.destroy();
Expand Down
Loading

0 comments on commit fc7e96e

Please sign in to comment.