guh 0.0.11 → 0.0.12
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 +4 -4
- data/lib/guh.rb +6 -1
- data/lib/guh/action.rb +36 -0
- data/lib/guh/base.rb +7 -0
- data/lib/guh/state.rb +35 -0
- data/lib/guh/state_type.rb +18 -0
- data/lib/guh/type/state_operator.rb +15 -0
- data/lib/guh/type/value_operator.rb +15 -0
- data/lib/guh/version.rb +1 -1
- metadata +6 -3
- data/lib/guh/action_type.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a84701b06415b921eec4e557982c283cb669b62
|
4
|
+
data.tar.gz: 9202d75c1e2bfc4077c02e65ae0e70d4dffaf80f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
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.
|
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-
|
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
|
data/lib/guh/action_type.rb
DELETED
@@ -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
|