App-RPi-EnvUI
view release on metacpan or search on metacpan
Changes history for App::RPi::EnvUI
0.30 2017-12-21
- this will be the last beta release. The next release will be 1.00,
will be stable, and will have proper documentation
- the env_to_db() Event will now restart itself if it crashes
- significant modifications to the API action_light() infrastructure...
we use DateTime objects now, per stevieb9/scripts/perl/light_timer
- code cleanup
- fix void assignment of hash in API
- DateTime objects are now properly set in the class scope for
action_light()
- updated t/50 with newer tests; we now perform tests to ensure that if
the on/off cycle completes within the same 24 hour period, the next
"on" time will be pushed to the following day
- updated the timezone in the src config file and db to
America/Vancouver
- fix issue where in test mode, Events aren't created and stored into
the API object, therefore calls to Event->status() would fail when
calling the API->env() method in testing (fixes #48)
- fixed issue where override was not operating correctly. Fixed Perl and
- consolodated the JS graph routines into a single function
- all SQL prepare statements are now only created once, where possible
(queries where structure elements can be hardcoded)
- /logout route now redirects back to the home page
- removed everything related to the water auxs; aux 4 and 5 are now just
generic, unused auxs now
- all auxs are now listed in the HTML template (hidden if pin == -1)
- completely changed the way we track light times. Added
set_light_times(). It's called once on webapp start, then at the end
of each light-off event. It's all done with epoch now instead of
DateTime objects
- the set_aux route has been broken out into two separate routes:
set_aux_state and set_aux_override. (closes #30)
- we now save draggable widget locations if changed from default with
HTML5's `localStorage`
- new menu header "System", with sub menu "Reset Layout", resets layout
to defaults
- template layout changes
- JS code restructured entirely; all functions have been moved out of
$(document).ready
- all auxs will now be hidden if the pin is set to -1 in the config/db
0.26 2016-10-25
- functionality adddition and bug fix beta release
- DB::auth() now returns a hashref of the username sent in with a blank
password field if the user doesn't exist (added tests)
- added light_on() and light_off(), each return a DateTime object with
with the respective times for each operation
- action_light() now uses proper DateTime objects for on/off checking
- _config_light('on_hours') will die if hours is not an integer, is less
than 0 or more than 24
- added numerous new tests for new internal functionality and existing
- cleanup after profiling, shaved startup from 10.7 seconds to ~700ms
(closes #20)
- added new drop-down menu system
- added time to top-right of UI, beside menu, with the same style as the
menu
- UI now has a basic, alpha set of "draggable" widgets
- reworked light_off(), it now uses the set 'on_since' flag as it's base
"runtime" : {
"requires" : {
"Async::Event::Interval" : "0.05",
"Crypt::SaltedHash" : "0",
"DBD::SQLite" : "0",
"DBI" : "0",
"Dancer2" : "0.203001",
"Dancer2::Plugin::Auth::Extensible" : "0",
"Dancer2::Plugin::Auth::Extensible::Provider::Base" : "0",
"Dancer2::Session::JSON" : "0",
"DateTime" : "0",
"Digest::SHA1" : "0",
"JSON::XS" : "0",
"Logging::Simple" : "1.01",
"Mock::Sub" : "1.07",
"Plack::Test" : "0",
"RPi::Const" : "1.02",
"RPi::DHT11" : "1.01",
"Test::More" : "0",
"WiringPi::API" : "1.04"
}
- inc
requires:
Async::Event::Interval: '0.05'
Crypt::SaltedHash: '0'
DBD::SQLite: '0'
DBI: '0'
Dancer2: '0.203001'
Dancer2::Plugin::Auth::Extensible: '0'
Dancer2::Plugin::Auth::Extensible::Provider::Base: '0'
Dancer2::Session::JSON: '0'
DateTime: '0'
Digest::SHA1: '0'
JSON::XS: '0'
Logging::Simple: '1.01'
Mock::Sub: '1.07'
Plack::Test: '0'
RPi::Const: '1.02'
RPi::DHT11: '1.01'
Test::More: '0'
WiringPi::API: '1.04'
resources:
Makefile.PL view on Meta::CPAN
},
},
PL_FILES => {},
PREREQ_PM => {
'Async::Event::Interval' => 0.05,
'Crypt::SaltedHash' => 0,
'Dancer2' => 0.203001,
'Dancer2::Plugin::Auth::Extensible' => 0,
'Dancer2::Plugin::Auth::Extensible::Provider::Base' => 0,
'Dancer2::Session::JSON' => 0,
'DateTime' => 0,
'DBI' => 0,
'DBD::SQLite' => 0,
'Digest::SHA1' => 0,
'JSON::XS' => 0,
'Logging::Simple' => '1.01',
'Mock::Sub' => '1.07',
'Plack::Test' => 0,
'RPi::DHT11' => '1.01',
'RPi::Const' => '1.02',
'Test::More' => 0,
lib/App/RPi/EnvUI/API.pm view on Meta::CPAN
package App::RPi::EnvUI::API;
use strict;
use warnings;
use App::RPi::EnvUI::DB;
use App::RPi::EnvUI::Event;
use Carp qw(confess);
use Crypt::SaltedHash;
use Data::Dumper;
use DateTime;
use JSON::XS;
use Logging::Simple;
use Mock::Sub no_warnings => 1;
use RPi::Const qw(:all);
our $VERSION = '0.30';
# configure handlers
BEGIN {
lib/App/RPi/EnvUI/API.pm view on Meta::CPAN
my $log = $log->child('action_light');
my $aux = $self->_config_control('light_aux');
my $pin = $self->aux_pin($aux);
my $override = $self->aux_override($aux);
return if $override;
my $dt_now = defined $dt_now_test
? $dt_now_test->set_time_zone('local')
: DateTime->now->set_time_zone('local');
if (! $light_initialized){
$log->_5("initializing light");
$light_on_hours = $self->_config_light('on_hours');
$light_on_at = $self->_config_light('on_at');
$log->_6("light on: $light_on_at, light hours: $light_on_hours");
lib/App/RPi/EnvUI/Configuration.pod view on Meta::CPAN
=head3 event_display_timer
Value: Integer, representing the interval (seconds) that the client UI will
automatically refresh the page (asynchronously).
Default: C<4>
=head3 time_zone
Value: A time zone as accepted by L<DateTime>'s C<new()> method's C<time_zone>
parameter.
Default: C<America/Edmonton> (MST)
=head3 testing
Value: Bool. True (C<1>) to enable testing. We will mock out all portions that
are non-Perl in order to allow for unit test runs on non-Pi boards. Set to False
(C<0>) to disable this and run in normal mode.
lib/App/RPi/EnvUI/DB.pm view on Meta::CPAN
package App::RPi::EnvUI::DB;
BEGIN {
if (! exists $INC{'DateTime.pm'}){
require DateTime;
DateTime->import;
}
if (! exists $INC{'DBI.pm'}){
require DBI;
DBI->import;
}
if (! exists $INC{'RPi/Const.pm'}){
require RPi::Const;
RPi::Const->import(qw(:all));
}
}
t/50-api_light.t view on Meta::CPAN
{ # on/off same day to see if the datetime is set correctly
$api->aux_state($aux, 0);
$$init = 0;
$api->action_light;
$$on_at = '01:00';
$$on_hours = 12;
$$dt_now = DateTime->now->set_time_zone('local');
$$dt_now->set_hour(1);
$$dt_now->set_minute(0);
$$dt_now->set_second(0);
$$dt_on = $$dt_now->clone;
$$dt_now->add(minutes => 3);
$$dt_off = $$dt_on->clone;
$$dt_off->add(hours => $$on_hours);
t/50-api_light.t view on Meta::CPAN
$$dt_now->set_hour(13);
$$dt_now->set_minute(2);
$api->action_light;
is $api->aux_state($aux), 0, "lamp is off";
# tomorrow on
$$dt_now = DateTime->now->set_time_zone('local');
$$dt_now->set_hour(1);
$$dt_now->set_minute(0);
$$dt_now->set_second(0);
$$dt_now->add(hours => 24);
$$dt_now->add(minutes => 3);
$api->action_light;
is $api->aux_state($aux), 1, "lamp is on when on/off time is in the same 24 hrs";
# print "now: $$dt_now | on: $$dt_on | off: $$dt_off\n";
( run in 0.405 second using v1.01-cache-2.11-cpan-05444aca049 )