Class: MqttAbilities::Mqtt

Inherits:
Object
  • Object
show all
Includes:
SlackRubyBot::Loggable
Defined in:
src/abilities/mqtt_abilities.rb

Instance Method Summary collapse

Instance Method Details

#publish(topic, message) ⇒ void

This method returns an undefined value.

Publish an MQTT message on a topic

Examples:

mqtt.publish 'temperature', '25'
mqtt.publish 'lamps/set', {1 => true, 2 => false}.to_json

Parameters:

  • topic (String)

    The MQTT topic to send on.

  • message (String)

    The message to send. Must be a string.



26
27
28
29
30
# File 'src/abilities/mqtt_abilities.rb', line 26

def publish(topic, message)
  mqtt_service.publish(topic.to_s, message.to_s)

  logger.debug "Published MQTT message on topic '#{topic}': #{message.inspect}"
end