Skip to content

Commit

Permalink
[commandBool widget] Fixed error with primary command not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferllings committed Sep 29, 2015
1 parent 304e0d9 commit a58ab39
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions packs/widgets/basic/commandBool.html
Expand Up @@ -32,7 +32,7 @@
ready: function() {
this.super();
this.boolstate = null;
this.nextValue = 1;
this.currentValue = 0;
},
sensorsUpdated: function() {
if (this.$.boolstate.isSet) {
Expand All @@ -43,32 +43,32 @@
if (this.$.primary.isSet) {
this.labelprimary = this.$.primary.device['name'];
this.labelsecondary = this.$.primary.name;
this.sendtext = i18n.t("domoweb:bool.0", { context: this.$.primary.parameters[0]['datatype_id'] });
this.$.send.addEventListener('click', this.send.bind(this));
this.sendtext = i18n.t("domoweb:bool." + this.currentvalue, { context: this.$.primary.parameters[0]['datatype_id'] });
this.$.send.addEventListener('click', this.send.bind(this));
}
},
send: function(e) {
var parameters = {};
parameters[this.$.primary.parameters[0]['key']] = this.nextValue;
parameters[this.$.primary.parameters[0]['key']] = !this.currentValue;
this.$.primary.send(parameters);
e.preventDefault();
e.stopPropagation();
if (!this.hasFeedback) { //If no feedback sensor, we assume ok
this.boolstate = this.nextValue;
this.boolstate = !this.currentValue;
}
},
boolstateChanged: function(oldValue, newValue) {
var currentvalue = parseInt(newValue);
if (currentvalue == 1) {
this.nextValue = 0;
this.currentvalue = parseInt(newValue);
if (this.currentvalue == 1) {
this.$.send.classList.add('true');
this.$.send.classList.remove('false');
} else {
this.nextValue = 1;
this.$.send.classList.add('false');
this.$.send.classList.remove('true');
}
this.sendtext = i18n.t("domoweb:bool." + currentvalue, { context: this.$.primary.parameters[0]['datatype_id'] });
if (this.$.primary.isSet) {
this.sendtext = i18n.t("domoweb:bool." + this.currentvalue, { context: this.$.primary.parameters[0]['datatype_id'] });
}
}
});
</script>
Expand Down
12 changes: 6 additions & 6 deletions packs/widgets/basic/info.json
Expand Up @@ -27,7 +27,7 @@
"name": "Number",
"description": "Number sensor",
"types" : ["DT_Number"],
"required": true
"required": true
}
}
},
Expand All @@ -40,7 +40,7 @@
"name": "Bool",
"description": "Bool sensor",
"types" : ["DT_Bool"],
"required": true
"required": true
}
}
},
Expand All @@ -54,7 +54,7 @@
"types" : [
["DT_String"]
],
"required": true
"required": true
}
}
},
Expand All @@ -76,7 +76,7 @@
"types" : [
["DT_Bool"]
],
"required": true
"required": true
}
}
},
Expand All @@ -98,7 +98,7 @@
"types" : [
["DT_Scaling"]
],
"required": true
"required": true
}
}
},
Expand All @@ -119,7 +119,7 @@
"name": "Number",
"description": "Number sensor",
"types" : ["DT_Number"],
"required": true
"required": true
}
}
}
Expand Down

0 comments on commit a58ab39

Please sign in to comment.