App-RPi-EnvUI

 view release on metacpan or  search on metacpan

lib/App/RPi/EnvUI.pm  view on Meta::CPAN

                    error => 'unauthorized request. You must be logged in'
            };
        }

        my $aux_id = params->{aux};
        my $override = $api->_bool(params->{override});

        $log->_5("setting override for aux id: $aux_id");

        $override = $api->aux_override($aux_id, $override);

        $log->_5("current override status for aux id $aux_id is $override");

        if ($override == -1){
            $log->_5("override for aux id $aux_id is currently disabled");
        }

        return to_json {
            aux => $aux_id,
            override => $override,
        };
    };

true;

__END__

=head1 NAME

App::RPi::EnvUI - One-page asynchronous grow room environment control web
application

=head1 SYNOPSIS

    cd ~/envui
    sudo plackup bin/app.pl

Now direct your browser at your Pi, on port 3000:

    http://raspberry.pi:3000

=head1 DESCRIPTION

*** This is beta software until v1.00 is released. It's still a constant work
in progress, so the docs are awful, but I am trying to improve them as I learn
the things I need to know to get where I want to be.***

*** Note that my focus hasn't been one about detailed security, so please, if
you desire to test this software, ensure it is not Internet facing, and you have
adequate protection from undesired access ***

A self-contained, one-page web application that runs on a Raspberry Pi and
monitors and manages an indoor grow room environment, with an API that can be
used external to the web app itself.

This distribution reads environmental sensors, turns on/off devices based on
specific thresholds, contains an adjustable grow light timer, and five extra
auxillary channels that you can configure for your own use.

The software connects to Raspberry Pi GPIO pins for each C<"auxillary">, and at
specific times or thresholds, turns on and or off the 120/240v devices that
you've relayed to that voltage (if you choose to use this functionality).

=head1 WHAT IT DOES

Reads temperature and humidity data via a hygrometer sensor through the
L<RPi::DHT11> distribution.

It then allows, through a one-page asynchronous web UI to turn on and off
120/240v devices through buttons, timers and reached threshold limits.

For example. We have a max temperature limit of 80F. We assign an auxillary
(GPIO pin) that is connected to a relay to a 120v exhaust fan. Through the
configuration file, we load the temp limit, and if the temp goes above it, we
enable the fan via the GPIO pin.

To prevent the fan from going on/off repeatedly if the temp hovers at the limit,
a minimum "on time" is also set, so by default, if the fan turns on, it'll stay
on for 30 minutes, no matter if the temp drops back below the limit.

Each auxillary has a manual override switch in the UI, and if overridden in the
UI, it'll remain in the state you set.

We also include a grow light scheduler, so that you can connect your light, set
the schedule, and we'll manage it. The light has an override switch in the UI,
but that can be disabled to prevent any accidents.

=head1 HOW IT WORKS

Upon installation of this module, a new directory C<envui> will be created in
your home directory. All of the necessary pieces of code required for this web
app to run are copied into that directory. You simply change into that
directory, and run C<sudo plackup bin/app.pl>, then point your browser to
C<http://raspberry.pi:3000>. I haven't integrated it into a full-blown web
server as of yet.

There are eight auxillary channels (UI buttons that connect to GPIO pins to turn
devices on or off). Three are dedicated to specific functionality. The first
(aux1) is used for temperature sensor duties. The second, humidity sensor
duties. The third is set up to manage a single grow lamp. The remaining five
auxillaries can be set and connected to whatever you please, but these channels
do not have any logic behind them yet; they're just on or off.

Note that you must be logged in to toggle the connected devices. The default
username is C<admin> and the default password is C<admin>.

=head1 WEB UI

The UI and infrastructure behind it is in its infancy. There are vast changes
that I'll be making. Currently I have:

    - a reasonably nice menu system, with the current time displayed
    - all auxillaries are movable objects within the page
    - if objects are moved, the layout will be preserved across a refresh
    - ability to easily reset page layout to default
    - temp, humidity and light auxillary objects will be in override state if
      the state is changed in the UI (ie. automation routines will skip them)
    - the memory footprint of a long run is very manageable (7-15MB)
    - longest unchanged runtime: 178 hours
    - it's a singleton; all browsers pointed to the UI will see the same state,
      with updates every three seconds maximum
    - design is geared to a 5" LCD touchscreen for attaching to the device
      itself, but renders reasonably well on any device size
    - authentication is required for any routes that set state of any kind
    - everything is stored in a DB backend

Note that you must be logged in to toggle the connected devices. The default
username is C<admin> and the default password is C<admin>.

=head1 HOWTO



( run in 1.621 second using v1.01-cache-2.11-cpan-39bf76dae61 )