inels 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/inels +70 -0
- data/lib/inels/controller.rb +5 -0
- data/lib/inels/templates/schedule.erb +4 -4
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2af4907ce4b2e187e22ce77e14ae26d6867cb26432ab6c823155c6714de7fdf9
|
4
|
+
data.tar.gz: 0fe65ab8365a368c4b20f26f7f20081098a92fd75bee7fce3d82bf63ed9884f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79f8a41c68da61c24226036e3ea9128953cfc42b79ce29ba6e311227992676b0515926d76cd8d9d71f7ca3b7af51fdff320251f748c661635b1d2950e35fb607
|
7
|
+
data.tar.gz: b84f8ef382774ad11ef52433c1e6fcab6c837fa9c023df811c0493873070999c00efccc7e51bc2c4b53d74449d338da2316365c3ea6e40f998e245072d78e5bb
|
data/bin/inels
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'inels'
|
5
|
+
|
6
|
+
IPS = %w(192.168.1.30 192.168.1.31 192.168.1.32)
|
7
|
+
|
8
|
+
class InelsCLI < Thor
|
9
|
+
|
10
|
+
desc 'list', 'List all devices'
|
11
|
+
def list
|
12
|
+
devices = Inels::Controller.new(IPS).list_devices
|
13
|
+
head = [
|
14
|
+
{ name: 'ID', id: :id },
|
15
|
+
{ name: 'Name', id: :name },
|
16
|
+
{ name: 'Type', id: :product_type },
|
17
|
+
{ name: 'Room name', id: :room_name },
|
18
|
+
{ name: 'IP address', id: :ip },
|
19
|
+
]
|
20
|
+
print_table(devices, head)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'get-device', 'Gets device\'s information'
|
24
|
+
def get_device id
|
25
|
+
device = Inels::Controller.new(IPS).get_device(id)
|
26
|
+
device.each do |k,v|
|
27
|
+
puts k + ': ' + v.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'set-temperature', 'Sets device\'s correction'
|
32
|
+
def set_correction id, correction
|
33
|
+
Inels::Controller.new(IPS).set_correction(id, Integer(correction))
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'set-power', 'Sets device\'s power'
|
37
|
+
def set_power id, power
|
38
|
+
Inels::Controller.new(IPS).set_power(id, Integer(power))
|
39
|
+
end
|
40
|
+
|
41
|
+
no_commands do
|
42
|
+
def print_table(values, head)
|
43
|
+
head.each do |title|
|
44
|
+
title[:lenght] = (values.map{|value| value[title[:id]].to_s.length} + [title[:name].length]).max
|
45
|
+
end
|
46
|
+
print_line(head)
|
47
|
+
print_head(head)
|
48
|
+
print_line(head)
|
49
|
+
values.each{|row| print_row(head, row)}
|
50
|
+
print_line(head)
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def print_line(head)
|
55
|
+
puts '-' * (head.map{|e| e[:lenght] + 3}.reduce(&:+) + 1)
|
56
|
+
end
|
57
|
+
|
58
|
+
def print_head(head)
|
59
|
+
columns = head.map{|e| e[:name].ljust(e[:lenght], ' ')}
|
60
|
+
puts '| ' + columns.join(' | ') + ' |'
|
61
|
+
end
|
62
|
+
|
63
|
+
def print_row(head, row)
|
64
|
+
columns = head.map{|e| row[e[:id]].to_s.ljust(e[:lenght], ' ')}
|
65
|
+
puts '| ' + columns.join(' | ') + ' |'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
InelsCLI.start
|
data/lib/inels/controller.rb
CHANGED
@@ -56,6 +56,11 @@ module Inels
|
|
56
56
|
client.api_post('temperature/schedules', schedule.result(binding))
|
57
57
|
end
|
58
58
|
|
59
|
+
def set_correction id, correction, client: nil
|
60
|
+
client ||= multi_client.client_for_id('devices', id)
|
61
|
+
client.api_put("devices/#{id}", {correction: correction}.to_json)
|
62
|
+
end
|
63
|
+
|
59
64
|
def set_power id, power, client: nil
|
60
65
|
client ||= multi_client.client_for_id('devices', id)
|
61
66
|
client.api_put("devices/#{id}", {power: power}.to_json)
|
@@ -4,19 +4,19 @@
|
|
4
4
|
"label": "<%= schedule_id %>",
|
5
5
|
"modes": {
|
6
6
|
"1": {
|
7
|
-
"min":
|
7
|
+
"min": 20,
|
8
8
|
"max": 35
|
9
9
|
},
|
10
10
|
"2": {
|
11
|
-
"min":
|
11
|
+
"min": 22,
|
12
12
|
"max": 35
|
13
13
|
},
|
14
14
|
"3": {
|
15
|
-
"min":
|
15
|
+
"min": <%= temperature %>,
|
16
16
|
"max": 35
|
17
17
|
},
|
18
18
|
"4": {
|
19
|
-
"min":
|
19
|
+
"min": 26,
|
20
20
|
"max": 35
|
21
21
|
}
|
22
22
|
},
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zsolt Prontvai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,21 +16,23 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.7.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.7.3
|
27
27
|
description: Client library for the Inels eLAN-RF-003 home automation system
|
28
28
|
email:
|
29
29
|
- prozsolt@gmail.com
|
30
|
-
executables:
|
30
|
+
executables:
|
31
|
+
- inels
|
31
32
|
extensions: []
|
32
33
|
extra_rdoc_files: []
|
33
34
|
files:
|
35
|
+
- bin/inels
|
34
36
|
- lib/inels.rb
|
35
37
|
- lib/inels/client.rb
|
36
38
|
- lib/inels/controller.rb
|
@@ -55,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
57
|
version: '0'
|
56
58
|
requirements: []
|
57
59
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
60
|
+
rubygems_version: 2.7.3
|
59
61
|
signing_key:
|
60
62
|
specification_version: 4
|
61
63
|
summary: Inels client library
|