Blank mostly

This commit is contained in:
Skylar Grant 2024-08-15 06:53:26 -04:00
parent c7ffc0c296
commit 288d19e95b
8 changed files with 16 additions and 215 deletions

BIN
.DS_Store vendored

Binary file not shown.

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "hestia",
"version": "1.0.0",
"description": "Hestia Pellet Stove Controller by Skylar Grant",
"main": "src/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.vfsh.dev/voidf1sh/hestia"
},
"author": "Skylar Grant",
"license": "MIT"
}

View File

@ -1,71 +0,0 @@
export class State {
constructor(config) {
config.mqtt.subscriptions.forEach(subscription => {
this[subscription.name] = {
on: false,
topic: subscription.topic,
power: () => {
// This *should* toggle the state, asks if state is true, if it is set it false, otherwise set it true
this[subscription.name].on ? this[subscription.name].on = false : this[subscription.name].on = true;
}
};
});
};
};
export class Communicator {
constructor(state) {
// Connect to the MQTT Broker
this.client = mqtt.connect(config.mqtt.address);
// Subscribe to status topics
config.mqtt.subscriptions.forEach(subscription => {
this.client.subscribe(subscription.topic);
state[subscription.name].topic = subscription.topic;
});
}
powerOn(element, state) {
// Send the enable igniter message
// Publish with retain flag set to true
this.client.publish(topic, message, { retain: true }, (err) => {
if (err) {
console.error('Failed to publish message:', err);
} else {
console.log('Message published and retained on topic:', topic);
}
// Optionally close the connection
client.end();
});
// Confirm
// Update state
state.igniterOn();
return state;
}
igniterOn(state) {
}
augerOn(state) {
// Send the enable auger message
// Confirm
// Update state
state.augerOn();
return state;
}
exhaustOn(state) {
// Send the enable exhaust message
// Confirm
// Update state
state.exhaustOn();
return state;
}
}

View File

@ -1,19 +0,0 @@
{
"mqtt": {
"address": "wd://broker-url:port",
"subscriptions": [
{
"name": "igniter",
"topic": "hestia/status/igniter"
},
{
"name": "exhaust",
"topic": "hestia/status/exhaust"
},
{
"name": "auger",
"topic": "hestia/status/auger"
}
]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

View File

@ -1,39 +0,0 @@
import { Communicator,State } from './HestiaClasses.js';
window.onload = async function() {
await fetch('/assets/config.json')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON data from the response
})
.then(data => {
const config = data;
console.log(config);
const psState = new State(config);
refreshState(window.document, psState);
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
};
function refreshState(doc, state) {
const igniterStatus = doc.getElementById("igniter-status");
const exhaustStatus = doc.getElementById("exhaust-status");
const augerStatus = doc.getElementById("auger-status");
let statusString;
statusString = '';
if (state.igniter.on) statusString = "On"; else statusString = "Off";
igniterStatus.innerHTML = statusString;
statusString = '';
if (state.exhaust.on) statusString = "On"; else statusString = "Off";
exhaustStatus.innerHTML = statusString;
statusString = '';
if (state.auger.on) statusString = "On"; else statusString = "Off";
augerStatus.innerHTML = statusString;
}

View File

@ -1,86 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hestia</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
<script type="module" src="./assets/hestia.js"></script>
</head>
<body class="bg-gray-900 text-white font-sans">
<marquee style="color: yellow; background-color: red; font-weight: bold;">
PELLET STOVE FREE TRIAL HAS ENDED, PLEASE PURCHASE A LICENSE NOW!
</marquee>
<div class="container mx-auto py-8 max-w-md">
<h1 class="text-3xl text-center text-purple-400 font-bold mb-8">Hestia Control Panel</h1>
<div class="controls-container bg-gray-800 p-6 rounded-lg shadow-lg space-y-4">
<table class="min-w-full bg-gray-900 text-white rounded-lg shadow-lg">
<thead>
<tr>
<th class="py-2 px-4 text-left text-purple-400">Element</th>
<th class="py-2 px-4 text-left text-purple-400">Status</th>
</tr>
</thead>
<tbody>
<tr class="border-b border-gray-700">
<td class="py-2 px-4">Igniter</td>
<td class="py-2 px-4" id="igniter-status">Placeholder</td>
</tr>
<tr class="border-b border-gray-700">
<td class="py-2 px-4">Exhaust</td>
<td class="py-2 px-4" id="exhaust-status">Placeholder</td>
</tr>
<tr>
<td class="py-2 px-4">Auger</td>
<td class="py-2 px-4" id="auger-status">Placeholder</td>
</tr>
</tbody>
</table>
<form action="/" method="post">
<!-- Start | Shutdown | Reload Settings -->
<div class="button-container flex">
<input class="btn bg-gray-700 hover:bg-purple-600 text-white py-2 w-full rounded mx-auto" type="submit" id="igniter-toggle-btn" value="Toggle Igniter" name="igniterToggle">
</div>
<div class="button-container flex mt-4">
<input class="btn bg-gray-700 hover:bg-purple-600 text-white py-2 w-full rounded mx-auto" type="submit" id="exhaust-toggle-btn" value="Toggle Exhaust" name="exhaustToggle">
</div>
<div class="button-container flex mt-4">
<input class="btn bg-gray-700 hover:bg-purple-600 text-white py-2 w-full rounded mx-auto" type="submit" id="auger-toggle-btn" value="Toggle Auger" name="augerToggle">
</div>
<!-- Set feed rates -->
<div class="form-group mt-4">
<label for="feedRate" class="block text-sm font-medium text-purple-400">Feed Rate:</label>
<select name="feedRate" class="form-control bg-gray-700 text-white mt-1 block w-full rounded border-gray-600 focus:border-purple-500 focus:ring-purple-500 py-2 px-4">
<option value="500">Low</option>
<option value="625">Medium-Low</option>
<option value="750">Medium</option>
<option value="875">Medium-High</option>
<option value="1000">High</option>
</select>
</div>
<div class="button-container flex justify-end mt-4">
<input class="btn bg-purple-600 hover:bg-purple-700 text-white py-2 px-4 rounded w-full" type="submit" id="reload" value="Set Feed Rate" name="reload">
</div>
</form>
</div>
<div class="text-center my-8">
<img src="./assets/dancing_jesus.gif" class="img-fluid mx-auto rounded-lg shadow-lg" alt="Dancing Jesus">
</div>
<div class="controls-container bg-gray-800 p-6 rounded-lg shadow-lg hidden" id="quitContainer">
<form action="/" method="POST">
<input class="btn bg-red-600 hover:bg-red-700 text-white py-2 px-4 rounded w-full" type="submit" id="quit" value="Quit!!" name="quit">
</form>
</div>
</div>
</body>
</html>

1
src/main.js Normal file
View File

@ -0,0 +1 @@
// Hestia Control Panel Back-End