class M2X::MQTT

Constants

VERSION

Attributes

client[RW]

Public Class Methods

new(api_key, options={}) click to toggle source
# File lib/m2x/mqtt.rb, line 14
def initialize(api_key, options={})
  @api_key = api_key
  @options = options
end

Public Instance Methods

create_device(attributes) click to toggle source
# File lib/m2x/mqtt.rb, line 43
def create_device(attributes)
  M2X::MQTT::Device.create!(client, attributes)
end
device(id) click to toggle source
# File lib/m2x/mqtt.rb, line 39
def device(id)
  M2X::MQTT::Device.new(client, "id" => id)
end
distribution(id) click to toggle source
# File lib/m2x/mqtt.rb, line 47
def distribution(id)
  M2X::MQTT::Distribution.new(client, "id" => id)
end
status() click to toggle source

Returns the status of the M2X system.

The response to this endpoint is an object in which each of its attributes represents an M2X subsystem and its current status.

# File lib/m2x/mqtt.rb, line 27
def status
  client.subscribe
  client.get("/status")
  client.get_response
end
stream(device_id, name) click to toggle source
# File lib/m2x/mqtt.rb, line 51
def stream(device_id, name)
  M2X::MQTT::Stream.new(client, device(device_id), "name" => name)
end
time() click to toggle source
# File lib/m2x/mqtt.rb, line 33
def time
  client.subscribe
  client.get("/time")
  client.get_response["body"]
end