sharp_aquos_remote_control 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 836db0882883c9aeb91834cb519db230b1eb83d6
4
+ data.tar.gz: 6bf93f88062a75a3f4e62fe638d569db8c9b1934
5
+ SHA512:
6
+ metadata.gz: f2a37b530195b381fe9a5bdb74d1a83f6811f567448123d5f0ea94db167d06bf0829fce4d3e3d0a10b29e404bac89209d5b6b48ea0f924a078c61e21bbf02240
7
+ data.tar.gz: 9a0864ee3cac87dca2de48a1066942bdfbe0acc95696895da7ff85afa1cdad4a3dac55e1492337c6d65a614a1b9b73a68b7bdf57eb57fb7e96b7b264795b2263
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) [2015] [Gale Shafer]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Sharp Aquos Remote Control
2
+
3
+ This gem enables remote control functionality for Sharp Aquos televisions.
4
+
5
+ ## Sharp Aquos Setup
6
+
7
+ 1. Ensure the television is turned on.
8
+ 2. Hit the 'Menu' button on your remote.
9
+ 3. Navigate to 'Initial Setup'
10
+ 4. Navigate to 'Internet Setup'
11
+ 5. Navigate to 'Aquos Remote Control'
12
+ 6. Enable the Remote Control functionality.
13
+ 7. (optional) Go to Detailed Settings and set a username/password.
14
+
15
+ ## How to use this gem
16
+
17
+ ```rb
18
+ tv = SharpAquosRemoteControl.new("192.168.1.1")
19
+
20
+ tv.on
21
+ # => "OK"
22
+
23
+ tv.volume 15
24
+ # => "OK"
25
+
26
+ tv.volume?
27
+ # => "15"
28
+
29
+ tv.mute
30
+ # => "OK"
31
+
32
+ tv.muted?
33
+ # => true
34
+
35
+ tv.unmute
36
+ # => "OK"
37
+
38
+ tv.off
39
+ # => "OK"
40
+ ```
41
+
42
+ ## How this gem works
43
+
44
+ This gem uses a TCP socket to send messages to your TV over wi-fi. The
45
+ messages that are sent can be found in the Sharp user manual. The manual
46
+ used specifically for this gem can be found in the repo:
47
+ `sharp_manual.pdf`.
48
+
49
+ The MIT License (MIT)
@@ -0,0 +1,96 @@
1
+ require 'socket'
2
+
3
+ class SharpAquosRemoteControl
4
+ attr_reader :hostname
5
+ attr_reader :port
6
+ attr_reader :username
7
+ attr_reader :password
8
+
9
+ def initialize(hostname = "192.168.2.188", port = 10002, username = nil, password = nil)
10
+ @hostname = hostname
11
+ @port = port
12
+ @username = username
13
+ @password = password
14
+ end
15
+
16
+ def analog_channel(value)
17
+ return "Analog Channels are limited to 2 through 69" if value < 2 || value > 69
18
+ new_channel = value.to_s.rjust(2, "0")
19
+
20
+ request "DCCH" + new_channel + " \x0D"
21
+ end
22
+
23
+ def digital_channel(value)
24
+ first = (value.to_s.split(".")[0]).to_i
25
+ second = (value.to_s.split(".")[1] || 0).to_i
26
+ return "Analog Channels are limited to 1 through 99.99" if first < 1 || first > 99 || second < 0 || second > 99
27
+ new_channel = first.to_s.rjust(2, "0") + second.to_s.rjust(2, "0")
28
+
29
+ request "DA2P" + new_channel + "\x0D"
30
+ end
31
+
32
+ def channel_down
33
+ request "CHUP0 \x0D"
34
+ end
35
+
36
+ def channel_up
37
+ request "CHUP0 \x0D"
38
+ end
39
+
40
+ def input(value)
41
+ return "Inputs are limited to 1 through 9" if value < 1 || value > 9
42
+ request("IAVD" + value.to_s + " \x0D")
43
+ end
44
+
45
+ def input?
46
+ request "IAVD? \x0D"
47
+ end
48
+
49
+ def mute
50
+ request "MUTE1 \x0D"
51
+ end
52
+
53
+ def unmute
54
+ request "MUTE2 \x0D"
55
+ end
56
+
57
+ def muted?
58
+ request("MUTE? \x0D") == "1"
59
+ end
60
+
61
+ def off
62
+ request "POWR0 \x0D"
63
+ end
64
+
65
+ def off?
66
+ request("POWR? \x0D") == "0"
67
+ end
68
+
69
+ def on
70
+ request "POWR1 \x0D"
71
+ end
72
+
73
+ def on?
74
+ request("POWR? \x0D") == "1"
75
+ end
76
+
77
+ def volume(level)
78
+ return "Volume is limited to 0 through 60" if level < 0 || level > 60
79
+ new_volume = level.to_s.rjust(2, "0")
80
+
81
+ request("VOLM" + new_volume + " \x0D")
82
+ end
83
+
84
+ def volume?
85
+ request("VOLM? \x0D").to_i
86
+ end
87
+
88
+ def request(command)
89
+ response = Socket.tcp(@hostname, @port) do |socket|
90
+ socket.write command
91
+ socket.recv 1024
92
+ end
93
+
94
+ response.strip
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sharp_aquos_remote_control
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gale Shafer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem enables remote control functionality for Sharp Aquos televisions.
14
+ email:
15
+ - developers@squaremouth.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE.txt
21
+ - README.md
22
+ - lib/sharp_aquos_remote_control.rb
23
+ homepage: https://github.com/sqm/sharp_aquos_remote_control
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.2.2
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Gem for adding Sharp Aquos Remote Control functionality with Ruby.
47
+ test_files: []
48
+ has_rdoc: