Class: M2X::MQTT
- Inherits:
-
Object
- Object
- M2X::MQTT
- Defined in:
- lib/m2x/mqtt.rb,
lib/m2x/mqtt/version.rb
Defined Under Namespace
Classes: Client, Device, Distribution, Resource, Stream
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #create_device(attributes) ⇒ Object
- #device(id) ⇒ Object
- #distribution(id) ⇒ Object
-
#initialize(api_key, options = {}) ⇒ MQTT
constructor
A new instance of MQTT.
-
#status ⇒ Object
Returns the status of the M2X system.
- #stream(device_id, name) ⇒ Object
Constructor Details
#initialize(api_key, options = {}) ⇒ MQTT
Returns a new instance of MQTT.
12 13 14 15 |
# File 'lib/m2x/mqtt.rb', line 12 def initialize(api_key, ={}) @api_key = api_key @options = end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/m2x/mqtt.rb', line 10 def client @client end |
Instance Method Details
#create_device(attributes) ⇒ Object
35 36 37 |
# File 'lib/m2x/mqtt.rb', line 35 def create_device(attributes) M2X::MQTT::Device.create!(client, attributes) end |
#device(id) ⇒ Object
31 32 33 |
# File 'lib/m2x/mqtt.rb', line 31 def device(id) M2X::MQTT::Device.new(client, "id" => id) end |
#distribution(id) ⇒ Object
39 40 41 |
# File 'lib/m2x/mqtt.rb', line 39 def distribution(id) M2X::MQTT::Distribution.new(client, "id" => id) end |
#status ⇒ Object
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.
25 26 27 28 29 |
# File 'lib/m2x/mqtt.rb', line 25 def status client.subscribe client.get("/status") client.get_response end |