Hey there! I'm a bit clueless and hope you may be able to help me.
It concerns one of my nodes, node-red-contrib-smarthome-powerswitch. It's something pretty simple. Until now, the output's topic was always command
and the payload either boolean true
or false
. So in the HTML file, I added:
RED.nodes.registerType('powerswitch',{
category: 'Smart Home',
color: '#C0DEED',
defaults: {
...
outputPayloadOnType: {value: "initval"},
outputPayloadOn: {value: true},
outputPayloadOffType: {value: "initval"},
outputPayloadOff: {value: false}
},
...
oneditprepare: function() {
...
if (this.outputPayloadOnType === 'initval') {
$("#node-input-outputPayloadOnType").val('bool');
}
if (this.outputPayloadOffType === 'initval') {
$("#node-input-outputPayloadOffType").val('bool');
}
...
$("#node-input-outputPayloadOn").typedInput({
default: 'bool',
typeField: $("#node-input-outputPayloadOnType"),
types:['str','num','bool']
});
$("#node-input-outputPayloadOff").typedInput({
default: 'bool',
typeField: $("#node-input-outputPayloadOffType"),
types:['str','num','bool']
});
...
The idea was to have the initial values the same as the hardcoded values have been before the update. That is: boolean true
for payload On and boolean false
for payload Off.
Basically everything works. The only thing bothering me is that as soon as I update the node to the latest development version, it shows both boolean true
for payload On and payload Off, as shown below:
This is inacceptable since after an update, the behaviour would be different than before the update.
The question is: Why does the field "Off Payload" also show true
, eventhough it has a declared false
as default value (outputPayloadOff: {value: false}
)?
Link to the code before the update: GitHub - danube/node-red-contrib-smarthome-powerswitch at v1.0.11
Link to the node after the update: GitHub - danube/node-red-contrib-smarthome-powerswitch at v1.1.0