Class: Cocoro::Device
- Inherits:
-
Struct
- Object
- Struct
- Cocoro::Device
- Defined in:
- lib/cocoro/device.rb
Instance Attribute Summary collapse
-
#box_id ⇒ Object
Returns the value of attribute box_id.
-
#client ⇒ Object
Returns the value of attribute client.
-
#device_id ⇒ Object
Returns the value of attribute device_id.
-
#echonet_node ⇒ Object
Returns the value of attribute echonet_node.
-
#echonet_object ⇒ Object
Returns the value of attribute echonet_object.
-
#maker ⇒ Object
Returns the value of attribute maker.
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_status! ⇒ Object
- #set_air_volume!(value) ⇒ Object
- #set_humidifier_on!(value) ⇒ Object
-
#set_power_on!(value) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #status ⇒ Object
Instance Attribute Details
#box_id ⇒ Object
Returns the value of attribute box_id
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def box_id @box_id end |
#client ⇒ Object
Returns the value of attribute client
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def client @client end |
#device_id ⇒ Object
Returns the value of attribute device_id
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def device_id @device_id end |
#echonet_node ⇒ Object
Returns the value of attribute echonet_node
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def echonet_node @echonet_node end |
#echonet_object ⇒ Object
Returns the value of attribute echonet_object
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def echonet_object @echonet_object end |
#maker ⇒ Object
Returns the value of attribute maker
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def maker @maker end |
#model ⇒ Object
Returns the value of attribute model
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def model @model end |
#name ⇒ Object
Returns the value of attribute name
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def name @name end |
#type ⇒ Object
Returns the value of attribute type
7 8 9 |
# File 'lib/cocoro/device.rb', line 7 def type @type end |
Class Method Details
.parse_box_info(box_info, client) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cocoro/device.rb', line 19 def self.parse_box_info(box_info, client) box_info.flat_map do |box| box["echonetData"].map do |data| new( client: client, box_id: box["boxId"], device_id: data["deviceId"], echonet_node: data["echonetNode"], echonet_object: data["echonetObject"], name: data["labelData"]["name"], type: data["labelData"]["deviceType"], maker: data["maker"], model: data["model"] ) end end end |
Instance Method Details
#fetch_status! ⇒ Object
41 42 43 44 45 |
# File 'lib/cocoro/device.rb', line 41 def fetch_status! client.control_device(device: self) @status = client.device_status(device: self) end |
#set_air_volume!(value) ⇒ Object
56 57 58 |
# File 'lib/cocoro/device.rb', line 56 def set_air_volume!(value) send_payload!(:air_volume, value) end |
#set_humidifier_on!(value) ⇒ Object
52 53 54 |
# File 'lib/cocoro/device.rb', line 52 def set_humidifier_on!(value) send_payload!(:humidifier_on, value) end |
#set_power_on!(value) ⇒ Object
rubocop:disable Naming/AccessorMethodName
48 49 50 |
# File 'lib/cocoro/device.rb', line 48 def set_power_on!(value) send_payload!(:power_on, value) end |
#status ⇒ Object
37 38 39 |
# File 'lib/cocoro/device.rb', line 37 def status @status || fetch_status! end |