node-red-contrib-myhome-bticino-v2
Version:
Control Bticino / Legrand MyHome components from Node-RED
149 lines (143 loc) • 8.96 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('myhome-thermo-zone',{
category: 'Bticino MyHome',
color: '#a6bbcf',
defaults: {
name: { value: '', required: true },
zoneid: { value: '', required: true, validate: RED.validators.number() },
topic: { value: '', required: true},
gateway: { type: 'myhome-gateway', required: true },
thermo_onconnect_refreshstate: { value: true, required: false},
isstatusrequest: { value: false, required: false},
skipevents: { value: false, required: false},
smartfilter: { value: true, required: false},
output2_name: { value: 'On', required: false},
output2_type: { value: 'text_state', required: false}
},
inputs: 1,
inputLabels: function () {
let inputLabel = this._("common.input-label-simple") + ":";
inputLabel += "\n - 'xx.x' : manual mode to xx.x °C ";
inputLabel += "\n - 'OFF' ";
inputLabel += "\n - 'AUTO' ";
inputLabel += "\n - 'PROTECT' ";
inputLabel += "\n - 'THERMAL_PROTECT' ";
inputLabel += "\n - 'ANTIFREEZE' ";
return inputLabel;
},
outputs: 2,
outputLabels: function (index) {
if (index === 0) {
return 'payload';
} else if (index === 1) {
let outputTypeDescr;
if (this.output2_type === 'text_state') {
outputTypeDescr = '°C';
} else {
outputTypeDescr = '.' + this.output2_type;
}
return 'payload' + ((this.output2_name === '') ? '' : ('.' + this.output2_name)) + " = " + outputTypeDescr;
}
},
icon: 'font-awesome/fa-thermometer-half',
paletteLabel: 'MH Thermo Zone',
label: function() {
return this.name || 'MH Thermo Zone';
},
oneditprepare: function() {
let scope = this;
$('#node-input-topic').on('change', function() {
let topicName = $(this).val();
let topicInfo = scope._('common.topic-info' , {'topicName': (topicName) ? topicName : 'topic'});
$('#node-info-topic').prop('title' , topicInfo);
});
function checkboxEditable (checkBoxID , isEditable, readonlyValue) {
// Function to turn checkbox uneditable (=greyed out box & label, disabled access and value forced), or back editable
$('#' + checkBoxID)
.prop('checked', (isEditable) ? $('#' + checkBoxID).prop('checked') : readonlyValue)
.prop('disabled', !isEditable)
.change()
.next().css('color', (isEditable) ? '' : 'LightGrey');
}
$('#node-input-skipevents').on('change', function() {
// All gateway events are to be ignored. SmartFilter has nothig to filter (so assume is always 'forced on')
let isEditable = !($(this).prop('checked'));
checkboxEditable ('node-input-smartfilter' , isEditable, true);
});
}
});
</script>
<script type="text/x-red" data-template-name="myhome-thermo-zone">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]mh-thzone.config.name-placeholder"/>
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-terminal"></i> <span data-i18n="common.topic"></span></label>
<input type="text" id="node-input-topic" data-i18n="[placeholder]mh-thzone.config.topic-placeholder"/>
<i id="node-info-topic" class="fa fa-info-circle" title=""></i>
</div>
<div class="form-row">
<label for="node-input-gateway"><i class="fa fa-server"></i> <span data-i18n="common.gateway"></span></label>
<input type="text" id="node-input-gateway"/>
</div>
<div style="border-top-style: solid ;border-width: 1px; border-color: #CCCCCC; height: 10px;"></div>
<div class="form-row">
<label for="node-input-zoneid"><i class="fa fa-thermometer-half"></i> <span data-i18n="mh-thzone.config.zoneid"></span></label>
<input type="text" id="node-input-zoneid" placeholder="1-99"/>
</div>
<div class="form-row">
<label for="node-input-thermo_onconnect_refreshstate"><i class="fa fa-refresh"></i> <span data-i18n="mh-thzone.config.thermo-onconnect-refreshstate"></span></label>
<label for="node-input-thermo_onconnect_refreshstate" style="width:70%">
<input type="checkbox" id="node-input-thermo_onconnect_refreshstate" style="display:inline-block; margin-left:0px; width:22px; vertical-align:baseline;"/><span data-i18n="mh-thzone.config.thermo-onconnect-refreshstate-checkbox"></span>
<i class="fa fa-info-circle" data-i18n="[title]mh-thzone.config.thermo-onconnect-refreshstate-info"></i>
</label>
</div>
<div class="form-row">
<label for="node-input-isstatusrequest"><i class="fa fa-eye"></i> <span data-i18n="common.option-readonly"></span></label>
<label for="node-input-isstatusrequest" style="width:70%">
<input type="checkbox" id="node-input-isstatusrequest" style="display:inline-block; margin-left:0px; width:22px; vertical-align:baseline;"/><span data-i18n="common.option-readonly-checkbox"></span>
<i class="fa fa-info-circle" data-i18n="[title]common.option-readonly-info"></i>
</label>
</div>
<div class="form-row">
<label for="node-input-skipevents"><i class="fa fa-ban"></i> <span data-i18n="common.option-skipevents"></span></label>
<label for="node-input-skipevents" style="width:70%">
<input type="checkbox" id="node-input-skipevents" style="display:inline-block; margin-left:0px; width:22px; vertical-align:baseline;"/><span data-i18n="common.option-skipevents-checkbox"></span>
<i class="fa fa-info-circle" data-i18n="[title]common.option-skipevents-info"></i>
</label>
</div>
<div class="form-row">
<label for="node-input-smartfilter"><i class="fa fa-filter"></i> <span data-i18n="common.option-smartfilter"></span></label>
<label for="node-input-smartfilter" style="width:70%">
<input type="checkbox" id="node-input-smartfilter" style="display:inline-block; margin-left:0px; width:22px; vertical-align:baseline;"/><span data-i18n="common.option-smartfilter-checkbox"></span>
<i class="fa fa-info-circle" data-i18n="[title]common.option-smartfilter-info"></i>
</label>
</div>
<div class="form-tips form-row" style="max-width:none; background:#EFEFEF">
<i class="fa fa-sign-out"></i> <b><span data-i18n="common.secondary-output-title"></span></b>
<br>
<p style="max-width:450px" data-i18n="common.secondary-output-intro"></p>
<div class="form-row">
<label for="node-input-output2_name" style="width:130px; margin-left:15px"><i class="fa fa-tags"></i> <span data-i18n="common.secondary-output-name"></span></label>
<input type="text" id="node-input-output2_name" data-i18n="[placeholder]common.secondary-output-name-placeholder" style="width:55%"/>
<label for="node-input-output2_name" style="width:15px">
<i class="fa fa-info-circle" data-i18n="[title]common.secondary-output-name-info"></i>
</label>
</div>
<div class="form-row">
<label for="node-input-output2_type" style="width:130px; margin-left:15px"><i class="fa fa-check-square-o"></i> <span data-i18n="common.secondary-output-content"></span></label>
<select id="node-input-output2_type" style="width:55%">
<option value="text_state" data-i18n="mh-thzone.config.secondary-output-content-textstate">[.state (number: °C)]</option>
<option value="setTemperature" data-i18n="mh-thzone.config.secondary-output-content-settemp">[.setTemperature (number: °C)]</option>
<option value="operationType_ownValue" data-i18n="mh-thzone.config.secondary-output-content-optype-ownvalue">[.operationType_ownValue (string: see doc)]</option>
<option value="operationType" data-i18n="mh-thzone.config.secondary-output-content-optype">[.operationType (string: see doc)]</option>
<option value="operationMode_ownValue" data-i18n="mh-thzone.config.secondary-output-content-opmode-ownvalue">[.operationMode_ownValue (string: see doc)]</option>
<option value="operationMode" data-i18n="mh-thzone.config.secondary-output-content-opmode">[.operationMode (string: see doc)]</option>
<option value="localOffset_ownValue" data-i18n="mh-thzone.config.secondary-output-content-offset-ownvalue">[.localOffset_ownValue (string: see doc)]</option>
<option value="localOffset" data-i18n="mh-thzone.config.secondary-output-content-offset">[.localOffset (string/number: see doc)]</option>
<option value="actuatorStates.On" data-i18n="mh-thzone.config.secondary-output-content-actuatorstates-on">[.actuatorStates.On (boolean: true / false)]</option>
</select>
</div>
</div>
</script>