aca-device-modules 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ module Transmitsms; end
2
+
3
+ # default URL: https://api.transmitsms.com
4
+ # Settings: api_key and api_secret
5
+
6
+ class Transmitsms::Api
7
+ include ::Orchestrator::Constants
8
+
9
+
10
+ DECODE_OPTIONS = {
11
+ symbolize_names: true
12
+ }.freeze
13
+
14
+
15
+ def on_load
16
+ defaults({
17
+ keepalive: false,
18
+ inactivity_timeout: 1.5, # seconds before closing the connection if no response
19
+ connect_timeout: 2 # max seconds for the initial connection to the device
20
+ })
21
+
22
+ on_update
23
+ end
24
+
25
+ def on_update
26
+ @api_key = setting(:api_key)
27
+ @api_secret = setting(:api_secret)
28
+ end
29
+
30
+ def send_sms(message, params = {})
31
+ params[:message] = message
32
+ options = {
33
+ headers: {
34
+ 'authorization' => [@api_key, @api_secret]
35
+ },
36
+ body: params
37
+ }
38
+
39
+ logger.debug "Requesting SMS: #{params}"
40
+
41
+ post('/send-sms.json', options) do |data, resolve|
42
+ resp = ::JSON.parse(data[:body], DECODE_OPTIONS)
43
+ if resp[:error][:code] != 'SUCCESS'
44
+ self[:last_error] = resp[:error]
45
+ logger.error "#{resp[:error][:code]}: #{resp[:error][:description]}"
46
+ :abort
47
+ else
48
+ :success
49
+ end
50
+ end
51
+ end
52
+ end
@@ -76,13 +76,13 @@ class Vaddio::Camera::ClearViewPtzTelnet
76
76
 
77
77
 
78
78
  # direction: left, right, stop
79
- def pan(direction, speed = 16)
79
+ def pan(direction, speed = 18)
80
80
  params = direction.to_sym == :stop ? direction : "#{direction} #{speed}"
81
81
  send "camera pan #{params}\r", name: :pan
82
82
  end
83
83
 
84
84
  # direction: up, down, stop
85
- def tilt(direction, speed = 16)
85
+ def tilt(direction, speed = 18)
86
86
  params = direction.to_sym == :stop ? direction : "#{direction} #{speed}"
87
87
  send "camera tilt #{params}\r", name: :tilt
88
88
  end
@@ -97,7 +97,7 @@ class Vaddio::Camera::ClearViewPtzTelnet
97
97
  end
98
98
 
99
99
  # direction: in, out, stop
100
- def zoom(direction, speed = 3)
100
+ def zoom(direction, speed = 4)
101
101
  params = direction.to_sym == :stop ? direction : "#{direction} #{speed}"
102
102
  send "camera zoom #{params}\r", name: :zoom
103
103
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aca-device-modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen von Takach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -55,17 +55,24 @@ files:
55
55
  - modules/axis/camera/vapix.rb
56
56
  - modules/biamp/nexia.rb
57
57
  - modules/bss/blu100.rb
58
+ - modules/chiyu/cyt.rb
58
59
  - modules/clipsal/c_bus.rb
59
60
  - modules/epson/projector/esc_vp21.rb
60
61
  - modules/extron/mixer/dmp44.rb
61
62
  - modules/extron/mixer/dmp64.rb
62
63
  - modules/extron/switcher/dxp.rb
63
64
  - modules/global_cache/gc100.rb
65
+ - modules/kramer/switcher/protocol3000.rb
64
66
  - modules/kramer/switcher/vs_hdmi.rb
67
+ - modules/nec/display/all.rb
68
+ - modules/nec/projector/np_series.rb
65
69
  - modules/panasonic/camera/he50.rb
66
- - modules/panasonic/projector/pj_link.rb
70
+ - modules/panasonic/projector/tcp.rb
67
71
  - modules/samsung/displays/md_series.rb
68
- - modules/sony/display/gdx_and_fwd.rb
72
+ - modules/screen_technics/connect.rb
73
+ - modules/sony/display/id_talk.rb
74
+ - modules/sony/projector/pj_talk.rb
75
+ - modules/transmitsms/api.rb
69
76
  - modules/vaddio/camera/clear_view_ptz_telnet.rb
