so what is the run this is Fabi here, today we're here for a video that's
going to be a little bit different today
I'm going to show you how to use a
Raspberry Pi, whatever version you have
lying around you, can buy one to track
internet outages and when your power
goes out. these events you can easily
track with something like this and a
program I coded and so today I'm going
to show you how to easily install this
now you can find the source code on
github I'm going to link in the
description down below but the purpose
of this video is to show you guys the
easiest way that you can install this
script basically on your raspberry don't
worry it's not going to be difficult
it's only going to be a few linux
commands and i'm going to show you those
so you only have to copy and paste them
and it's going to go over smoothly if
you guys don't have one of these
computers I highly recommend getting one
of them now it's not necessary to get
one of these Raspberry Pi fours you can
also get one of the Raspberry Pi zeroes
those are really cheap about ten dollars
I believe for the wireless version which
is the one I recommend but if you want
to get into the nitty-gritty and have
some horsepower to spare basically you
can get one of these it even has dual
HDMI output so this is basically a mini
computer over on this side you can now
see some examples of the notifications
you would get from running my
application you can choose between
getting notifications in pushbullet
which is an application you can download
from the App Store that just pushes
notifications to you and there's a
really nice API that I'm using to just
send over notifications to pushbullet to
your phone or you can of course go with
a more straightforward option choosing
the email route so you can basically
receive the notification on your email
address now let's jump over to our
raspberry and run the commands so your
raspberry can turn into an Internet or
power outage detector alright here we
are now some of you might be thinking
why am I on the Mac well I'm actually on
a Mac but I'm also on the Raspberry Pi
because I'm connected via a secure shell
to my Raspberry Pi so this one is
connected only to the power you can see
the USBC power cable being connected but
nothing else so this is not connected to
a monitor it's not connected to a mouse
or keyboard but I'm controlling the
rasberry through commands sent from my
Mac so this is much easier when you're
going through the setup process you
don't have to connect it to a monitor
and it's just really easier to do what
you have to do with your device so here
we have a clean
terminal command now the first thing you
want to do is actually update your
system even if you just installed your
raspbian there's always going to be new
updates for packages that are installed
for this purpose we are going to do sudo
apt update first and this is going to
take a little while but then we're going
to upgrade all of our packages this just
updates the list of all the packages but
now we are actually going to update all
of the packages that are not up-to-date
so we are going to do that with sudo apt
full - upgrade let it run and we are
going to be back when it's all done
before we go and grab a cup of coffee we
do have to say that we are ok with the
fact that this upgrade is going to take
up more space on our discs by the way
something that I forgot to mention is
the fact that this will work with either
raspbian light so the command-line
interface version of raspbian OS or with
the normal desktop sort of interface a
version of raspbian so it doesn't matter
which version of raspbian you install
this will work either way this will also
work on other Linux variants or flavors
but that is not the purpose of this
video the purpose is the fact that you
can actually run something that doesn't
consume a lot of power and it gets you
good information with the minimal power
consumption so that's the whole thing
with this video I can't make this run on
Windows and I probably will at some
point but for now it's just not what I
envisioned this script to be because
it's not feasible to run your Windows
computer 24/7 as it is running the
Raspberry Pi so now that this is done
we're going to get into the nitty-gritty
first of all we need to do sudo apt-get
install Python 3
-
then now this is going to install Python
three virtual environments because with
Python you have a lot of dependencies
between packages and you want to make
them sort of sandbox you want each and
every application to be sandbox into its
own virtual environment where you can
satisfy all of these requirements
without messing with some other app that
might be using Python so that's exactly
what I'm installed here we installed
pythons way of creating these sort of
virtual environments alright so now we
can make our directory where the
application is going to go so mkdir
which stands for make directory and
we're going to call it let's say Python
you can call this whatever you want
alright so now if we type LS it's going
to show us our directory we are going to
go into that directory with CD so change
directory python by the way you can also
type in just py and then tap the tab
button on your keyboard and it's going
to automate it for you and now that
we're in this directory we can actually
create our own virtual environment so to
do now we just have to type python 3 - m
then 4 which is basically the name of
the thing which is installed and then we
are going to name the virtual
environment just then it doesn't matter
what you name it you just have to
remember what you actually named it
alright so now that it's created we have
to activate it and the syntax to do that
is really simple you just type in dot
space then so the name that you just
chose before bin slash activate there we
go when you can see in the left side
that it shows us between those brackets
the virtual environment is now activated
so now that it's activated we can go
ahead and install the Python script we
do that by typing pip so pip is
basically pythons package manager you
can use this to install all sorts of
packages you can find a lot of packages
online and it's really versatile so we
are going to do pip install outage -
detector
you do have to be paying attention to
the upper case of outage and detector
because otherwise it's not going to work
then you press ENTER and you're going to
have a little bit to wait just so that
it downloads all of the dependencies so
just like I told you most of the scripts
that are out there depend on some other
packages and so that's exactly what my
script does right now it gets all of the
packages installed that it has to have
installed in order for the application
to run so now that the application has
installed we can type in outage detector
or we can just type in out press the tab
key and it all completes so outage
underscore detectors basically what you
have to type if you don't want to do the
outer complete thing then you type in -
- in it
so from initialization stands for
installation then you type in enter and
now you have to choose which way you
want to configure this app to run so you
can configure it to either send you push
notifications to pushbullet
or just regular mails so we are going to
first of all go the push notification
routes so let's type in notification now
you do have to pay attention I actually
write a notification not push
notification you have to pay attention
and write them exactly this way so
notification now it's going to ask us
for our pushbullet API key I'm going to
put a link in the description down below
- pushbullet site where you can actually
generate one of these keys it's easy to
do you just need an account and it only
takes a few minutes actually have it
copied in my clipboard I'm just going to
paste it into here run it's now going to
try and send me a push notification and
I just got actually a notification on my
on my watch it does just to make sure
that the API key is valid and it works
and that's what it just did
you can now type in a quick description
of where the location is going to be
where your raspberry is going to be
located so I'm just going to type in
home
and then it's going to ask me if I want
to set up the application to run
automatically now I do want to do this
and I do encourage you guys to do this
you only think it does is it creates a
sort of automation with a cron which is
the task scheduler for Linux and it
makes the application run every five
minutes just so that it can have the
last time stamp of when your internet or
power was still running so that it can
send you useful information when either
the power or the internet goes out so we
are going to type in yes now and there
we go you have nothing more to do than
this now the application is all up and
running and you can test it by either
unplugging the raspberry and plugging
back in again or turning off and on your
router we're going to do this one more
time just so that I can show you how to
actually configure it for the mail
notifications so I'm going to type in
the same thing again
I'll just detector - - in it now it's
going to tell us that it already
detected one configuration file but we
can override this by typing yes meaning
that we'd like to reconfigure the script
we are going to type in mail now we have
to type in the email address that is
going to be the sender because you do
have to have a sender and a receiver I
can't just send you mails from my email
address is going to have to be one of
your mails to one of your other males it
can be the same mail as well it doesn't
have to be a different mail but we are
going to type in my designated email
address for the disorder stuff so let's
type it in okay I have to type in my
password now don't worry this is not
stored in plain text I'm actually using
one of the packages developed for Python
so you can securely store the passwords
in the key vault of the device you're
using so let's type in the password and
now we have to type in the receiver of
these notifications so the email address
on which you want to get the
notifications whenever the power or the
internet goes out as you can see it also
sent a mail right now just to check if
the mailbox is active and I'm going to
type in my home address or basically the
location where the raspberry is going to
be I'm going to just type in home for
now
and you can type in yes now for the same
sort of scheduling of the application
and boom you're done now that we are
done I just have to tell you about the
limitation of this which is basically
with internet connection so because
we're running this every five minutes
it's going to run at let's say four pm
four oh five four ten you get the idea
of it if the internet goes out at 4:01
it comes back on at four over two this
is not going to detect that it's pretty
hard to just continuously paint the
internet connection to see if it's
actually up and running I could move
this so that it runs every minute but
I'm not sure if it would be any helpful
for me or for anyone else but if you
guys actually want that I can make the
schedule link configurable so you can
type it just how often you want this
application to run now this is not the
problem with power outages because the
application is also scheduled to run
every time the system boots up so
whenever it boots up it's going to send
you a push notification that there has
been a power outage because again this
is meant to run 24/7 if the system has
no more power it's just meant to assume
that there has been a power outage
anyways rest assured that there's going
to be bug fixes in the future if you
guys find any bugs please let me know
there's going to be more features
implemented and if you have any
suggestions for these sort of features
that you want to see make sure to leave
them in the comment section down below
I'm going to implement all of the things
that I believe makes sense for such an
application anyways guys thank you for
watching this has been a video that I
wanted to make for a while I'm trying to
sort of blend in the YouTube side of
things with programming because these
are two things that I enjoy doing and I
think that there might be some of you
that are going to be benefiting from
something like this again this is easy
to run don't let the terminal scare you
it's just a few easy commands I'm going
to also put them in the comment section
down below and you can follow step by
step so thank you guys for watching make
sure to LIKE this video share with your
friends on Facebook and subscribe it
does help me grow on YouTube again guys
stay awesome and stay tuned peace out
guys peace
