From 99d88ff82ab44cb9389885051950a3752e931e09 Mon Sep 17 00:00:00 2001 From: Pierre CLEMENT Date: Thu, 25 Jan 2018 21:08:58 +0100 Subject: [PATCH] fix(magnet): updateContact from abstract-thing takes true when the magnet is close and false if open Related to aholstenson/miio#101 --- lib/devices/gateway/magnet.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/devices/gateway/magnet.js b/lib/devices/gateway/magnet.js index 38dea94..0c3c2ba 100644 --- a/lib/devices/gateway/magnet.js +++ b/lib/devices/gateway/magnet.js @@ -18,10 +18,11 @@ module.exports = class Magnet extends SubDevice.with(Contact, Voltage) { } propertyUpdated(key, value, oldValue) { + console.log(key, value, oldValue); if(key === 'status') { // Change the contact state - const isOpen = value === 'open'; - this.updateContact(isOpen); + const isContact = value === 'close'; + this.updateContact(isContact); } super.propertyUpdated(key, value, oldValue);