70
77
  homepage: http://cotag.me/
71
78
  licenses:
@@ -1,266 +0,0 @@
1
- module Panasonic; end
2
- module Panasonic::Projector; end
3
-
4
-
5
- require 'digest/md5'
6
-
7
- #
8
- # Port: 1024
9
- #
10
- class Panasonic::Projector::PjLink
11
- include ::Orchestrator::Constants
12
- include ::Orchestrator::Transcoder
13
-
14
- def on_load
15
- # PJLink is slow
16
- defaults({
17
- timeout: 4000,
18
- delay_on_receive: 400
19
- })
20
-
21
- config({
22
- tokenize: true,
23
- delimiter: "\r",
24
- wait_ready: 'NTCONTROL'
25
- })
26
-
27
- @check_scheduled = false
28
- self[:power] = false
29
- self[:stable_state] = true # Stable by default (allows manual on and off)
30
- self[:input_stable] = true
31
-
32
- # Meta data for inquiring interfaces
33
- self[:type] = :projector
34
- end
35
-
36
- def on_update
37
- end
38
-
39
- def connected
40
- @polling_timer = schedule.every('60s', method(:do_poll))
41
- end
42
-
43
- def disconnected
44
- self[:power] = false
45
-
46
- @polling_timer.cancel unless @polling_timer.nil?
47
- @polling_timer = nil
48
- end
49
-
50
-
51
-
52
- #
53
- # Power commands
54
- #
55
- def power(state, opt = nil)
56
- self[:stable_state] = false
57
- if is_affirmative?(state)
58
- self[:power_target] = On
59
- do_send(:POWR, 1, {:retries => 10, :name => :power})
60
- logger.debug "-- panasonic Proj, requested to power on"
61
- do_send('POWR', '?', :name => :power_state)
62
- else
63
- self[:power_target] = Off
64
- do_send(:POWR, 0, {:retries => 10, :name => :power})
65
- logger.debug "-- panasonic Proj, requested to power off"
66
- do_send('POWR', '?', :name => :power_state)
67
- end
68
- end
69
-
70
- def power?(options = {}, &block)
71
- options[:emit] = block if block_given?
72
- options[:name] = :power_state
73
- do_send(:POWR, options)
74
- end
75
-
76
-
77
-
78
- #
79
- # Input selection
80
- #
81
- INPUTS = {
82
- :hdmi => 31,
83
- :hdmi2 => 32,
84
- :digital => 33,
85
- :miracast => 52
86
- }
87
- INPUTS.merge!(INPUTS.invert)
88
-
89
-
90
- def switch_to(input)
91
- input = input.to_sym
92
- return unless INPUTS.has_key? input
93
-
94
- do_send(:INPT, INPUTS[input], {:retries => 10, :name => :inpt_source})
95
- do_send('INPT', '?', {:name => :inpt_query})
96
- logger.debug "-- panasonic LCD, requested to switch to: #{input}"
97
-
98
- self[:input] = input # for a responsive UI
99
- self[:input_stable] = false
100
- end
101
-
102
-
103
- #
104
- # Mute Audio and Video
105
- #
106
- def mute
107
- logger.debug "-- panasonic Proj, requested to mute"
108
- do_send(:AVMT, 31, {:name => :video_mute}) # Audio + Video
109
- end
110
-
111
- def unmute
112
- logger.debug "-- panasonic Proj, requested to unmute"
113
- do_send(:AVMT, 30, {:name => :video_mute})
114
- end
115
-
116
-
117
- ERRORS = {
118
- :ERR1 => '1: Undefined control command'.freeze,
119
- :ERR2 => '2: Out of parameter range'.freeze,
120
- :ERR3 => '3: Busy state or no-acceptable period'.freeze,
121
- :ERR4 => '4: Timeout or no-acceptable period'.freeze,
122
- :ERR5 => '5: Wrong data length'.freeze,
123
- :ERRA => 'A: Password mismatch'.freeze
124
- }
125
-
126
-
127
- def received(data, resolve, command) # Data is default received as a string
128
- logger.debug "panasonic Proj sent: #{data}"
129
-
130
- # This is the ready response
131
- if data[0] == ' '
132
- @mode = data[1]
133
- if @mode == '1'
134
- @pass = "#{setting(:username) || 'admin1'}:#{setting(:password) || 'panasonic'}:#{data.strip.split(/\s+/)[-1]}"
135
- @pass = Digest::MD5.hexdigest(@hash)
136
- end
137
-
138
- :success
139
-
140
- # Error Response
141
- elsif data[0] == 'E'
142
- error = data.to_sym
143
- #self[:last_error] = ERRORS[error] (for error status query)
144
-
145
- # Check for busy or timeout
146
- if error == :ERR3 || error == :ERR4
147
- logger.warn "Panasonic Proj busy: #{self[:last_error]}"
148
- :retry
149
- else
150
- logger.error "Panasonic Proj error: #{self[:last_error]}"
151
- :abort
152
- end
153
-
154
- # Success Response
155
- else
156
- data = data[2..-1].split('=')
157
-
158
- if data[1] = 'OK'
159
- return :success
160
- else
161
- type = data[0][2..-1].to_sym
162
- response = data[1].to_i
163
- resolve.call(:success)
164
-
165
- case type
166
- when :POWR
167
- self[:power] = response >= 1 && response != 2
168
- self[:warming] = response == 3
169
- self[:cooling] = response == 2
170
- if response >= 2 && !@check_scheduled && !self[:stable_state]
171
- @check_scheduled = true
172
- schedule.in('20s') do
173
- @check_scheduled = false
174
- logger.debug "-- checking panasonic state"
175
- power?({:priority => 0}) do
176
- state = self[:power]
177
- if state != self[:power_target]
178
- if self[:power_target] || !self[:cooling]
179
- power(self[:power_target])
180
- end
181
- elsif self[:power_target] && self[:cooling]
182
- power(self[:power_target])
183
- else
184
- self[:stable_state] = true
185
- switch_to(self[:input]) if self[:power_target] == On && !self[:input].nil?
186
- end
187
- end
188
- end
189
- end
190
- when :INPT
191
- if INPUTS[response].present?
192
- self[:input] = INPUTS[response] if self[:input].nil?
193
- self[:actual_input] = INPUTS[response]
194
- if self[:input] == self[:actual_input]
195
- self[:input_stable] = true
196
- elsif self[:input_stable] == false
197
- schedule.in('5s') do
198
- logger.debug "-- forcing panasonic input"
199
- switch_to(self[:input]) if self[:input_stable] == false
200
- end
201
- end
202
- end
203
- when :AVMT
204
- self[:mute] = response == 31 # 10 == video mute off, 11 == video mute, 20 == audio mute off, 21 == audio mute, 30 == AV mute off
205
- when :LAMP
206
- self[:lamp] = data[1][0..-2].to_i
207
- end
208
- end
209
- end
210
- end
211
-
212
-
213
-
214
- protected
215
-
216
-
217
- def do_poll(*args)
218
- power?({:priority => 0}) do
219
- if self[:power]
220
- if self[:stable_state] == false && self[:power_target] == Off
221
- power(Off)
222
- else
223
- self[:stable_state] = true
224
- do_send(:INPT, {
225
- :name => :inpt_query,
226
- :priority => 0
227
- })
228
- do_send(:AVMT, {
229
- :name => :mute_query,
230
- :priority => 0
231
- })
232
- do_send(:LAMP, {
233
- :name => :lamp_query,
234
- :priority => 0
235
- })
236
- end
237
- elsif self[:stable_state] == false
238
- if self[:power_target] == On
239
- power(On)
240
- else
241
- self[:stable_state] = true
242
- end
243
- end
244
- end
245
- end
246
-
247
- def do_send(command, param = nil, options = {})
248
- if param.is_a? Hash
249
- options = param
250
- param = nil
251
- end
252
-
253
- if param.nil?
254
- pj = "#{command} ?"
255
- else
256
- pj = "#{command} #{param}"
257
- end
258
-
259
- if @mode == '0'
260
- send("00#{pj}\r", options)
261
- else
262
- send("#{@pass}00#{pj}\r", options)
263
- end
264
- end
265
- end
266
-