wutu / pimatic-mqtt

MQTT plugin for Pimatic
https://pimatic.org/plugins/pimatic-mqtt/
GNU Affero General Public License v3.0
9 stars 13 forks source link

MQTT Buttons - Incoming Message Issue #19

Closed aap82 closed 7 years ago

aap82 commented 7 years ago

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.

wutu commented 7 years ago

Thx for reporting. Fixed in https://github.com/wutu/pimatic-mqtt/commit/5f8988b4617581a672d9a5fbcbed730558b31eff

aap82 commented 7 years ago

no problem.