lightwaverf 0.0.7 → 0.0.8
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.
- data/bin/lightwaverf +7 -4
- data/lib/lightwaverf.rb +21 -3
- metadata +2 -2
data/bin/lightwaverf
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
require 'lightwaverf'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
case ARGV[0]
|
4
|
+
when 'help'
|
5
|
+
puts LightWaveRF.new.help
|
6
|
+
when 'energy'
|
7
|
+
puts LightWaveRF.new.energy
|
8
|
+
else
|
9
|
+
LightWaveRF.new.send ARGV[0], ARGV[1], ARGV[2], ARGV[4]
|
7
10
|
end
|
data/lib/lightwaverf.rb
CHANGED
@@ -9,13 +9,16 @@ class LightWaveRF
|
|
9
9
|
|
10
10
|
def usage
|
11
11
|
rooms = self.class.get_rooms self.get_config
|
12
|
-
'usage: lightwaverf ' + rooms.keys.first + ' ' + rooms.values.first['device'].keys.first.to_s + ' on'
|
12
|
+
'usage: lightwaverf ' + rooms.keys.first + ' ' + rooms.values.first['device'].keys.first.to_s + ' on # where "' + rooms.keys.first + '" is a room in ' + self.get_config_file
|
13
13
|
end
|
14
14
|
|
15
15
|
def help
|
16
16
|
help = self.usage + "\n"
|
17
|
-
help +=
|
17
|
+
help += "your rooms, devices, and sequences, as defined in " + self.get_config_file + ":\n\n"
|
18
18
|
help += YAML.dump self.get_config['room']
|
19
|
+
room = self.get_config['room'].keys.last
|
20
|
+
device = self.get_config['room'][room].last
|
21
|
+
help += "\n\nso to turn on " + room + " " + device + " type \"lightwaverf " + room + " " + device + " on\"\n"
|
19
22
|
end
|
20
23
|
|
21
24
|
def config_json
|
@@ -68,6 +71,10 @@ class LightWaveRF
|
|
68
71
|
state = 'F1'
|
69
72
|
when 1..100
|
70
73
|
state = 'FdP' + ( state * 0.32 ).round.to_s
|
74
|
+
else
|
75
|
+
if state
|
76
|
+
p 'did not recognise state, got ' + state
|
77
|
+
end
|
71
78
|
end
|
72
79
|
state
|
73
80
|
end
|
@@ -108,6 +115,15 @@ class LightWaveRF
|
|
108
115
|
end
|
109
116
|
end
|
110
117
|
|
118
|
+
# A sequence of events
|
119
|
+
# maybe I really mean a "mood" here?
|
120
|
+
#
|
121
|
+
# Example:
|
122
|
+
# >> LightWaveRF.new.sequence 'lights'
|
123
|
+
#
|
124
|
+
# Arguments:
|
125
|
+
# name: (String)
|
126
|
+
# debug: (Boolean)
|
111
127
|
def sequence name, debug = false
|
112
128
|
if self.get_config['sequence'][name]
|
113
129
|
self.get_config['sequence'][name].each do | task |
|
@@ -119,8 +135,10 @@ class LightWaveRF
|
|
119
135
|
|
120
136
|
def energy
|
121
137
|
data = self.raw '666,@?'
|
138
|
+
p data
|
122
139
|
# /W=(?<usage>\d+),(?<max>\d+),(?<today>\d+),(?<yesterday>\d+)/.match( data ) # ruby 1.9 only?
|
123
|
-
/W=(\d+),(\d+),(\d+),(\d+)/.match( data )
|
140
|
+
match = /W=(\d+),(\d+),(\d+),(\d+)/.match( data )
|
141
|
+
{ 'usage' => match[0], 'max' => match[1], 'today' => match[2], 'yesterday' => match[3] }
|
124
142
|
end
|
125
143
|
|
126
144
|
def raw command
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightwaverf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: Interact with lightwaverf wifi link from the command line
|
14
|
+
description: Interact with lightwaverf wifi link from code or the command line
|
15
15
|
email: pauly@clarkeology.com
|
16
16
|
executables:
|
17
17
|
- lightwaverf
|