node-red-contrib-myhome-bticino-v2
Version:
Control Bticino / Legrand MyHome components from Node-RED
150 lines (144 loc) • 9.1 kB
HTML
central unit<script type="text/javascript">
RED.nodes.registerType('myhome-thermo-central',{
category: 'Bticino MyHome',
color: '#a6bbcf',
defaults: {
name: { value: '', required: true },
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 - 'ANTIFREEZE' ";
inputLabel += "\n - 'OFF_HEATING' ";
inputLabel += "\n - 'MANUAL_HEATING:xxxx' ";
inputLabel += "\n - 'PROGRAM_HEATING:x' ";
inputLabel += "\n - 'SCENARIO_HEATING:xx' ";
inputLabel += "\n - 'THERMAL_PROTECT' ";
inputLabel += "\n - 'OFF_CONDITIONING' ";
inputLabel += "\n - 'MANUAL_CONDITIONING:xxxx' ";
inputLabel += "\n - 'PROGRAM_CONDITIONING:x' ";
inputLabel += "\n - 'SCENARIO_CONDITIONING:xx' ";
inputLabel += "\n - 'OFF' ";
inputLabel += "\n - 'MANUAL:xxxx' ";
inputLabel += "\n - 'PROGRAM:x' ";
inputLabel += "\n - 'SCENARIO:xx' ";
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: 'mh-thermo-centralunit.svg',
paletteLabel: 'MH Thermo Central',
label: function() {
return this.name || 'MH Thermo Central';
},
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-central">
<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-thcentral.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-thcentral.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-thermo_onconnect_refreshstate"><i class="fa fa-refresh"></i> <span data-i18n="mh-thcentral.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-thcentral.config.thermo-onconnect-refreshstate-checkbox"></span>
<i class="fa fa-info-circle" data-i18n="[title]mh-thcentral.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-thcentral.config.secondary-output-content-text-state">[.state (string: see doc)]</option>
<option value="operationMode" data-i18n="mh-thcentral.config.secondary-output-content-mode">[.operationMode (string: see doc)]</option>
<option value="operationMode_ownValue" data-i18n="mh-thcentral.config.secondary-output-content-mode-ownvalue">[.operationMode_ownValue (string: see doc)]</option>
<option value="operationMode_setTemperature" data-i18n="mh-thcentral.config.secondary-output-content-mode-settemp">[.operationMode_setTemperature (number: °C)]</option>
<option value="operationMode_curProgram" data-i18n="mh-thcentral.config.secondary-output-content-mode-curprg">[.operationMode_curProgram (string: 1-3)]</option>
<option value="operationMode_curScenario" data-i18n="mh-thcentral.config.secondary-output-content-mode-curscen">[.operationMode_curScenario (string: 01-16)]</option>
<option value="remoteControl" data-i18n="mh-thcentral.config.secondary-output-content-remotecontrol">[.remoteControl (boolean: true / false)]</option>
</select>
</div>
</div>
</script>