diff --git a/src/assets/hestia.js b/src/assets/hestia.js index 54bf0fc..8766ed5 100644 --- a/src/assets/hestia.js +++ b/src/assets/hestia.js @@ -37,8 +37,8 @@ const config = { }; // Create a new state and communicator -const psState = new State(config); -const comms = new Communicator(psState); +window.psState = new State(config); +const comms = new Communicator(window.psState); // Grab elements from the DOM const setFeedRateButton = document.getElementById("set-feed-rate"); @@ -81,8 +81,8 @@ export function refreshState(doc, state) { } export function togglePower(element) { - psState[element].power(comms); - refreshState(window.document, psState); + window.psState[element].power(comms); + refreshState(window.document, window.psState); } export function startup() { @@ -95,13 +95,13 @@ export function shutdown() { // Run stuff once the page loads window.onload = function() { - comms.init(psState, config); - refreshState(window.document, psState); + comms.init(window.psState, config); + refreshState(window.document, window.psState); }; setFeedRateButton.addEventListener("click", function() { const feedRate = document.getElementById("feed-rate").value; - psState.auger.feedRate = feedRate; - comms.send(config.mqtt.topics.auger, JSON.stringify(psState.auger)); - refreshState(window.document, psState); + window.psState.auger.feedRate = feedRate; + comms.send(config.mqtt.topics.auger, JSON.stringify(window.psState.auger)); + refreshState(window.document, window.psState); }); \ No newline at end of file