Monitor motorhome leisure battery and provide simple control of habitation
Dependencies: net lpc1768 crypto clock web fram log
web-this/boiler/web-boiler-script.js
- Committer:
- andrewboyson
- Date:
- 2021-01-14
- Revision:
- 0:b843d647695c
File content as of revision 0:b843d647695c:
//Boiler script 'use strict'; let dateTime = ''; let tankTemperature = ''; let blrOutTemperature = ''; let blrRtnTemperature = ''; let boilerCall = false; let boilerPump = false; let tankSetPoint = ''; let tankHysteresis = ''; let blrRunOnDeg = ''; let blrRunOnTime = ''; function parse() { let lines = Ajax.response.split('\n'); tankTemperature = Ajax.hexToSignedInt16(lines[0]); blrOutTemperature = Ajax.hexToSignedInt16(lines[1]); blrRtnTemperature = Ajax.hexToSignedInt16(lines[2]); boilerCall = Ajax.hexToBit (lines[3], 0); boilerPump = Ajax.hexToBit (lines[3], 1); tankSetPoint = Ajax.hexToSignedInt16(lines[4]); tankHysteresis = Ajax.hexToSignedInt16(lines[5]); blrRunOnDeg = Ajax.hexToSignedInt16(lines[6]); blrRunOnTime = Ajax.hexToSignedInt16(lines[7]); } function display() { let elem; elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature); elem = Ajax.getElementOrNull('ajax-blr-out-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature); elem = Ajax.getElementOrNull('ajax-blr-rtn-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrRtnTemperature); elem = Ajax.getElementOrNull('ajax-blr-rise-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature - blrRtnTemperature); elem = Ajax.getElementOrNull('ajax-blr-call-toggle'); if (elem) elem.setAttribute('dir', boilerCall ? 'rtl' : 'ltr'); elem = Ajax.getElementOrNull('ajax-blr-pump-toggle'); if (elem) elem.setAttribute('dir', boilerPump ? 'rtl' : 'ltr'); elem = Ajax.getElementOrNull('ajax-tank-set-point' ); if (elem) elem.value = tankSetPoint; elem = Ajax.getElementOrNull('ajax-tank-hysteresis'); if (elem) elem.value = tankHysteresis; elem = Ajax.getElementOrNull('ajax-blr-run-on-deg' ); if (elem) elem.value = OneWire.DS18B20ToString(blrRunOnDeg); elem = Ajax.getElementOrNull('ajax-blr-run-on-time'); if (elem) elem.value = blrRunOnTime; } Ajax.server = '/boiler-ajax'; Ajax.onResponse = function() { parse(); display(); }; Ajax.init();