forked from IntelliHome/Google-at-Home
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into feature-webui
- Loading branch information
Showing
30 changed files
with
861 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
rpc_host: 'localhost' | ||
rpc_port: '3000' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use lib './lib'; | ||
use IntelliHome::Schema::SQLite::Schema; | ||
|
||
my $schema = IntelliHome::Schema::SQLite::Schema->connect( | ||
'dbi:SQLite:/var/lib/intellihome/intellihome.db'); | ||
|
||
my $room_data = { | ||
'name' => "cucina", | ||
'location' => "cucina" | ||
}; | ||
|
||
my $room = $schema->resultset('Room')->create($room_data); | ||
|
||
my $node_data1 = { | ||
'roomid' => $room->id, | ||
'name' => 'master', | ||
'host' => 'localhost', | ||
'port' => 23459, | ||
'type' => 'master', | ||
'username' => 'username', | ||
'password' => 'passwd' | ||
}; | ||
|
||
my $node_data2 = { | ||
'roomid' => $room->id, | ||
'name' => 'master', | ||
'host' => '127.0.0.1', | ||
'port' => 23456, | ||
'type' => 'node', | ||
'username' => 'username', | ||
'password' => 'passwd' | ||
}; | ||
|
||
my $node_one = $schema->resultset('Node')->create($node_data1); | ||
my $node_two = $schema->resultset('Node')->create($node_data2); | ||
|
||
my $gpio_data1 = { | ||
'nodeid' => $node_two->id, | ||
'num_gpio' => 1, | ||
'type' => 3, | ||
'value' => 0, | ||
'driver' => "IntelliHome::Driver::GPIO::Mono" | ||
}; | ||
|
||
my $gpio_data2 = { | ||
'nodeid' => $node_two->id, | ||
'num_gpio' => 2, | ||
'type' => 1, | ||
'value' => 1, | ||
'driver' => "IntelliHome::Driver::GPIO::Dual" | ||
}; | ||
|
||
my $gpio_one = $schema->resultset('GPIO')->create($gpio_data1); | ||
my $gpio_two = $schema->resultset('GPIO')->create($gpio_data2); | ||
|
||
my $tag_data1 = { | ||
'gpioid' => $gpio_one->id, | ||
'tag' => "serranda 1" | ||
}; | ||
|
||
my $tag_data2 = { | ||
'gpioid' => $gpio_two->id, | ||
'tag' => "serranda 2" | ||
}; | ||
|
||
my $tag_one = $schema->resultset('Tag')->create($tag_data1); | ||
my $tag_two = $schema->resultset('Tag')->create($tag_data2); | ||
|
||
my $user_data1 = { | ||
'username' => "user1", | ||
'password' => "password", | ||
'name' => "User 1", | ||
'admin' => 0 | ||
}; | ||
|
||
my $user_data2 = { | ||
'username' => "user2", | ||
'password' => "password", | ||
'name' => "User 2", | ||
'admin' => 1 | ||
}; | ||
|
||
my $user_one = $schema->resultset('User')->create($user_data1); | ||
my $user_two = $schema->resultset('User')->create($user_data2); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package IntelliHome::Deployer::Schema::SQLite; | ||
|
||
use strict; | ||
use Carp::Always; | ||
use warnings; | ||
use 5.010; | ||
use DBIx::Class::DeploymentHandler; | ||
use lib '../../'; | ||
use IntelliHome::Schema::SQLite::Schema; | ||
use File::Path qw(make_path); | ||
use constant DBDIR => "/var/lib/intellihome/"; | ||
use Moo; | ||
|
||
has 'dh' => ( | ||
is => "rw", | ||
lazy => 1, | ||
default => sub { | ||
make_path DBDIR unless -d DBDIR; | ||
return DBIx::Class::DeploymentHandler->new( | ||
{ schema => IntelliHome::Schema::SQLite::Schema->connect( | ||
'dbi:SQLite:' . DBDIR . 'intellihome.db' | ||
), | ||
script_directory => DBDIR . 'db_upgrades', | ||
databases => 'SQLite', | ||
force_overwrite => 1, | ||
schema_version => 1 #TODO pass version | ||
} | ||
); | ||
} | ||
); | ||
|
||
sub prepare { | ||
my $self = shift; | ||
my $from_version = shift; | ||
my $to_version = shift; | ||
$self->dh->prepare_install; | ||
|
||
if ( defined $from_version && defined $to_version ) { | ||
$self->dh->prepare_upgrade( | ||
{ from_version => $from_version, | ||
to_version => $to_version, | ||
} | ||
); | ||
} | ||
} | ||
|
||
sub install { | ||
my $self = shift; | ||
my $version = shift; | ||
if ( defined $version ) { | ||
$self->dh->install( { schema_version => $version } ); | ||
} | ||
else { | ||
$self->dh->install; | ||
} | ||
} | ||
|
||
sub upgrade { | ||
return shift->upgrade; | ||
} | ||
|
||
sub database_version { | ||
return shift->database_version; | ||
} | ||
|
||
sub schema_version { | ||
return shift->schema_version; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.