sensibo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/sensibo.rb +77 -0
- metadata +57 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 55beafd9c7e31f798b684ddc2d4a4dc925cf935e
|
|
4
|
+
data.tar.gz: 87ac8216b0677c8925e44d2aa79581b4381cce4c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8c656318ecb6c3e4b4f2a4839987f657c0a6a5e1e4bb2f8eaedd6414f15919194988204e91cc6e096afcc5524cfd5e88a0f8dbfda52e9b5f7a4c2c950f7bd0e1
|
|
7
|
+
data.tar.gz: e1f33e9522b7658709e3cdd246718bf660e1cadcc688af5e1630ea41e78cd754957327b4f10e0c8ec8ea3129ecf5607a5fb8ce366b72c928e26da3fbbea72145
|
data/lib/sensibo.rb
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'httparty'
|
|
4
|
+
|
|
5
|
+
module Sensibo
|
|
6
|
+
class System
|
|
7
|
+
|
|
8
|
+
attr_reader :pods
|
|
9
|
+
|
|
10
|
+
def initialize(key)
|
|
11
|
+
|
|
12
|
+
@apiKey = key
|
|
13
|
+
@urlBase = 'https://home.sensibo.com/api/v2/'
|
|
14
|
+
@urlEnd = '?apiKey=' + @apiKey
|
|
15
|
+
|
|
16
|
+
@pods = Array.new
|
|
17
|
+
|
|
18
|
+
podsURL = @urlBase + 'users/me/pods' + @urlEnd
|
|
19
|
+
podResults = JSON.parse(open(podsURL).string)['result']
|
|
20
|
+
|
|
21
|
+
podResults.each do |pod|
|
|
22
|
+
pods.push(Pod.new(@apiKey, pod['id']))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Pod
|
|
28
|
+
|
|
29
|
+
attr_reader :id, :measurementAge, :measurementTime, :currentTemp, :currentHumidity, :on, :mode, :fanLevel, :targetTemp
|
|
30
|
+
|
|
31
|
+
def initialize(key, id)
|
|
32
|
+
@apiKey = key
|
|
33
|
+
@id = id
|
|
34
|
+
@urlBase = 'https://home.sensibo.com/api/v2/'
|
|
35
|
+
@urlEnd = '?apiKey=' + @apiKey
|
|
36
|
+
|
|
37
|
+
getState
|
|
38
|
+
getMeasurements
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def getState
|
|
42
|
+
stateIDsURL = @urlBase + 'pods/' + @id + '/acStates' + @urlEnd
|
|
43
|
+
stateID = JSON.parse(open(stateIDsURL).string)['result'][0]['id']
|
|
44
|
+
|
|
45
|
+
stateURL = @urlBase + 'pods/' + @id + '/acStates/' + stateID + @urlEnd
|
|
46
|
+
stateData = JSON.parse(open(stateURL).string)['result']['acState']
|
|
47
|
+
|
|
48
|
+
@on = stateData['on']
|
|
49
|
+
@mode = stateData['mode']
|
|
50
|
+
@fanLevel = stateData['fanLevel']
|
|
51
|
+
@targetTemp = stateData['targetTemperature']
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def getMeasurements
|
|
55
|
+
podDataURL = @urlBase + 'pods/' + @id + '/measurements' + @urlEnd
|
|
56
|
+
podData = JSON.parse(open(podDataURL).string)['result'][0]
|
|
57
|
+
|
|
58
|
+
@measurementAge = podData['time']['secondsAgo']
|
|
59
|
+
@measurementTime = podData['time']['time']
|
|
60
|
+
@currentTemp = podData['temperature']
|
|
61
|
+
@currentHumidity = podData['humidity']
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def setState(on, mode, fanLevel, targetTemp)
|
|
65
|
+
podUpdateURL = @urlBase + 'pods/' + @id + '/acStates' + @urlEnd
|
|
66
|
+
|
|
67
|
+
response = HTTParty.post(
|
|
68
|
+
podUpdateURL,
|
|
69
|
+
{
|
|
70
|
+
:body => { 'acState' => {"on" => on, "mode" => mode, "fanLevel" => fanLevel, "targetTemperature" => targetTemp } }.to_json,
|
|
71
|
+
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
getState
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sensibo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Michael Davie
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-11-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: Ruby implementation of Sensibo API
|
|
28
|
+
email: michael.davie@gmail.com
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- lib/sensibo.rb
|
|
34
|
+
homepage: https://home.sensibo.com/me/api
|
|
35
|
+
licenses: []
|
|
36
|
+
metadata: {}
|
|
37
|
+
post_install_message:
|
|
38
|
+
rdoc_options: []
|
|
39
|
+
require_paths:
|
|
40
|
+
- lib
|
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - '>='
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
requirements: []
|
|
52
|
+
rubyforge_project:
|
|
53
|
+
rubygems_version: 2.0.14
|
|
54
|
+
signing_key:
|
|
55
|
+
specification_version: 4
|
|
56
|
+
summary: Ruby implementation of Sensibo API
|
|
57
|
+
test_files: []
|