guh 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffee0d0fcc4933f665846b7ba8ca2d9fc59d8a46
4
- data.tar.gz: de1af3814936cc1d847a19668b72a654921a8822
3
+ metadata.gz: 0a84701b06415b921eec4e557982c283cb669b62
4
+ data.tar.gz: 9202d75c1e2bfc4077c02e65ae0e70d4dffaf80f
5
5
  SHA512:
6
- metadata.gz: c3ec2af5b1e2588efd6e0f0047e31584a73c20cc18965db6dd1c4d73ef8df206c0a6d55417761236e2b96a7ef6549bde9497982c642202ac4b9fb567e40fa365
7
- data.tar.gz: 637db3633414119a37594ea60855d967fed28ab96d2d080aa55cccdef1ea97b17322182e770efe06f1df28b81e75760052269d65c995e087f41b0ab4a5a298e3
6
+ metadata.gz: 661c602bcc06befc794f25e1791a45f2e034c4d63fc42dd34328911ca5e38aaf1ca2881b3b2589f0ef6ca5cc588b4a9eecf6cf0d4770f0666924b3e67086fdcd
7
+ data.tar.gz: a3011a6fa8bc0291895c2077e65e91cff485cf2a69718c5e6d437540c3131023e6778022a0450e7af7067c7ffb6cfbb68bbcffc1c3ff3ad0c572c8705fd48c30
data/lib/guh.rb CHANGED
@@ -4,7 +4,6 @@ require 'json'
4
4
  require 'socket'
5
5
 
6
6
  require "guh/base"
7
- require "guh/action_type"
8
7
  require "guh/action"
9
8
  require "guh/device"
10
9
  require "guh/device_class"
@@ -13,8 +12,14 @@ require "guh/event"
13
12
  require "guh/plugin"
14
13
  require "guh/rule_type"
15
14
  require "guh/rule"
15
+ require "guh/state_type"
16
+ require "guh/state"
17
+
16
18
  require "guh/vendor"
17
19
 
20
+ require "guh/type/state_operator"
21
+ require "guh/type/value_operator"
22
+
18
23
  require "guh/em/connection"
19
24
  require "guh/em/notifications"
20
25
 
data/lib/guh/action.rb CHANGED
@@ -4,6 +4,42 @@ module Guh
4
4
  #
5
5
  class Action < Base
6
6
 
7
+ ##
8
+ #
9
+ # Example:
10
+ # Guh::ActionType.find("{cfbc6504-d86f-4856-8dfa-97b6fbb385e4}")
11
+ #
12
+ def self.find(action_type_id)
13
+ response = get({
14
+ id: generate_request_id,
15
+ method: "Actions.GetActionType",
16
+ params: {
17
+ actionTypeId: action_type_id
18
+ }
19
+ })
20
+
21
+ response['actionType']
22
+ end
23
+
24
+ ##
25
+ # Retrieves all known ActionTypes for a specific Device identified by its +device_class_id+.
26
+ #
27
+ # Example:
28
+ #
29
+ # Guh::ActionType.all("{308ae6e6-38b3-4b3a-a513-3199da2764f8}")
30
+ #
31
+ def self.all(device_class_id)
32
+ response = get({
33
+ id: generate_request_id,
34
+ method: "Devices.GetActionTypes",
35
+ params: {
36
+ deviceClassId: device_class_id
37
+ }
38
+ })
39
+
40
+ response['actionTypes']
41
+ end
42
+
7
43
  ##
8
44
  #
9
45
  # Executes a specific Action on a specific Device.
data/lib/guh/base.rb CHANGED
@@ -37,6 +37,13 @@ module Guh
37
37
  })
38
38
  end
39
39
 
40
+ def self.version
41
+ get({
42
+ id: generate_request_id,
43
+ method: "JSONRPC.Version",
44
+ })
45
+ end
46
+
40
47
  ##
41
48
  #
42
49
  # <b>Don't use this unless you know what you are doing!</b>
data/lib/guh/state.rb ADDED
@@ -0,0 +1,35 @@
1
+ module Guh
2
+ ##
3
+ # This class wraps everything related to the state of a device.
4
+ #
5
+ class State < Base
6
+
7
+ def self.find(device_id, state_id)
8
+ get({
9
+ id: generate_request_id,
10
+ method: 'Devices.GetStateValue',
11
+ params: {
12
+ deviceId: device_id,
13
+ stateTypeId: state_id
14
+ }
15
+ })
16
+ end
17
+
18
+ def self.all(device_id)
19
+ device = Guh::Device.find(device_id)
20
+ state_types = Guh::StateType.all(device['deviceClassId'])
21
+
22
+ values = []
23
+ state_types.each do |state|
24
+ value = state
25
+ value['value'] = Guh::State.find(device_id, state['id'])
26
+
27
+ values << value
28
+ end
29
+
30
+ return values
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,18 @@
1
+ module Guh
2
+ ##
3
+ # This class wraps everything related to the state types of a device class.
4
+ #
5
+ class StateType < Base
6
+
7
+ def self.all(device_class_id)
8
+ response = get({
9
+ id: generate_request_id,
10
+ method: 'Devices.GetStateTypes',
11
+ params: { deviceClassId: device_class_id }
12
+ })
13
+ return response['stateTypes']
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,15 @@
1
+ module Guh
2
+ module Type
3
+ class StateOperator
4
+
5
+ ##
6
+ #
7
+ # Returns a list of state operators that may be used for the creation of state based rules
8
+ #
9
+ def self.all
10
+ introspect = Guh::Base.introspect
11
+ introspect['types']['StateOperator']
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Guh
2
+ module Type
3
+ class ValueOperator
4
+
5
+ ##
6
+ #
7
+ # Returns a list of value operators that may be used for the creation of rules
8
+ #
9
+ def self.all
10
+ introspect = Guh::Base.introspect
11
+ introspect['types']['ValueOperator']
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/guh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Guh
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Edthofer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-02 00:00:00.000000000 Z
12
+ date: 2014-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -113,7 +113,6 @@ files:
113
113
  - guh.gemspec
114
114
  - lib/guh.rb
115
115
  - lib/guh/action.rb
116
- - lib/guh/action_type.rb
117
116
  - lib/guh/base.rb
118
117
  - lib/guh/device.rb
119
118
  - lib/guh/device_class.rb
@@ -124,6 +123,10 @@ files:
124
123
  - lib/guh/plugin.rb
125
124
  - lib/guh/rule.rb
126
125
  - lib/guh/rule_type.rb
126
+ - lib/guh/state.rb
127
+ - lib/guh/state_type.rb
128
+ - lib/guh/type/state_operator.rb
129
+ - lib/guh/type/value_operator.rb
127
130
  - lib/guh/vendor.rb
128
131
  - lib/guh/version.rb
129
132
  - spec/helper.rb
@@ -1,27 +0,0 @@
1
- module Guh
2
- ##
3
- # This class wraps everything related to ActionTypes.
4
- #
5
- class ActionType < Base
6
-
7
- ##
8
- # Retrieves all known ActionTypes for a specific Device identified by its +device_id+.
9
- #
10
- # Example:
11
- #
12
- # Guh::ActionType.all("{308ae6e6-38b3-4b3a-a513-3199da2764f8}")
13
- #
14
- def self.all(device_class_id)
15
- response = get({
16
- id: generate_request_id,
17
- method: "Devices.GetActionTypes",
18
- params: {
19
- deviceClassId: device_class_id
20
- }
21
- })
22
-
23
- response['actionTypes']
24
- end
25
-
26
- end
27
- end