trigger_switch_d 0.1.1 → 0.1.2
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/README.rdoc +74 -57
- data/bin/ts_setup +68 -0
- data/bin/{teach → ts_teach} +1 -1
- data/bin/{turn_off → ts_turn_off} +1 -1
- data/bin/{turn_on → ts_turn_on} +1 -1
- data/bin/tsd +1 -1
- data/config/environment.rb.sample +42 -0
- data/config/lookup.dsl +7 -0
- data/lib/tellstick/code_converter.rb +56 -0
- data/lib/tellstick/protocol/nexa.rb +25 -10
- data/lib/tellstick/protocol/not_connected.rb +6 -14
- data/lib/tellstick/protocol/null_protocol.rb +6 -14
- data/lib/tellstick/protocol/proove.rb +60 -35
- data/lib/tellstick/protocol/protocol_loader.rb +2 -3
- data/lib/tellstick/protocol/rising_sun.rb +8 -4
- data/lib/tellstick/proxy_io.rb +32 -14
- data/lib/tellstick/tellstick.rb +4 -12
- data/lib/trigger_switch_d/action.rb +54 -19
- data/lib/trigger_switch_d/application.rb +77 -34
- data/lib/trigger_switch_d/config.rb +85 -35
- data/lib/trigger_switch_d/daylight.rb +135 -52
- data/lib/trigger_switch_d/ipc.rb +44 -12
- data/lib/trigger_switch_d/schedule.rb +20 -13
- data/lib/trigger_switch_d/switch.rb +6 -0
- data/lib/trigger_switch_d/trigger_switch_d_helper.rb +14 -13
- data/samples/devices +14 -0
- data/samples/devices.rising_sun +6 -0
- data/samples/environment.rb +44 -0
- data/samples/lookup.dsl +7 -0
- data/samples/scheduled_actions +6 -0
- data/samples/scheduled_actions.rising_sun +4 -0
- metadata +41 -116
- data/doc/classes/Tellstick/Tellstick.html +0 -117
- data/doc/classes/Tellstick/TellstickIO.html +0 -265
- data/doc/classes/Tellstick/TellstickIO.src/M000020.html +0 -18
- data/doc/classes/Tellstick/TellstickIO.src/M000021.html +0 -20
- data/doc/classes/Tellstick/TellstickIO.src/M000022.html +0 -26
- data/doc/classes/Tellstick/TellstickIO.src/M000023.html +0 -19
- data/doc/classes/Tellstick/TellstickIO.src/M000024.html +0 -26
- data/doc/classes/Tellstick/TellstickIO.src/M000025.html +0 -16
- data/doc/classes/Tellstick/TellstickIO.src/M000026.html +0 -16
- data/doc/classes/Tellstick/TellstickIO.src/M000027.html +0 -24
- data/doc/classes/Tellstick.html +0 -204
- data/doc/classes/Tellstick.src/M000019.html +0 -25
- data/doc/classes/TriggerSwitchD/Action.html +0 -165
- data/doc/classes/TriggerSwitchD/Action.src/M000015.html +0 -28
- data/doc/classes/TriggerSwitchD/Action.src/M000016.html +0 -18
- data/doc/classes/TriggerSwitchD/Application.html +0 -203
- data/doc/classes/TriggerSwitchD/Application.src/M000017.html +0 -21
- data/doc/classes/TriggerSwitchD/Application.src/M000018.html +0 -40
- data/doc/classes/TriggerSwitchD/ConfigFactory/Config.html +0 -127
- data/doc/classes/TriggerSwitchD/ConfigFactory/Config.src/M000014.html +0 -23
- data/doc/classes/TriggerSwitchD/ConfigFactory.html +0 -141
- data/doc/classes/TriggerSwitchD/ConfigFactory.src/M000013.html +0 -24
- data/doc/classes/TriggerSwitchD/IPC.html +0 -134
- data/doc/classes/TriggerSwitchD/IPC.src/M000012.html +0 -32
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.html +0 -242
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000005.html +0 -19
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000006.html +0 -18
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000007.html +0 -23
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000008.html +0 -19
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000009.html +0 -19
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000010.html +0 -18
- data/doc/classes/TriggerSwitchD/Schedule/InstanceMethods.src/M000011.html +0 -18
- data/doc/classes/TriggerSwitchD/Schedule.html +0 -147
- data/doc/classes/TriggerSwitchD/Schedule.src/M000004.html +0 -19
- data/doc/classes/TriggerSwitchD/SwitchFactory.html +0 -135
- data/doc/classes/TriggerSwitchD/SwitchFactory.src/M000003.html +0 -20
- data/doc/classes/TriggerSwitchD.html +0 -212
- data/doc/classes/TriggerSwitchD.src/M000001.html +0 -22
- data/doc/classes/TriggerSwitchD.src/M000002.html +0 -27
- data/doc/created.rid +0 -1
- data/doc/files/lib/tellstick/protocol/nexa_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/not_connected_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/null_protocol_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/plain_text_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/proove_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/protocol_loader_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/rising_sun_rb.html +0 -126
- data/doc/files/lib/tellstick/protocol/waveman_rb.html +0 -126
- data/doc/files/lib/tellstick/tellstick_io_rb.html +0 -135
- data/doc/files/lib/tellstick/tellstick_rb.html +0 -135
- data/doc/files/lib/tellstick_rb.html +0 -134
- data/doc/files/lib/trigger_switch_d/action_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d/application_rb.html +0 -136
- data/doc/files/lib/trigger_switch_d/config_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d/daylight_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d/ipc_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d/schedule_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d/switch_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d/trigger_switch_d_helper_rb.html +0 -126
- data/doc/files/lib/trigger_switch_d_rb.html +0 -140
- data/doc/fr_class_index.html +0 -38
- data/doc/fr_file_index.html +0 -46
- data/doc/fr_method_index.html +0 -53
- data/doc/index.html +0 -24
- data/features/execute_schedule.feature +0 -20
- data/features/group_aliases.feature +0 -31
- data/features/handle_switches.feature +0 -36
- data/features/listen_for_client_call.feature +0 -23
- data/features/persistent_schedule.feature +0 -70
- data/features/proove_protocol.feature +0 -20
- data/features/schedule.feature +0 -25
- data/features/simple_string_protocol.feature +0 -35
- data/features/step_definitions/execute_schedule_steps.rb +0 -16
- data/features/step_definitions/group_aliases_steps.rb +0 -24
- data/features/step_definitions/handle_switches_steps.rb +0 -21
- data/features/step_definitions/listen_for_client_call_steps.rb +0 -34
- data/features/step_definitions/persistent_schedule_steps.rb +0 -18
- data/features/step_definitions/proove_protocol_steps.rb +0 -3
- data/features/step_definitions/schedule_steps.rb +0 -9
- data/features/step_definitions/shared_steps.rb +0 -75
- data/features/step_definitions/simple_string_protocol_steps.rb +0 -3
- data/features/step_definitions/sunrise_steps.rb +0 -22
- data/features/step_definitions/tellstick_connected_steps.rb +0 -21
- data/features/sunrise.feature +0 -22
- data/features/sunset.feature +0 -22
- data/features/support/action_helpers.rb +0 -10
- data/features/support/env.rb +0 -7
- data/features/support/listen_for_client_call_helper.rb +0 -71
- data/features/support/proove_helpers.rb +0 -6
- data/features/support/sunrise_helper.rb +0 -8
- data/features/tellstick_connected.feature +0 -14
- data/spec/spec_helper.rb +0 -22
- data/spec/tellstick/protocol/nexa_spec.rb +0 -57
- data/spec/tellstick/protocol/proove_spec.rb +0 -61
- data/spec/tellstick/protocol/rising_sun_spec.rb +0 -56
- data/spec/tellstick/protocol/waveman_spec.rb +0 -57
- data/spec/tellstick/proxy_io_spec.rb +0 -34
- data/spec/tellstick/tellstick_spec.rb +0 -86
- data/spec/trigger_switch_d/application_spec.rb +0 -147
- data/spec/trigger_switch_d/config_spec.rb +0 -154
- data/spec/trigger_switch_d/daylight_spec.rb +0 -39
- data/spec/trigger_switch_d/ipc_spec.rb +0 -119
- data/spec/trigger_switch_d/schedule_spec.rb +0 -103
- data/spec/trigger_switch_d/trigger_switch_d_spec_helpers.rb +0 -24
- data/trigger_switch_d.gemspec +0 -43
@@ -1,21 +0,0 @@
|
|
1
|
-
Givet /^att usb stickan inte är inkopplad$/ do
|
2
|
-
message = StringIO.new
|
3
|
-
def message.connected?; false;end
|
4
|
-
message.connected?.should == false
|
5
|
-
end
|
6
|
-
|
7
|
-
Givet /^jag har skapat en tellstick$/ do
|
8
|
-
message = StringIO.new
|
9
|
-
def message.connected?; false;end
|
10
|
-
Tellstick::create(message)
|
11
|
-
end
|
12
|
-
|
13
|
-
När /^jag (.+) en strömbrytare (.+) (.+)$/ do |kommando,hus,enhet|
|
14
|
-
@message = StringIO.new
|
15
|
-
def @message.connected?; false;end
|
16
|
-
dongle(@message).send(actions[kommando[0..-3]],hus,enhet)
|
17
|
-
end
|
18
|
-
|
19
|
-
Så /^skall jag se meddelandet "([^\"]*)"$/ do |meddelande|
|
20
|
-
@message.string.gsub("\n","").should include(meddelande)
|
21
|
-
end
|
data/features/sunrise.feature
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#language: se
|
2
|
-
Egenskap: Sunrise
|
3
|
-
För att kunna, var jag än är, ställa min väckarklocka att ringa precis innan solen går upp
|
4
|
-
Som en solbeivrare
|
5
|
-
Vill jag kunna räkna ut tiden för soluppgång
|
6
|
-
|
7
|
-
@implemented
|
8
|
-
Abstrakt Scenario: soluppgång på den plats jag är
|
9
|
-
Givet att aktuellt datum är "<datum>"
|
10
|
-
Och att jag är på latitud "<latitude>"
|
11
|
-
Och att jag är på longitud "<longitude>"
|
12
|
-
När jag beräknar soluppgång
|
13
|
-
Så skall se "<soluppgång>"
|
14
|
-
|
15
|
-
Exempel:
|
16
|
-
| datum | latitude | longitude | soluppgång |
|
17
|
-
| 20100505 | 55:36.6N | 12:59.7Ö | 05:18 |
|
18
|
-
| 20100830 | 57:42.6N | 11:58.08Ö | 06:09 |
|
19
|
-
| 20091214 | 60:40.68N | 17:8.52Ö | 08:55 |
|
20
|
-
|
21
|
-
|
22
|
-
|
data/features/sunset.feature
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#language: se
|
2
|
-
Egenskap: Sunset
|
3
|
-
För att kunna, var jag än är, tända ytterbelysningen precis innan solen går ned
|
4
|
-
Som en kvälls människa
|
5
|
-
Vill jag kunna räkna ut tiden för solnedgång
|
6
|
-
|
7
|
-
@implemented
|
8
|
-
Abstrakt Scenario: solnedgång på den plats jag är
|
9
|
-
Givet att aktuellt datum är "<datum>"
|
10
|
-
Och att jag är på latitud "<latitude>"
|
11
|
-
Och att jag är på longitud "<longitude>"
|
12
|
-
När jag beräknar solnedgång
|
13
|
-
Så skall se "<solnedgång>"
|
14
|
-
|
15
|
-
Exempel:
|
16
|
-
| datum | latitude | longitude | solnedgång |
|
17
|
-
| 20100505 | 55:36.6N | 12:59.7Ö | 20:53 |
|
18
|
-
| 20100830 | 57:42.6N | 11:58.08Ö | 20:19 |
|
19
|
-
| 20091214 | 60:40.68N | 17:8.52Ö | 14:39 |
|
20
|
-
|
21
|
-
|
22
|
-
|
data/features/support/env.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__),".." ,".." ,"lib" )
|
2
|
-
require 'cucumber/formatter/unicode'
|
3
|
-
require 'tellstick'
|
4
|
-
require 'trigger_switch_d'
|
5
|
-
require 'socket'
|
6
|
-
TriggerSwitchD::ConfigFactory.new
|
7
|
-
TriggerSwitchD::SwitchFactory.new(["house_code","unit_code","model_name"])
|
@@ -1,71 +0,0 @@
|
|
1
|
-
module ListenForClientCallHelper
|
2
|
-
def devices_filename
|
3
|
-
"db/devices"
|
4
|
-
end
|
5
|
-
|
6
|
-
def schedule_filename
|
7
|
-
"db/scheduled_actions"
|
8
|
-
end
|
9
|
-
|
10
|
-
def config_filename
|
11
|
-
"config/config.rb"
|
12
|
-
end
|
13
|
-
|
14
|
-
def prepare_devices(device_name,device1,device2)
|
15
|
-
__recreate_db_dir__
|
16
|
-
dev = []
|
17
|
-
dev = __load_existing_devices__ if File.exist? devices_filename
|
18
|
-
new_switches = [device1,device2].map do |device|
|
19
|
-
device.split(",").flatten
|
20
|
-
end.map do |device|
|
21
|
-
{"house_code" => device[0], "unit_code" => device[1], "model_name" => device[2]}
|
22
|
-
end
|
23
|
-
dev << {"name" => device_name, "switches" => new_switches}
|
24
|
-
file = File.open(devices_filename,"w+")
|
25
|
-
YAML::dump(dev,file)
|
26
|
-
file.close
|
27
|
-
end
|
28
|
-
|
29
|
-
def prepare_config
|
30
|
-
file = File.open(config_filename,"w+")
|
31
|
-
file.puts <<-EOS
|
32
|
-
Config.geo_position = {:north => 54.57525, :west => -12.94125}
|
33
|
-
Config.log_path = "log"
|
34
|
-
Config.db_path = "db"
|
35
|
-
Config.dsl_path = "config"
|
36
|
-
#Config.log_object = :file
|
37
|
-
Config.log_object = :spec
|
38
|
-
Config.output = :spec
|
39
|
-
Config.unix_socket_path = "/tmp"
|
40
|
-
EOS
|
41
|
-
file.close
|
42
|
-
end
|
43
|
-
|
44
|
-
def prepare_schedule(action)
|
45
|
-
__recreate_db_dir__
|
46
|
-
actions = ["#{action}\n"]
|
47
|
-
file = File.open(schedule_filename,"a+")
|
48
|
-
file.write(actions)
|
49
|
-
file.close
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def __recreate_db_dir__
|
55
|
-
Dir.mkdir("db") unless File.directory? "db"
|
56
|
-
end
|
57
|
-
|
58
|
-
def __load_existing_devices__
|
59
|
-
file = File.open(devices_filename,"r")
|
60
|
-
devices = TriggerSwitchD::load_devices(file)
|
61
|
-
file.close
|
62
|
-
devices.map do |device|
|
63
|
-
switches = device[1].map do |switch|
|
64
|
-
{"house_code" => switch.house_code, "unit_code" => switch.unit_code, "model_name" => switch.model_name}
|
65
|
-
end
|
66
|
-
{"name" => device[0], "switches" => switches}
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
World(ListenForClientCallHelper)
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#language: se
|
2
|
-
Egenskap: Om tellstick är inkopplad eller inte
|
3
|
-
|
4
|
-
För att usb stickan skall kunna skicka signaler till strömbrytare
|
5
|
-
Som en användare av usb stickan
|
6
|
-
Vill jag veta om usb stickan är inkopplad eller inte
|
7
|
-
|
8
|
-
@implemented
|
9
|
-
Scenario: är tellstick inkopplad
|
10
|
-
Givet att usb stickan inte är inkopplad
|
11
|
-
Och jag har skapat en tellstick
|
12
|
-
När jag tänder en strömbrytare A 1
|
13
|
-
När jag släcker en strömbrytare B 7
|
14
|
-
Så skall jag se meddelandet "Koppla in usb stickan först"
|
data/spec/spec_helper.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__),".." ,"lib" )
|
19
|
-
require 'spec'
|
20
|
-
require 'tellstick'
|
21
|
-
require 'trigger_switch_d'
|
22
|
-
TriggerSwitchD::ConfigFactory.new
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__),"..","..","spec_helper")
|
19
|
-
|
20
|
-
# "S$k$k $kk$ $k+"
|
21
|
-
# "S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+"
|
22
|
-
# "S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$k$k$}+"
|
23
|
-
# "S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+"
|
24
|
-
# "S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$k$k$}+"
|
25
|
-
|
26
|
-
module Tellstick
|
27
|
-
describe Tellstick do
|
28
|
-
context "switch uses nexa code switch protocol" do
|
29
|
-
before(:each) do
|
30
|
-
@messages = StringIO.new
|
31
|
-
end
|
32
|
-
it "should turn on switch with house and unit code" do
|
33
|
-
::Tellstick.create(@messages,"nexa").turn_on("A",1)
|
34
|
-
@messages.string.split("\n").should include("S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+")
|
35
|
-
end
|
36
|
-
it "should turn off switch with house and unit code" do
|
37
|
-
::Tellstick.create(@messages,"nexa").turn_off("A",1)
|
38
|
-
@messages.string.split("\n").should include("S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$k$k$}+")
|
39
|
-
end
|
40
|
-
it "should turn on switch with house and unit code" do
|
41
|
-
::Tellstick.create(@messages,"nexa").turn_on("B",2)
|
42
|
-
@messages.string.split("\n").should include("S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+")
|
43
|
-
end
|
44
|
-
it "should turn off switch with house and unit code" do
|
45
|
-
::Tellstick.create(@messages,"nexa").turn_off("B",2)
|
46
|
-
@messages.string.split("\n").should include("S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$k$k$}+")
|
47
|
-
end
|
48
|
-
describe "house code is a number instead of letter" do
|
49
|
-
it "should turn on switch with house and unit code" do
|
50
|
-
::Tellstick.create(@messages,"nexa").turn_on("2",2)
|
51
|
-
@messages.string.split("\n").should include("S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__),"..","..","spec_helper")
|
19
|
-
|
20
|
-
module Tellstick
|
21
|
-
describe Tellstick do
|
22
|
-
context "switch uses proove protocol" do
|
23
|
-
before(:each) do
|
24
|
-
@messages = StringIO.new
|
25
|
-
end
|
26
|
-
it "should turn on switch with house and unit code" do
|
27
|
-
::Tellstick.create(@messages,"proove").turn_on("A",1)
|
28
|
-
@messages.string.split("\n").should include("R\005T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\210\252\212\212\212\212+")
|
29
|
-
end
|
30
|
-
it "should turn off switch with house and unit code" do
|
31
|
-
::Tellstick.create(@messages,"proove").turn_off("A",1)
|
32
|
-
@messages.string.split("\n").should include("R\005T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212+")
|
33
|
-
end
|
34
|
-
it "should turn on switch with house and unit code" do
|
35
|
-
::Tellstick.create(@messages,"proove").turn_on("B",2)
|
36
|
-
@messages.string.split("\n").should include("R\005T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\210\252\210\252\212\212\210\252+")
|
37
|
-
end
|
38
|
-
it "should turn off switch with house and unit code" do
|
39
|
-
::Tellstick.create(@messages,"proove").turn_off("B",2)
|
40
|
-
@messages.string.split("\n").should include("R\005T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\210\252\212\212\212\212\210\252+")
|
41
|
-
end
|
42
|
-
it "should teach switch with house and unit code" do
|
43
|
-
::Tellstick.create(@messages,"proove").teach("A",1)
|
44
|
-
@messages.string.split("\n").length.should == 5
|
45
|
-
@messages.string.split("\n").should include("R\002T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\210\252\212\212\212\212+")
|
46
|
-
end
|
47
|
-
it "should teach switch with house and unit code" do
|
48
|
-
::Tellstick.create(@messages,"proove").teach("B",2)
|
49
|
-
@messages.string.split("\n").length.should == 5
|
50
|
-
@messages.string.split("\n").should include("R\002T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\210\252\210\252\212\212\210\252+")
|
51
|
-
end
|
52
|
-
describe "house code is a number instead of letter" do
|
53
|
-
it "should turn on switch with house and unit code" do
|
54
|
-
::Tellstick.create(@messages,"proove").turn_on("17",1)
|
55
|
-
@messages.string.split("\n").should include("R\005T\177\377\030\001\204\232\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\212\210\252\210\252\212\212\212\212+")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__),"..","..","spec_helper")
|
19
|
-
|
20
|
-
# "S.e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..ee..e+"
|
21
|
-
# "S.ee..e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..e+"
|
22
|
-
# "S.e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..e.e.e+"
|
23
|
-
# "S.ee..e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..e.e.e+"
|
24
|
-
|
25
|
-
module Tellstick
|
26
|
-
describe Tellstick do
|
27
|
-
context "switch uses rising sun protocol" do
|
28
|
-
before(:each) do
|
29
|
-
@messages = StringIO.new
|
30
|
-
end
|
31
|
-
it "should turn on switch with house and unit code" do
|
32
|
-
::Tellstick.create(@messages,"rising_sun").turn_on("A",1)
|
33
|
-
@messages.string.split("\n").should include("S.e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..ee..e+")
|
34
|
-
end
|
35
|
-
it "should turn off switch with house and unit code" do
|
36
|
-
::Tellstick.create(@messages,"rising_sun").turn_off("A",1)
|
37
|
-
@messages.string.split("\n").should include("S.e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..e.e.e+")
|
38
|
-
end
|
39
|
-
it "should turn on switch with house and unit code" do
|
40
|
-
::Tellstick.create(@messages,"rising_sun").turn_on("B",2)
|
41
|
-
@messages.string.split("\n").should include("S.ee..e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..e+")
|
42
|
-
end
|
43
|
-
it "should turn off switch with house and unit code" do
|
44
|
-
::Tellstick.create(@messages,"rising_sun").turn_off("B",2)
|
45
|
-
@messages.string.split("\n").should include("S.ee..e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..e.e.e+")
|
46
|
-
end
|
47
|
-
describe "house code is a number instead of letter" do
|
48
|
-
it "should turn on switch with house and unit code" do
|
49
|
-
::Tellstick.create(@messages,"rising_sun").turn_on("2",2)
|
50
|
-
@messages.string.split("\n").should include("S.ee..e.e.ee..ee..ee..e.e.ee..ee..ee..ee..ee..ee..e+")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__),"..","..","spec_helper")
|
19
|
-
|
20
|
-
# "S$k$k $kk$ $k+"
|
21
|
-
# "S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+"
|
22
|
-
# "S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$}+"
|
23
|
-
# "S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+"
|
24
|
-
# "S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$k$k$k$k$k$k$}+"
|
25
|
-
|
26
|
-
module Tellstick
|
27
|
-
describe Tellstick do
|
28
|
-
context "switch uses waveman code switch protocol" do
|
29
|
-
before(:each) do
|
30
|
-
@messages = StringIO.new
|
31
|
-
end
|
32
|
-
it "should turn on switch with house and unit code" do
|
33
|
-
::Tellstick.create(@messages,"waveman").turn_on("A",1)
|
34
|
-
@messages.string.split("\n").should include("S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+")
|
35
|
-
end
|
36
|
-
it "should turn off switch with house and unit code" do
|
37
|
-
::Tellstick.create(@messages,"waveman").turn_off("A",1)
|
38
|
-
@messages.string.split("\n").should include("S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$}+")
|
39
|
-
end
|
40
|
-
it "should turn on switch with house and unit code" do
|
41
|
-
::Tellstick.create(@messages,"waveman").turn_on("B",2)
|
42
|
-
@messages.string.split("\n").should include("S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+")
|
43
|
-
end
|
44
|
-
it "should turn off switch with house and unit code" do
|
45
|
-
::Tellstick.create(@messages,"waveman").turn_off("B",2)
|
46
|
-
@messages.string.split("\n").should include("S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$k$k$k$k$k$k$}+")
|
47
|
-
end
|
48
|
-
describe "house code is a number instead of letter" do
|
49
|
-
it "should turn on switch with house and unit code" do
|
50
|
-
::Tellstick.create(@messages,"waveman").turn_on("2",2)
|
51
|
-
@messages.string.split("\n").should include("S$kk$$k$k$k$k$k$k$kk$$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__),"..","spec_helper")
|
19
|
-
|
20
|
-
module Tellstick
|
21
|
-
describe ProxyIO do
|
22
|
-
it "should respond to puts, gets when there is no TellstickIO instance" do
|
23
|
-
dongle = StringIO.new
|
24
|
-
dongle.stub!(:new).and_return(dongle)
|
25
|
-
dongle.stub!(:gets).and_return("bla")
|
26
|
-
dongle.stub!(:close)
|
27
|
-
proxy = ProxyIO.new(StringIO)
|
28
|
-
proxy.close
|
29
|
-
Proc.new { proxy.puts "bla" }.should_not raise_error(NoMethodError)
|
30
|
-
proxy.close
|
31
|
-
Proc.new { proxy.gets }.should_not raise_error(NoMethodError)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# TriggerSwitchD, executes commands to activate/deactive remote switches.
|
2
|
-
# (c) Copyright 2010 Pontus Strömdahl, AdhocSkill.
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
|
18
|
-
require File.join(File.dirname(__FILE__),"..","spec_helper")
|
19
|
-
|
20
|
-
module Tellstick
|
21
|
-
describe Tellstick do
|
22
|
-
before(:each) do
|
23
|
-
@messages = StringIO.new
|
24
|
-
end
|
25
|
-
it "should create a tellstick" do
|
26
|
-
@messages.stub("connected?").and_return(true)
|
27
|
-
@messages.should_receive("connected?").and_return(true)
|
28
|
-
::Tellstick.create(@messages).should_not == nil
|
29
|
-
end
|
30
|
-
context "usb dongle is connected" do
|
31
|
-
before(:each) do
|
32
|
-
@messages.stub("connected?").and_return(true)
|
33
|
-
end
|
34
|
-
it "should know if usb dongle is connected" do
|
35
|
-
@messages.connected?.should == true
|
36
|
-
end
|
37
|
-
it "should turn on switch with house and unit code" do
|
38
|
-
@messages.should_receive("connected?").and_return(true)
|
39
|
-
::Tellstick.create(@messages).turn_on("A",1)
|
40
|
-
@messages.string.split("\n").should include("Strömbrytare A1 tänd")
|
41
|
-
end
|
42
|
-
it "should turn off switch with house and unit code" do
|
43
|
-
@messages.should_receive("connected?").and_return(true)
|
44
|
-
::Tellstick.create(@messages).turn_off("D",3)
|
45
|
-
@messages.string.split("\n").should include("Strömbrytare D3 släckt")
|
46
|
-
end
|
47
|
-
describe "house code is a number instead of letter" do
|
48
|
-
it "should turn on switch with house and unit code" do
|
49
|
-
@messages.should_receive("connected?").and_return(true)
|
50
|
-
::Tellstick.create(@messages).turn_on(3,5)
|
51
|
-
@messages.string.split("\n").should include("Strömbrytare 35 tänd")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "usb dongle is not connected" do
|
57
|
-
before(:each) do
|
58
|
-
@messages.stub("connected?").and_return(false)
|
59
|
-
end
|
60
|
-
it "should know if usb dongle is connected" do
|
61
|
-
@messages.connected?.should == false
|
62
|
-
end
|
63
|
-
it "should tell us to connect usb dongle" do
|
64
|
-
@messages.should_receive("connected?").and_return(false)
|
65
|
-
::Tellstick.create(@messages).turn_off("D",3)
|
66
|
-
@messages.string.should include("Koppla in usb stickan först")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "output does not have connected? method" do
|
71
|
-
it "assumes output is connected" do
|
72
|
-
output = StringIO.new
|
73
|
-
::Tellstick.create(output).turn_off("D",3)
|
74
|
-
output.string.split("\n").should include("Strömbrytare D3 släckt")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "protocol name does not exist" do
|
79
|
-
it "assumes protocol is NullProtocol" do
|
80
|
-
output = StringIO.new
|
81
|
-
::Tellstick.create(output,"undefined_protocol").turn_off("D",3)
|
82
|
-
output.string.split("\n").should include("Protokollet finns inte")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|