diff --git a/.DS_Store b/.DS_Store index e981ce7..f5ae1c8 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..cd7f20f --- /dev/null +++ b/package.json @@ -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" +} diff --git a/src/assets/HestiaClasses.js b/src/assets/HestiaClasses.js deleted file mode 100644 index 32be192..0000000 --- a/src/assets/HestiaClasses.js +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/src/assets/config.json b/src/assets/config.json deleted file mode 100644 index 129060e..0000000 --- a/src/assets/config.json +++ /dev/null @@ -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" - } - ] - } -} \ No newline at end of file diff --git a/src/assets/dancing_jesus.gif b/src/assets/dancing_jesus.gif deleted file mode 100644 index 9b118bb..0000000 Binary files a/src/assets/dancing_jesus.gif and /dev/null differ diff --git a/src/assets/hestia.js b/src/assets/hestia.js deleted file mode 100644 index 3088bef..0000000 --- a/src/assets/hestia.js +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/src/index.html b/src/index.html deleted file mode 100644 index b82cd16..0000000 --- a/src/index.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - Hestia - - - - - - - - PELLET STOVE FREE TRIAL HAS ENDED, PLEASE PURCHASE A LICENSE NOW! - - -
-

Hestia Control Panel

- -
- - - - - - - - - - - - - - - - - - - - - -
ElementStatus
IgniterPlaceholder
ExhaustPlaceholder
AugerPlaceholder
-
- -
- -
-
- -
-
- -
- - -
- - -
-
- -
-
-
- -
- Dancing Jesus -
- - -
- - - - \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..bf9ae54 --- /dev/null +++ b/src/main.js @@ -0,0 +1 @@ +// Hestia Control Panel Back-End