Tentative test for control toggle
This commit is contained in:
parent
5fa3d5bb9c
commit
a987800cd7
@ -79,6 +79,11 @@ module.exports = {
|
||||
console.log(`Message received on topic ${topic}: ${msgStr}`);
|
||||
console.log(msgJson);
|
||||
state[msgJson.name].on = msgJson.on;
|
||||
const change = {
|
||||
name: msgJson.name,
|
||||
on: msgJson.on
|
||||
};
|
||||
this.emit('stateChange', change);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -21,3 +21,10 @@ setInterval(() => {
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
comms.on('stateChange', (change) => {
|
||||
console.log(`State change detected: ${change.name}`);
|
||||
gpio.togglePin(config.states[change.name].pin, change.on).then(() => {
|
||||
console.log(`Pin ${config.states[change.name].pin} set to ${change.on}`);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user