Class: MideaAirCondition::Device
- Inherits:
-
Object
- Object
- MideaAirCondition::Device
- Defined in:
- lib/device.rb
Overview
Device representation (now only for status parsing)
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #eco ⇒ Object
- #fan_speed ⇒ Object
- #indoor_temperature ⇒ Object
-
#initialize(data) ⇒ Device
constructor
A new instance of Device.
- #mode ⇒ Object
- #mode_human ⇒ Object
- #off_timer ⇒ Object
- #off_timer_human ⇒ Object
- #on_timer ⇒ Object
- #on_timer_human ⇒ Object
- #outdoor_temperature ⇒ Object
- #power_status ⇒ Object
- #temperature ⇒ Object
Constructor Details
#initialize(data) ⇒ Device
Returns a new instance of Device.
8 9 10 11 |
# File 'lib/device.rb', line 8 def initialize(data) @data = data @pointer = 0x33 end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/device.rb', line 6 def data @data end |
Instance Method Details
#eco ⇒ Object
48 49 50 |
# File 'lib/device.rb', line 48 def eco !((@data[@pointer + 8] & 0x10) >> 4).zero? end |
#fan_speed ⇒ Object
36 37 38 |
# File 'lib/device.rb', line 36 def fan_speed @data[@pointer + 2] & 0x7f end |
#indoor_temperature ⇒ Object
40 41 42 |
# File 'lib/device.rb', line 40 def indoor_temperature (@data[@pointer + 10] - 50) / 2 end |
#mode ⇒ Object
21 22 23 |
# File 'lib/device.rb', line 21 def mode (@data[@pointer + 1] & 0xe0) >> 5 end |
#mode_human ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/device.rb', line 25 def mode_human mode_value = 'unknown' mode_value = 'auto' if mode == 1 mode_value = 'cool' if mode == 2 mode_value = 'dry' if mode == 3 mode_value = 'heat' if mode == 4 mode_value = 'fan' if mode == 5 mode_value end |
#off_timer ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/device.rb', line 61 def off_timer value = @data[@pointer + 4] { status: !((value & 0x80) >> 7).zero?, hour: ((value & 0x7c) >> 2), minutes: ((value & 0x3) | ((value & 0xf0))) } end |
#off_timer_human ⇒ Object
74 75 76 |
# File 'lib/device.rb', line 74 def off_timer_human "#{off_timer[:hours]}:#{off_timer[:mins]}" end |
#on_timer ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/device.rb', line 52 def on_timer value = @data[@pointer + 3] { status: !((value & 0x80) >> 7).zero?, hour: ((value & 0x7c) >> 2), minutes: ((value & 0x3) | ((value & 0xf0))) } end |
#on_timer_human ⇒ Object
70 71 72 |
# File 'lib/device.rb', line 70 def on_timer_human "#{on_timer[:hours]}:#{on_timer[:mins]}" end |
#outdoor_temperature ⇒ Object
44 45 46 |
# File 'lib/device.rb', line 44 def outdoor_temperature (@data[@pointer + 11] - 50) / 2 end |
#power_status ⇒ Object
13 14 15 |
# File 'lib/device.rb', line 13 def power_status !(@data[@pointer] & 0x01).zero? end |
#temperature ⇒ Object
17 18 19 |
# File 'lib/device.rb', line 17 def temperature (@data[@pointer + 1] & 0xf) + 16 end |