Add array to iterate over for elements
This commit is contained in:
parent
5af6ca77ba
commit
f09f4dcf24
@ -1,5 +1,6 @@
|
||||
export class State {
|
||||
constructor() {
|
||||
this.elements = ["igniter", "exhaust", "auger"],
|
||||
this.igniter = {
|
||||
on: false,
|
||||
topic: 'hestia/status/igniter',
|
||||
@ -55,10 +56,10 @@ export class Communicator {
|
||||
client.on('connect', () => {
|
||||
console.log('Connected to MQTT broker');
|
||||
// Subscribe to status topics
|
||||
state.forEach(element => {
|
||||
client.subscribe(element.topic, (err) => {
|
||||
state.elements.forEach(element => {
|
||||
client.subscribe(state[element].topic, (err) => {
|
||||
if (!err) {
|
||||
console.log(`Subscribed to ${element.topic}`);
|
||||
console.log(`Subscribed to ${state[element].topic}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user