Module: SleepIQ::Foundation

Included in:
Client
Defined in:
lib/sleepiq/foundation.rb

Instance Method Summary collapse

Instance Method Details

#foundation_statusObject



43
44
45
46
47
48
# File 'lib/sleepiq/foundation.rb', line 43

def foundation_status
  result = @conn.get { |req| req.url "rest/bed/#{bedid}/foundation/status" }
  raise "status code was #{result.status}, #{result.body}" unless result.status == 200

  result.body
end

#light(light = 1) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/sleepiq/foundation.rb', line 3

def light(light = 1)
  result = @conn.get do |req|
    req.url "rest/bed/#{bedid}/foundation/outlet"
    req.params = { outletId: light, _k: @key }
  end
  raise "status code was #{result.status}, #{result.body}" unless result.status == 200

  result.body
end

#preset(preset, side, slow_speed = 0, bedid = @bedid) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/sleepiq/foundation.rb', line 23

def preset(preset, side, slow_speed = 0, bedid = @bedid)
  result @conn.put do |req|
    req.url "rest/bed/#{bedid}/foundation/preset"
    req.body = "{\"preset\":#{preset}, \"speed\":#{slow_speed}, \"side\":#{side}}"
  end
  raise "status code was #{result.status}, #{result.body}" unless result.status == 200

  result.body
end

#set_light(light, setting = 0, bedid = @bedid) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/sleepiq/foundation.rb', line 13

def set_light(light, setting = 0, bedid = @bedid)
  result = @conn.put do |req|
    req.url "rest/bed/#{bedid}/foundation/outlet"
    req.body = "\"outletId\":\"#{light}\",\"setting\":#{setting}}"
  end
  raise "status code was #{result.status}, #{result.body}" unless result.status == 200

  result.body
end

#stop_motion(side, bedid = @bedid) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/sleepiq/foundation.rb', line 33

def stop_motion(side, bedid = @bedid)
  result @conn.put do |req|
    req.url "rest/bed/#{bedid}/foundation/motion"
    req.body = "{\"footMotion\":1, \"headMotion\":1, \"massageMotion\":1, \"side\":#{side}}"
  end
  raise "status code was #{result.status}, #{result.body}" unless result.status == 200

  result.body
end

#systemObject



50
51
52
53
54
55
# File 'lib/sleepiq/foundation.rb', line 50

def system
  result = @conn.get { |req| req.url "rest/bed/#{bedid}/foundation/system" }
  raise "status code was #{result.status}, #{result.body}" unless result.status == 200

  result.body
end