Permalink
Browse files

Updated plugin - Need to test

  • Loading branch information...
0 parents commit 75ad288f24fed82c22f79f40d9507b3dd868b96f @fiquett committed Nov 27, 2011
Showing with 89 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 Gemfile
  3. +1 −0 Rakefile
  4. +9 −0 config-info.yml
  5. +51 −0 lib/siriproxy-vipercontrol.rb
  6. +23 −0 siriproxy-vipercontrol.gemspec
@@ -0,0 +1 @@
+Gemfile.lock
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in siriproxy-vipercontrol.gemspec
+gemspec
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
+#Example configuration options that can be placed in your main SiriProxy config.yml
+
+##########################
+#NOTICE: Modifying these options in this file has no effect. You must put them in SiriProxy's config.yml!
+##########################
+
+ - name: 'ViperControl'
+ git: 'git://github.com/fiquett/SiriProxy-ViperControl.git'
+ host: 'yourwebserver'
@@ -0,0 +1,51 @@
+require 'json'
+
+class SiriProxy::Plugin::ViperControl < SiriProxy::Plugin
+ attr_accessor :host
+
+ def initialize(config = {})
+ self.host = config["host"]
+ end
+
+ #capture ViperControl status
+ listen_for(/Car.*start/i) { send_command_to_car("remote") }
+ listen_for(/start.*Car/i) { send_command_to_car("remote") }
+
+ listen_for(/Car.*lock/i) { send_command_to_car("arm") }
+ listen_for(/lock.*Car/i) { send_command_to_car("arm") }
+
+ listen_for(/Car.*unlock/i) { send_command_to_car("disarm") }
+ listen_for(/unlock.*Car/i) { send_command_to_car("disarm") }
+
+ listen_for(/Car.*trunk/i) { send_command_to_car("trunk") }
+ listen_for(/trunk.*Car/i) { send_command_to_car("trunk") }
+
+ listen_for(/Car.*panic/i) { send_command_to_car("panic") }
+ listen_for(/panic.*Car/i) { send_command_to_car("panic") }
+
+ def send_command_to_car(viper_command)
+ say "One moment while I connect to your vehicle..."
+
+ Thread.new {
+ status = JSON.parse(open("http://#{self.host}/viper_control.php?action=#{viper_command}").read)
+ if status
+ say "Viper Connection Successful"
+ if(status["Return"]["ResponseSummary"]["StatusCode"] == 0) #successful
+ if(status["Return"]["Results"]["Device"]["Action"] == "arm")
+ say "Vehicle security engaged!"
+ elsif(status["Return"]["Results"]["Device"]["Action"] == "disarm")
+ say "Vehicle security disabled!"
+ elsif(status["Return"]["Results"]["Device"]["Action"] == "remote")
+ say "Vehicle ignition has been triggered"
+ elsif(status["Return"]["Results"]["Device"]["Action"] == "trunk")
+ say "Vehicle trunk has been opened"
+ end
+ else
+ say "Sorry, could not connect to your vehicle."
+ end
+ end
+
+ request_completed
+ }
+ end
+end
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "siriproxy-vipercontrol"
+ s.version = "0.0.1"
+ s.authors = ["fiquett"]
+ s.email = [""]
+ s.homepage = "http://fiquett.com"
+ s.summary = %q{Viper SmartStart Control Plugin}
+ s.description = %q{This plugin accepts commands and send them to car via Viper SmartStart network}
+
+ s.rubyforge_project = "siriproxy-vipercontrol"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ # s.add_development_dependency "rspec"
+ s.add_runtime_dependency "json"
+end

0 comments on commit 75ad288

Please sign in to comment.