Compare commits

...

2 Commits

Author SHA1 Message Date
14e9a4b932 Add pof and vac places 2024-08-22 20:23:17 -04:00
2fd5239094 Ignore package-lock 2024-08-22 20:16:06 -04:00
4 changed files with 52 additions and 2 deletions

1
.gitignore vendored
View File

@ -110,3 +110,4 @@ dist
# TernJS port file # TernJS port file
.tern-port .tern-port
package-lock.json

View File

@ -36,6 +36,30 @@ export class State {
communicator.send(config.mqtt.topics.auger, JSON.stringify(this.auger)); 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.`) console.log(`State initialized.`)
}; };
}; };

View File

@ -7,14 +7,18 @@ const config = {
"topics": { "topics": {
"igniter": "hestia/status/igniter", "igniter": "hestia/status/igniter",
"exhaust": "hestia/status/exhaust", "exhaust": "hestia/status/exhaust",
"auger": "hestia/status/auger" "auger": "hestia/status/auger",
"pof": "hestia/status/pof",
"vacuum": "hestia/status/vacuum"
} }
}, },
"states": { "states": {
"elements": [ "elements": [
"igniter", "igniter",
"exhaust", "exhaust",
"auger" "auger",
"pof",
"vacuum"
] ]
} }
}; };
@ -25,6 +29,8 @@ export function refreshState(doc, state) {
const igniterStatus = doc.getElementById("igniter-status"); const igniterStatus = doc.getElementById("igniter-status");
const exhaustStatus = doc.getElementById("exhaust-status"); const exhaustStatus = doc.getElementById("exhaust-status");
const augerStatus = doc.getElementById("auger-status"); const augerStatus = doc.getElementById("auger-status");
const pofStatus = doc.getElementById("pof-status");
const vacuumStatus = doc.getElementById("vacuum-status");
let statusString; let statusString;
statusString = ''; statusString = '';
@ -38,6 +44,15 @@ export function refreshState(doc, state) {
statusString = ''; statusString = '';
if (state.auger.on) statusString = "On"; else statusString = "Off"; if (state.auger.on) statusString = "On"; else statusString = "Off";
augerStatus.innerHTML = statusString; 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.'); console.log('State refreshed.');
} }

View File

@ -43,6 +43,16 @@
<td class="py-2 px-4">Auger</td> <td class="py-2 px-4">Auger</td>
<td class="py-2 px-4" id="auger-status">Placeholder</td> <td class="py-2 px-4" id="auger-status">Placeholder</td>
</tr> </tr>
<!-- PoF -->
<tr>
<td class="py-2 px-4">PoF</td>
<td class="py-2 px-4" id="pof-status">Placeholder</td>
</tr>
<!-- Vacuum -->
<tr>
<td class="py-2 px-4">Vacuum</td>
<td class="py-2 px-4" id="vacuum-status">Placeholder</td>
</tr>
</tbody> </tbody>
</table> </table>
<div class="button-container flex"> <div class="button-container flex">