From 14e9a4b9326cefee55b5321bfdca0a97602b05e1 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Thu, 22 Aug 2024 20:23:17 -0400 Subject: [PATCH] Add pof and vac places --- src/assets/HestiaClasses.js | 24 ++++++++++++++++++++++++ src/assets/hestia.js | 19 +++++++++++++++++-- src/index.html | 10 ++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/assets/HestiaClasses.js b/src/assets/HestiaClasses.js index 62b0a5e..e98ebb2 100644 --- a/src/assets/HestiaClasses.js +++ b/src/assets/HestiaClasses.js @@ -36,6 +36,30 @@ export class State { communicator.send(config.mqtt.topics.auger, JSON.stringify(this.auger)); } }; + + this.pof = { + on: false, + name: "pof", + topic: config.mqtt.topics.pof, + publisher: 'backend', + power: (communicator) => { + // This *should* toggle the state, asks if state is true, if it is set it false, otherwise set it true + this.pof.on ? this.pof.on = false : this.pof.on = true; + communicator.send(config.mqtt.topics.pof, JSON.stringify(this.pof)); + } + }; + + this.vacuum = { + on: false, + name: "vacuum", + topic: config.mqtt.topics.vacuum, + publisher: 'backend', + power: (communicator) => { + // This *should* toggle the state, asks if state is true, if it is set it false, otherwise set it true + this.vacuum.on ? this.vacuum.on = false : this.vacuum.on = true; + communicator.send(config.mqtt.topics.vacuum, JSON.stringify(this.vacuum)); + } + }; console.log(`State initialized.`) }; }; diff --git a/src/assets/hestia.js b/src/assets/hestia.js index 9fee2a1..71e9722 100644 --- a/src/assets/hestia.js +++ b/src/assets/hestia.js @@ -7,14 +7,18 @@ const config = { "topics": { "igniter": "hestia/status/igniter", "exhaust": "hestia/status/exhaust", - "auger": "hestia/status/auger" + "auger": "hestia/status/auger", + "pof": "hestia/status/pof", + "vacuum": "hestia/status/vacuum" } }, "states": { "elements": [ "igniter", "exhaust", - "auger" + "auger", + "pof", + "vacuum" ] } }; @@ -25,6 +29,8 @@ export function refreshState(doc, state) { const igniterStatus = doc.getElementById("igniter-status"); const exhaustStatus = doc.getElementById("exhaust-status"); const augerStatus = doc.getElementById("auger-status"); + const pofStatus = doc.getElementById("pof-status"); + const vacuumStatus = doc.getElementById("vacuum-status"); let statusString; statusString = ''; @@ -38,6 +44,15 @@ export function refreshState(doc, state) { statusString = ''; if (state.auger.on) statusString = "On"; else statusString = "Off"; augerStatus.innerHTML = statusString; + + statusString = ''; + if (state.pof.on) statusString = "On"; else statusString = "Off"; + pofStatus.innerHTML = statusString; + + statusString = ''; + if (state.vacuum.on) statusString = "On"; else statusString = "Off"; + vacuumStatus.innerHTML = statusString; + console.log('State refreshed.'); } diff --git a/src/index.html b/src/index.html index 6545be2..d97f464 100644 --- a/src/index.html +++ b/src/index.html @@ -43,6 +43,16 @@ Auger Placeholder + + + PoF + Placeholder + + + + Vacuum + Placeholder +