Controls the central heating system and the lights.
Dependencies: 1-wire clock crypto fram log lpc1768 net web wiz mbed
web-this/radiator/web-radiator-script.inc@5:3579001bea1b, 2021-05-20 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu May 20 14:34:51 2021 +0000
- Revision:
- 5:3579001bea1b
- Parent:
- 0:22b158d3c76f
- Child:
- 8:8ac076ce51af
Added ability for the user to prioritise hot water for showers by allowing a limit on the tank temperature below which the radiator pump stops
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 0:22b158d3c76f | 1 | "//Radiator script\n" |
andrewboyson | 0:22b158d3c76f | 2 | "'use strict';\n" |
andrewboyson | 0:22b158d3c76f | 3 | "\n" |
andrewboyson | 0:22b158d3c76f | 4 | "let hallTemperature = '';\n" |
andrewboyson | 5:3579001bea1b | 5 | "let tankTemperature = '';\n" |
andrewboyson | 0:22b158d3c76f | 6 | "let programTimerOutput = false;\n" |
andrewboyson | 0:22b158d3c76f | 7 | "let radiatorMode = false;\n" |
andrewboyson | 0:22b158d3c76f | 8 | "let radiatorOverride = false;\n" |
andrewboyson | 0:22b158d3c76f | 9 | "let radiatorPump = false;\n" |
andrewboyson | 5:3579001bea1b | 10 | "let hotWaterProtectOn = false;\n" |
andrewboyson | 0:22b158d3c76f | 11 | "let overrideCancelHour = '';\n" |
andrewboyson | 0:22b158d3c76f | 12 | "let overrideCancelMinute = '';\n" |
andrewboyson | 0:22b158d3c76f | 13 | "let nightSetPoint = '';\n" |
andrewboyson | 0:22b158d3c76f | 14 | "let frostSetPoint = '';\n" |
andrewboyson | 5:3579001bea1b | 15 | "let hotWaterProtectTemp = '';\n" |
andrewboyson | 0:22b158d3c76f | 16 | "\n" |
andrewboyson | 0:22b158d3c76f | 17 | "function parse()\n" |
andrewboyson | 0:22b158d3c76f | 18 | "{\n" |
andrewboyson | 0:22b158d3c76f | 19 | " let lines = Ajax.response.split('\\n');\n" |
andrewboyson | 0:22b158d3c76f | 20 | " hallTemperature = Ajax.hexToSignedInt16(lines[0]);\n" |
andrewboyson | 5:3579001bea1b | 21 | " tankTemperature = Ajax.hexToSignedInt16(lines[1]);\n" |
andrewboyson | 5:3579001bea1b | 22 | " programTimerOutput = Ajax.hexToBit (lines[2], 0);\n" |
andrewboyson | 5:3579001bea1b | 23 | " radiatorMode = Ajax.hexToBit (lines[2], 1);\n" |
andrewboyson | 5:3579001bea1b | 24 | " radiatorOverride = Ajax.hexToBit (lines[2], 2);\n" |
andrewboyson | 5:3579001bea1b | 25 | " radiatorPump = Ajax.hexToBit (lines[2], 3);\n" |
andrewboyson | 5:3579001bea1b | 26 | " hotWaterProtectOn = Ajax.hexToBit (lines[2], 4);\n" |
andrewboyson | 5:3579001bea1b | 27 | " overrideCancelHour = Ajax.hexToSignedInt8 (lines[3]);\n" |
andrewboyson | 5:3579001bea1b | 28 | " overrideCancelMinute = Ajax.hexToSignedInt8 (lines[4]);\n" |
andrewboyson | 5:3579001bea1b | 29 | " nightSetPoint = Ajax.hexToSignedInt16(lines[5]);\n" |
andrewboyson | 5:3579001bea1b | 30 | " frostSetPoint = Ajax.hexToSignedInt16(lines[6]);\n" |
andrewboyson | 5:3579001bea1b | 31 | " hotWaterProtectTemp = Ajax.hexToSignedInt8 (lines[7]);\n" |
andrewboyson | 0:22b158d3c76f | 32 | "}\n" |
andrewboyson | 0:22b158d3c76f | 33 | "function display()\n" |
andrewboyson | 0:22b158d3c76f | 34 | "{\n" |
andrewboyson | 0:22b158d3c76f | 35 | " let elem;\n" |
andrewboyson | 5:3579001bea1b | 36 | " elem = Ajax.getElementOrNull('ajax-hall-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(hallTemperature);\n" |
andrewboyson | 5:3579001bea1b | 37 | " elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature);\n" |
andrewboyson | 5:3579001bea1b | 38 | " elem = Ajax.getElementOrNull('ajax-program-toggle' ); if (elem) elem.setAttribute('dir', programTimerOutput ? 'rtl' : 'ltr');\n" |
andrewboyson | 5:3579001bea1b | 39 | " elem = Ajax.getElementOrNull('ajax-mode-toggle' ); if (elem) elem.setAttribute('dir', radiatorMode ? 'rtl' : 'ltr');\n" |
andrewboyson | 5:3579001bea1b | 40 | " elem = Ajax.getElementOrNull('ajax-override-toggle' ); if (elem) elem.setAttribute('dir', radiatorOverride ? 'rtl' : 'ltr');\n" |
andrewboyson | 5:3579001bea1b | 41 | " elem = Ajax.getElementOrNull('ajax-radiator-toggle' ); if (elem) elem.setAttribute('dir', radiatorPump ? 'rtl' : 'ltr');\n" |
andrewboyson | 5:3579001bea1b | 42 | " elem = Ajax.getElementOrNull('ajax-hw-prot-toggle' ); if (elem) elem.setAttribute('dir', hotWaterProtectOn ? 'rtl' : 'ltr');\n" |
andrewboyson | 5:3579001bea1b | 43 | " elem = Ajax.getElementOrNull('ajax-override-cancel-minute'); if (elem)\n" |
andrewboyson | 0:22b158d3c76f | 44 | " {\n" |
andrewboyson | 0:22b158d3c76f | 45 | " elem.value = String(overrideCancelHour*100 + overrideCancelMinute).padStart(4, '0');\n" |
andrewboyson | 0:22b158d3c76f | 46 | " }\n" |
andrewboyson | 0:22b158d3c76f | 47 | " elem = Ajax.getElementOrNull('ajax-night-set-point' ); if (elem) elem.value = nightSetPoint;\n" |
andrewboyson | 0:22b158d3c76f | 48 | " elem = Ajax.getElementOrNull('ajax-frost-set-point' ); if (elem) elem.value = frostSetPoint;\n" |
andrewboyson | 5:3579001bea1b | 49 | " elem = Ajax.getElementOrNull('ajax-hw-prot-temp' ); if (elem) elem.value = hotWaterProtectTemp;\n" |
andrewboyson | 0:22b158d3c76f | 50 | "}\n" |
andrewboyson | 0:22b158d3c76f | 51 | "\n" |
andrewboyson | 0:22b158d3c76f | 52 | "Ajax.server = '/radiator-ajax';\n" |
andrewboyson | 0:22b158d3c76f | 53 | "Ajax.onResponse = function() { parse(); display(); };\n" |
andrewboyson | 0:22b158d3c76f | 54 | "Ajax.init();\n" |
andrewboyson | 0:22b158d3c76f | 55 | "" |