Tuesday, May 29, 2018

UPS monitoring

Here is an example of setting up a Raspberry Pi 3 to monitor a few UPSs.
Note you can also install on Windows, iOS and other Linux versions but for a UPS not near a PC, a Raspberry Pi 3 works a treat.

Install the apcupsd and chkconfig packages from the software manager. Note apcuspd works with many non APC brand UPSs like Cyber Power. 

For the first one you can use the standard files. For more than one things get a bit trickier as you need to pass parameters the built in functions do not support. Below has the added steps for adding a second, third .... UPS. Replace the 2 in apcupsd2 in each step with the number of the UPS. For first UPS just leave off the 2.
Note NISPORT 3551 is for UPS 1, 3552 for UPS 2 and so on
Note DEVICE  hiddev0 is for UPS 1, hiddev1 for UPS 2 and so on

To see which UPS is on which port use these commands
First see what ports are in use with
ls /dev/usb/hiddev*

Then for each listed run this swapping in the matching device name for hiddev0
udevadm info --attribute-walk --name=/dev/usb/hiddev0 | egrep 'manufacturer|product|serial'

mv /etc/apcupsd2/apcupsd.conf /etc/apcupsd2/apcupsd.conf.bak
vi /etc/apcupsd2/apcupsd.conf
Add lines like these
## apcupsd.conf v1.1 ##
#  for apcupsd2 release 3.14.12 (29 March 2014) - debian
# "apcupsd2" POSIX config file
DEVICE /dev/usb/hiddev1
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd2
PWRFAILDIR /etc/apcupsd2
NOLOGON disable
EVENTSFILE /var/log/apcupsd2.events
UPSCLASS standalone
UPSMODE disable
STATFILE /var/log/apcupsd2.status

vi /etc/init.d/apcupsd2
Replace the script lines with this. You should similarly alter /etc/init.d/apcupsd to match removing the 2 from the highlighted areas.


# Provides:             apcupsd2
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Should-Start:         $local_fs
# Should-Stop:          $local_fs
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Starts apcupsd2 daemon
# Description:          apcupsd2 provides UPS power management for APC products.

NAME=`basename $0`
DAEMON_OPTS="-d 9 -f ${CONFDIR}/apcupsd.conf"
DESC="UPS power management:${NAME}"

test -x $DAEMON || exit 0
test -e $CONFIG || exit 0

set -e


if [ "x$ISCONFIGURED" != "xyes" ] ;
        echo "Please check your configuration ISCONFIGURED in /etc/default/apcupsd"
        exit 0

case "$1" in
                echo "Starting $DESC: "
                rm -f ${CONFDIR}/powerfail
                PS=`ps -ef | grep ${CONFDIR}/apcupsd.conf | grep -v grep`
                if [ "$PS" = "" ]
                        echo "start-stop-daemon --start --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS"
                        start-stop-daemon --start --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS
                        sleep 1
                        $APCACCESS status -f ${CONFDIR}/apcupsd.conf
                        echo ""
                        echo "A copy of the daemon is still running.  If you just stopped it,"
                        echo "please wait about 5 seconds for it to shut down."
                        echo $PS
                        exit 0

                $APCACCESS status -f ${CONFDIR}/apcupsd.conf

                echo -n "Stopping $DESC: "
                start-stop-daemon --stop --oknodo --pidfile $PID || echo "Not Running."
                #rm -f $PID
                echo "$NAME."

                $0 stop
                sleep 10
                $0 start

                echo "Usage: $N {start|stop|restart|force-reload}" >&2
                exit 1

exit 0

Mark ready by editing master conf file
vi /etc/default/apcupsd
Change the line

Set to auto start by running
chkconfig apcupsd2 on

Lastly start it.
/etc/init.d/apcupsd2 start

If things did not work take a look at the wiki page for help debugging and / or triggering local actions on events. Note the script they show has the line
. /lib/lsb/init-functions
Odds are nothing below that line in the script gets executed due it being overridden by 
/lib/lsb/init-functions.d/40-systemd which /lib/lsb/init-functions probably pulls in as an include. Hence the custom script above.

