Skip to content

Commit

Permalink
1.0.8 version minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxmudjon committed Dec 1, 2019
1 parent e088107 commit 098b182
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
6 changes: 5 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.0.7 - Supported devices:
## Version 1.0.8 - Supported devices:

### Zigbee subdevices Xiaomi Gateway

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

## Version logs

### 1.0.8 (1.12.2019)

1. minor fixes.

### 1.0.7 (23.11.2019)

1. minor fixes.
Expand Down
4 changes: 2 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.0.7",
"version": "1.0.8",
"compatibility": ">=2.0.0",
"sdk": 2,
"name": {
Expand Down Expand Up @@ -34,7 +34,7 @@
"contributing": {
"donate": {
"paypal": {
"username": "maxmudjon"
"username": "Sallo"
}
}
},
Expand Down
25 changes: 15 additions & 10 deletions drivers/curtain/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Curtain extends Homey.Device {

registerCapabilities() {
const { triggers } = this.driver;
this.registerToggle("onoff", "open", "close", triggers.power);
this.registerToggle("onoff");
this.registerDim("dim");
this.registerCovering("windowcoverings_state");
}
Expand All @@ -35,7 +35,7 @@ class Curtain extends Homey.Device {

registerActions() {
const { actions } = this.driver;
this.registerToggleAction("onoff", "open", "close", actions.power);
this.registerToggleAction("onoff", actions.power);
}

handleStateChange(device) {
Expand Down Expand Up @@ -106,13 +106,17 @@ class Curtain extends Homey.Device {
}
}

registerToggle(name, valueOn = true, valueOff = false, trigger) {
registerToggle(name) {
let sid = this.data.sid;
this.registerCapabilityListener(name, async value => {
const newValue = value ? valueOn : valueOff;
const data = { curtain_status: newValue };
await Homey.app.mihub.sendWrite(sid, data);
this.triggerFlow(trigger, name, value);
const settings = this.getSettings();
if (value) {
const data = { curtain_status: settings.reverted ? "open" : "close" };
await Homey.app.mihub.sendWrite(sid, data);
} else {
const data = { curtain_status: settings.reverted ? "close" : "open" };
await Homey.app.mihub.sendWrite(sid, data);
}
});
}

Expand Down Expand Up @@ -148,15 +152,16 @@ class Curtain extends Homey.Device {
condition.registerRunListener((args, state) => Promise.resolve(this.getCapabilityValue(name)));
}

registerToggleAction(name, valueOn = true, valueOff = false, action) {
registerToggleAction(name, action) {
let sid = this.data.sid;
const settings = this.getSettings();
action.on.registerRunListener(async (args, state) => {
const data = { status: valueOn };
const data = { status: settings.reverted ? "open" : "close" };
await Homey.app.mihub.sendWrite(sid, data);
return true;
});
action.off.registerRunListener(async (args, state) => {
const data = { status: valueOff };
const data = { status: settings.reverted ? "close" : "open" };
await Homey.app.mihub.sendWrite(sid, data);
return true;
});
Expand Down
1 change: 1 addition & 0 deletions drivers/wleak_sensor/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class WleakSensor extends Homey.Device {
var battery = (device["data"]["voltage"] - 2800) / 5;
this.updateCapabilityValue("measure_battery", battery > 100 ? 100 : battery);
this.updateCapabilityValue("alarm_battery", battery <= 20 ? true : false);
if (this.getCapabilityValue("alarm_water")) this.updateCapabilityValue("alarm_water", false);
}

if (device["data"]["status"] == "leak") {
Expand Down

0 comments on commit 098b182

Please sign in to comment.