I believe the logic for how to handle incoming messages is incorrect:
for b in @config.buttons
if b.stateTopic
@mqttclient.on 'message', (topic, message) =>
if b.stateTopic == topic
payload = message.toString()
if payload == b.message
@emit 'button', b.id
As its written above, you add an on message handler for n buttons in the button device, and emits n updates for a state update of a single button.
I believe the logic for how to handle incoming messages is incorrect:
As its written above, you add an on message handler for n buttons in the button device, and emits n updates for a state update of a single button.