Now you should be able to aim your monitor at the host and port to pull in the UPS stats. For instance with Homeseer's Apcupsd plugin.

Which let's you monitor and trigger events on most of these data bits.

Monday, April 23, 2018

Where is my robot maid?

This article, Amazon Has a Top-Secret Plan to Build Home Robots, is making the rounds but it is kind of depressing. (It is also depressing how many other articles are coming up in Google searches that are just book reports on the Bloomberg article without any getting new details on their own. Bot journalism I guess.) Anyway it makes it sound like we'll never get robot maids. In part because we do not want them. WTF?! I've been wanting one forever! Have you ever met someone that did not want one? OK maybe not for the quoted price but an affordable one sure. When the Hero came out back in the 1980s they seemed just around the corner. Then the whole electronics DIY market seemed to stumble there for a bit while a lot techie types moved into programming for awhile. But the dream was still alive. Google beer fetching robot for example and you get loads of links and videos like this one.

Yet despite having fairly decent voice interfaces, wide spread wireless data links, relatively cheap drones that can follow and pan you around and avoid obstacles getting home, much less self driving cars, most bots seem about as advanced as the Heroes we had back in the 1980s that had nothing but an 8 bit CPU and a floppy drive to work with. So what is the hold up? I don't need a human looking android or even something that walks on legs, which seems to be the focus these days. Show me something that looks like a Johnny 5 and can do laundry and such on its own for a few grand and I'll preorder it now.

Look at the ER1, a platform from over 15 years back now that was basically a frame that you mounted a laptop into. One of the sample tasks was waving a bottle in front of its camera and it would go get one. It was like $700 (with optional arm) plus laptop. I went to a demo they were doing at Frys, got there like 5 minutes before it was supposed to start and was told the salesman had already left because he did not think there was enough people there to make it worth the effort. If only he'd waited to see all the people that left work early to get there after he'd gone. Then I decided to just get one direct online but for some reason they decided to sell only to schools. What you won't even take my money?! Looks like they are out of biz now. Wonder why. Which goes back to my point, we had these 15 years ago. Why don't I have one that can do the laundry by now? We have hardware now that way out performs what we had back then including CPUs, cameras, recognition systems, motors and batteries so it should be simple to at least market something better than we had 15 years ago. The latest security cameras for example do face and even pet recognition of them walking through a room and only cost $299. That was SciFi 15 years ago. Another example NiCad batteries were still a thing then.

Look at this laundry folding robot that was making the news not long ago. Comes in at about $1K and you still need someone to load it? It is little more than this folding board you can get for $10. Why not make it a bit more, put some arms and a camera on it so it hang and or fold the stuff in the dryer and then move the laundry from the washer to dryer? Got room for basket it ought to be able to sort colors and whites at least well enough to make loads too. If you have room for a couple baskets you could pre-sort. Extra points if it is mobile and can be moved into the kitchen to do dishes.

Which brings me to this self proclaimed THE WORLD'S FIRST ROBOTIC KITCHEN that was in the news this week. $75K and all it does is cook and maybe the dishes. It looks like it is actually a kitchen with arms. But from the video it still looks like you have to setup the ingredients for it. They also show it closing the top loading dish washer but not how it gets the plates to put in it. It might make sense in a restaurant but you would have to be the kind rich to have a cook on staff to install one at home.  And again they go on about how life like the hands are. Why does a kitchen appliance need life like hands? How much cheaper is one with grippers and snap in tools instead? The inventor says $75K is about the same price as a standard kitchen but given the median home in the US is $326K I'm not buying it. Anyway a robot that can do the laundry would seem it least as useful plus a lot easier and cheaper to build. Not to mention retro fit, especially if it is mobile and only needs to be placed in front of the washer and dryer.

So in closing Amazon I truly hope you are going to get us something as useful as Alexa has been and not just an Alexa powered Jibo as the the article implies. We do not need an Alexa with more personality. We need one that is mobile with arms.