365 lines
33 KiB
Plaintext
365 lines
33 KiB
Plaintext
|
|
Episode: 2173
|
||
|
|
Title: HPR2173: Driving a Blinkt! as an IoT device
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2173/hpr2173.mp3
|
||
|
|
Transcribed: 2025-10-18 15:17:31
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is HPR episode 2,173 entitled Driving a Blinked, and an EOT device.
|
||
|
|
It is hosted by Dave Morris and is about 39 minutes long.
|
||
|
|
The summary is, I have a Raspberry Pi nearer with a blinked.
|
||
|
|
HLEDRA I'm setting up an notification device.
|
||
|
|
This episode of HPR is brought to you by an honesthost.com.
|
||
|
|
At 15% discount on all shared hosting with the offer code HPR15, that's HPR15.
|
||
|
|
Better web hosting that's honest and fair at An Honesthost.com.
|
||
|
|
Hi everyone, this is Dave Morris. I've got a project I want to tell you about.
|
||
|
|
It's a slightly rambly project. It's probably the best way to put it.
|
||
|
|
I'll be messing around with it for a month or two now and I thought I'd better capture what I've
|
||
|
|
done so far. Otherwise it's going to just fiddle around with it. I'm going to fiddle around with it
|
||
|
|
forever and never get around to say anything. So it's based around a Raspberry Pi 0 and I bought one
|
||
|
|
of these when they first came out in December 2015. And it wasn't easy to get them because they
|
||
|
|
were very scarce but I managed to get one. I also bought a case at the same time. I like to buy
|
||
|
|
quite a lot of my Pi stuff from the Pimeroni company. That's how they pronounce it. Not Pi Meroni.
|
||
|
|
Pimeroni. I do believe. I got some 40 pin headers because there's nothing on the Pi 0 by default.
|
||
|
|
So you have to solder it yourself. So I got this. Didn't really have a tremendous number of ideas
|
||
|
|
what to do with it. And I decided to grab a device which came out a bit later called the blinked.
|
||
|
|
I don't like the name actually. It's B-L-I-N-K-T exclamation mark. It's a very strange thing to say.
|
||
|
|
But anyway, it's a device which you plug onto the GPIO pins. It's got eight RGB LEDs on it
|
||
|
|
and which are quite powerful, quite bright. And it costs £5 which is just a little more than
|
||
|
|
the 0 itself. So the plan was to turn them into some sort of status indicator so I could be alerted
|
||
|
|
to things that needed my attention. Eight things anyway. So I've called this talk this episode
|
||
|
|
driving a blinked as an IOT device. So I'm going to come on to the IOT which is internet of things.
|
||
|
|
It's not really internet of things I'm doing. It's more intranet of thing but because there's only
|
||
|
|
was only one thing and it's not. And it's just on my local network. But anyway, enough of that.
|
||
|
|
So let's talk about the setup of the Pi first of all. So I wanted to take the Pi because it's
|
||
|
|
really, really tiny the the Pi zero. I'm sure you know. I've got a photo in here. Anyway,
|
||
|
|
if you're not quite clear what it looks like. And I wanted to put the zero into some device where
|
||
|
|
I could have lights coming up and put labels alongside them to say what they meant.
|
||
|
|
And I could easily determine how important things were and that type of thing. So what I did was
|
||
|
|
was in IKEA and I noticed they have a series of picture frames which in the range called
|
||
|
|
ribber I assume you say same. But anyway, RI double BA. I've linked to it in the notes. I thought
|
||
|
|
I'd use that because it's quite deep or deep enough. It's I've given the dimensions. It's 12.5
|
||
|
|
centimeters by 17.4 and it's 3.4 centimeters deep. And it's got an internal size of 10 by 15
|
||
|
|
centimeters. It has a silver finish to when I picked up which is not the most lovely thing.
|
||
|
|
It's a bit garish but whatever. It's got glass in it and then behind that there's a piece of
|
||
|
|
hard board. I realized that hard board is a UK term. It's high density fiber board I think it's
|
||
|
|
called in the USA. It's sort of thing used for the backings of photos and that type of stuff.
|
||
|
|
I'd also got a fixture for hanging it and thing for standing it which I took off pretty quickly.
|
||
|
|
So what I wanted to do was to mount the zero behind the hard board. I drill holes in it so that
|
||
|
|
the blinked lights would shine through it. And I wanted the zero in its case to be held on
|
||
|
|
on the back of it. I kept wondering what was the best way of doing this. I had ideas of using a big
|
||
|
|
chunk of MDF the right size and scooping out a hollow into it to put the pie. But I don't have
|
||
|
|
the tools to do that really. There's no way I wanted to be chiseling away at MDF. It's horrible
|
||
|
|
material to use. And so I went with this. Now the pimmerony case that I've got is the early model
|
||
|
|
and the way they built this was to it's pretty much the same size as the pie zero and the bolts
|
||
|
|
hold it together go through the board. And as a consequence the bolts that you get with it are
|
||
|
|
size M2.5 which is quite an unusual size I find. I don't see it very often. Certainly not in the big
|
||
|
|
box hardware stores around here. Their later case is slightly bigger and the bolts go
|
||
|
|
through outside the periphery of the case. Outside the periphery of the board I mean and they've
|
||
|
|
used M3 bolts which are far more easily obtained. Anyway I managed to find a source of M2.5 20
|
||
|
|
millimeter nylon bolts to do this job. With the help of pimmerony I should say they I was I asked
|
||
|
|
them questions about what sizes these were and they and said I've had difficulty finding anything
|
||
|
|
and they pointed out somebody selling them on eBay which I then went and bought. So they're
|
||
|
|
amazingly helpful people. So what I did was I made a design in ink scape which I could use
|
||
|
|
first of all as a template for drilling the holes in this board and then I could use the same
|
||
|
|
thing or a similar thing a fresh piece of paper not the one with the holes drilled in it and I
|
||
|
|
could put labels on it and the fact that it'd be a sheet of paper over the holes in the hard board
|
||
|
|
would mean that it would act as a diffuser making it slightly less bright which I thought was a
|
||
|
|
good idea actually. It also would hide the horrible holes I drilled in this hard board because it's
|
||
|
|
not nice material to work with and obviously it's got room for the bits of text and so on. I found
|
||
|
|
that getting everything in the right position in the template under ink scape was quite difficult
|
||
|
|
because I'm a bit of a newbie with ink scape but I've certainly learnt a lot along the way.
|
||
|
|
I've shared the SVG file with this show if in case you want to mess around with it or look at it
|
||
|
|
or anything. Probably not relevant to you unless you've got all the same components that I have
|
||
|
|
but whatever. So I've got some pictures here of what I came up with. The first one is of the
|
||
|
|
the pie itself in its case. It's not got all the bolts in because I've taken it out of the frame
|
||
|
|
to do this picture. It's on and one of the LEDs is on. Number six is on and the camera had some
|
||
|
|
difficulties with that. Got a little bit upset as to how bright it was. I've shown the pie fixed
|
||
|
|
to the back of the hard board which has got a glossy black background to it and you'll see
|
||
|
|
you might be able to see from there that the the blinked LEDs are just held pressed against the
|
||
|
|
holes. So they're pretty well lined up not perfectly but they're not bad. There's another picture
|
||
|
|
of it from a better angle. You can see the back of the hard board looks pretty scabby because I
|
||
|
|
ripped off the hanging attachments but you can see the pie and it's bolted through. Now to the left
|
||
|
|
of the pie there's a couple of bits of hardwood which I cut off the stand bit that I'd ripped off
|
||
|
|
and I needed them because the whole face of the pie is not level because it's a it's level
|
||
|
|
across the case and then the blinked sits on top effectively of the case over the GPIO. So I put
|
||
|
|
these in a shims to level it all out and that took a little bit of filling around. Since I took
|
||
|
|
this picture I actually drilled holes in the in the shims so I could line them up with the bolts.
|
||
|
|
There's a picture of the front face of this hardboard looking messy. I stuck the template on it
|
||
|
|
and then couldn't get it off again so you can see there's bits of template all over it but
|
||
|
|
doesn't matter because it's going to be covered up and then there's a picture of the the whole
|
||
|
|
stuff in the picture frame. I made a little wire holding doodad. I didn't want to use the
|
||
|
|
little tabs that came as part of the frame because they're so fiddly to open and close so my
|
||
|
|
little bit of wire a little bit longer than the width of the case holded in effectively enough.
|
||
|
|
I drilled a hole through the case to do this and drilling through this stuff is a nightmare
|
||
|
|
because it's it's MDF and it's just it's really hard to get clean holes through it and you see
|
||
|
|
the bed duct tape stuck over the the tattiness of the hole and I would not have put the hole there
|
||
|
|
if I'd realized the way I was going to do it but anyway whatever next one will be not much
|
||
|
|
much nicer. There's ever a next one. Finally then the picture says there's a picture with showing
|
||
|
|
the front of this thing with all its legends and stuff and a wonderful reflection of the camera
|
||
|
|
taking it because the light wasn't perfect when I did this. Anyway enough of that that was the setup
|
||
|
|
of the device so I didn't say that the pie has a wireless dongle in it so all it needs is
|
||
|
|
a power lead. So this blinked device is quite well documented on the pimmerony site. There's loads of
|
||
|
|
hints and tips on how to use it and there's a lot of test python code which you can get
|
||
|
|
from there from by following links on their site and they they point to their GitHub repository
|
||
|
|
where all the code is so that's pretty good it you can mess around it. I'm not much for python
|
||
|
|
user. I must admit to being a little bit un-inthusiastic about python because it just with my background
|
||
|
|
in programming such as it is. Python doesn't feel right to me with all this indentation nonsense
|
||
|
|
but this is just a sort of fixed stance that my brain has wanted to take so many trying to
|
||
|
|
stop myself doing this. So pythons are way to go I think with this. So while I was preparing these
|
||
|
|
notes I remembered that I had been a bit bothered about the way the the pie with rasbian is set up
|
||
|
|
with regard to security. As you you can figure up your SD card and and so on and so forth you end up
|
||
|
|
with a username of pypy and it has the default password of raspberry. Well that's all fine and
|
||
|
|
wonderful but there's a lot of stuff that assumes that you he left this as it is and the way this
|
||
|
|
account is is set up it's it can run pseudo without a password so it's effectively a root account
|
||
|
|
to all intents and purposes and the password is well known it's known by everybody's ever touched
|
||
|
|
or by. So this ain't secure to my mind as somebody who used to work in a university where we were
|
||
|
|
quite fussy about security because we were being attacked by our students all the time then this
|
||
|
|
really upsets me. So what I normally do is I disable this account and change its password or something
|
||
|
|
I haven't actually deleted it in any instance because I'm not sure how many things actually
|
||
|
|
rely on it but I make sure it's pretty well locked away and I also take it out of the etc. pseudo as
|
||
|
|
file using a vi pseudo to to edit it and disable its pseudo access then I create an account for myself
|
||
|
|
which are normally called Dave and I give it a much more complicated password managing them with
|
||
|
|
key pass x is what I use for my password safe then I give it pseudo access but I have I want a
|
||
|
|
password to be provided via account's password obviously. So when you use the blinked then the
|
||
|
|
software assumes that in order to get access to the GPIO to write to it and change the LEDs and
|
||
|
|
stuff you need to run as a route and this is because the device driver that runs the GPIO works
|
||
|
|
through the proc file system I don't think it is but it's all devices are mapped to pseudo files and
|
||
|
|
directories in Linux and when you look at slash sys slash class slash GPIO for example the
|
||
|
|
directory that that manages all this you find that they're owned by user root and group GPIO.
|
||
|
|
So I looked for ways in which I could use the GPIO without using pseudo for everything because
|
||
|
|
it just gets really messy or you take away all the security and let anybody do it which I also
|
||
|
|
find wrong. I didn't find a clear answer how to do this I looked and looked and looked nobody
|
||
|
|
seemed to have come up with a very simplest simple and easily implemented way of doing this which
|
||
|
|
is a bit surprising. When I was tackling a project with a pie a while ago I did a show on this
|
||
|
|
making a print server, cups print server and scanner driver on a pie. I remember I had to give
|
||
|
|
the account access to a particular group. I've got what it was now but it's in the documentation.
|
||
|
|
So I thought I could probably do the same thing here so I gave user Dave access to the GPIO group
|
||
|
|
which is done through the user mod command, user mod space hyphen capital G space GPIO in
|
||
|
|
lowercase space then the account name Dave and when I done that I found I could use the GPIO
|
||
|
|
without any problems. Now I wish this was more clearly document and maybe it is now it was
|
||
|
|
a month or two that I looked ago that I looked at this maybe it's better now and maybe it's coming
|
||
|
|
because I think people are generally commenting on this. I've heard other people saying that this
|
||
|
|
whole business of pie and raspberry is too insecure. Anyway whatever I think people should be made
|
||
|
|
aware of this and the process of learning use of raspberry pie should include some basic security
|
||
|
|
practices and so on. People should understand the issues a little bit better than they do. I did
|
||
|
|
note here in the in the long notes and of course there's long notes here which I usually forget
|
||
|
|
to say but you probably have worked that out of yourself. The user pie PI also has GPIO membership
|
||
|
|
and I demonstrated this by using the command id space pie which returns all the all the group
|
||
|
|
UIDGID and group membership of a given user. I pipe that into a command fold which comes pre-installed
|
||
|
|
on raspberry and which is a thing which lets you wrap long lines. If I didn't do that then this would
|
||
|
|
all come out in one very long line and the markdown system I use here would get upset about it
|
||
|
|
you wouldn't be able to read it. After that digression let's talk about how how I wanted to use this
|
||
|
|
communications device, this notification device. So here it is sitting on a shelf. I'm sitting at my
|
||
|
|
workstation here with my main desktop machine and it's an IKEA computer desk which has a sort of
|
||
|
|
arch thing over the monitor. It's going to go actually. I'm going to chop that and build something
|
||
|
|
better but for the moment there's a sort of shelfy thing on which this picture frame exists and
|
||
|
|
there's plugged into it and nearby outlet. So how do I tell it to turn on a light? What's the question?
|
||
|
|
So I know that there are scripts I can run on the zero that will switch the LED's on and
|
||
|
|
often change color and so forth but I wanted to communicate with it from other machines. I didn't
|
||
|
|
want to... I knew I could have written something where I wrote something that listened on a port
|
||
|
|
and took commands and did things but I didn't really want to be writing my own remote control
|
||
|
|
infrastructure so I looked around to see what else was possible knowing that there must be tons of
|
||
|
|
stuff. First thing I came upon having listened to a recent episode of Changelog podcast was a
|
||
|
|
queuing system called ZeroMQ. I've heard about that before. I looked at it and actually bought
|
||
|
|
the book because I can see possibilities for using it but it seemed like overkill for this one.
|
||
|
|
It's a very sort of enterprise level tool and quite complex. So I next looked at MQTT. Now MQTT
|
||
|
|
I'd heard about at OgCamp 2012 there was a talk and this is a protocol which is being used
|
||
|
|
in Internet of Things stuff I believe. I don't know of any instances where it is but I'm told
|
||
|
|
that that's the case. There's an implementation of the MQTT protocol in a system called Mosquito
|
||
|
|
2Ts MOSQI TTO. There's links to all of this stuff in the notes. I've seen it but it's easy to install
|
||
|
|
Mosquito server and clients on the Pi Zero and it's just it was just an app getting install Mosquito
|
||
|
|
and Mosquito hyphen clients. So I got the server and clients. The server was already set up to run
|
||
|
|
at boot time and there's a service command I think which lets me mess around with it. I haven't
|
||
|
|
done much messing with it. It just runs. The clients that I got consist of the commands Mosquito
|
||
|
|
underscore sub and Mosquito underscore pub. So let's talk about what MQTT does. The design
|
||
|
|
is based around a so-called published subscriber pub sub model. This requires a message broker whose
|
||
|
|
job it is to take messages from or receive messages from a publisher and pass them to a subscriber.
|
||
|
|
It knows which messages to send where by filtering them and it bases it's filtering on an attribute
|
||
|
|
called a topic. So messages have topics. There are things that send them, his message and it's
|
||
|
|
got this topic. There are things the subscribers that listen to them, listen for them and they say
|
||
|
|
I'm here to get messages with this particular topic. There's nothing to stop you having
|
||
|
|
publishers that publish stuff and there's nobody listening. It'll just be thrown away. So it's all
|
||
|
|
quite simple and lightweight. So a typical case might be a publisher. You might have a
|
||
|
|
temperature sensor, an intelligent temperature sensor that can send IP messages or you might have
|
||
|
|
a doorbell which when pressed sends an IP message using this protocol and the subscriber might be
|
||
|
|
something controlling the heating system which is listening for temperature messages
|
||
|
|
or you might have an audio or visual alert system receiving the doorbell messages and doing
|
||
|
|
something with them. So that's you probably hear where all this stuff. That's the sort of model
|
||
|
|
that the internet of things is using. The only thing it though is that in many cases the intermediary
|
||
|
|
for all of this, the message transport level, the stuff that's doing the messaging is not
|
||
|
|
local to you. It's on the internet somewhere. So if you've got a cloud, you've got a nest thermostat
|
||
|
|
then it's talking to the nest service as far as I'm aware and if you've got a, is it
|
||
|
|
Philips Hue light, the ones that you can control over the internet, then they're receiving commands
|
||
|
|
from their base on the internet. So the Mosquito broker then is an MQTT message broker,
|
||
|
|
the server I was talking about earlier on. And the commands Mosquito Pub and Mosquito Sub are
|
||
|
|
examples of a publisher and a subscriber. Now at the Python level there's a library called
|
||
|
|
PAHOMQTT PAHO hyphen MQTT which you can use to write scripts and I've given example how you could
|
||
|
|
install it using PIP, PIP install PAHOMQTT running under pseudo. So in the Pimironi examples they
|
||
|
|
provide an example script which they call MQTT.py which demonstrates the use of this library which
|
||
|
|
is pretty wonderful. So I took this and modified it to make a first version of a listener, a subscriber
|
||
|
|
script. I renamed it blinked underscore client.py and there's a version available with this show if
|
||
|
|
you want to look at it. It's a temporary, it's a sort of in development script so don't take it
|
||
|
|
as definitive in any way. You're welcome to do whatever you want with it, a similar way to the
|
||
|
|
Pimironi thing I'm sure. Anyway I modified it to connect to localhost because I'm running it on
|
||
|
|
py0 and that's where the Mosquito broker is running. So it's a subscriber, it's an MQTT subscriber
|
||
|
|
and it's sitting there listening for messages. I left the topic as it was in the original script and
|
||
|
|
it was Pimironi slash blinked. I don't know what yeah there's a hierarchy of naming in the topic
|
||
|
|
with it's a bit like a file path. So Pimironi slash blinked and you can actually specify topics
|
||
|
|
as Pimironi slash asterisk to get everything which is under the prefix Pimironi I think. But
|
||
|
|
I've not really delved into this much. You can read up more about this if you want to from the
|
||
|
|
various links that I've put in the notes. The standard port that's used is 1883 and I've just
|
||
|
|
continued with that for the moment. So this script runs in the background on thepy0. So I just
|
||
|
|
simply added a crontab entry which starts it up when the pie is rebooted. I don't know if you
|
||
|
|
know but in a crontab file there's an entry you can put which starts at sign reboot space and
|
||
|
|
then the path to the script which in my case is dollar home, capitals in the capital letters slash
|
||
|
|
blinktie underscore client.py with an ampersand on the end. So at reboot it will fire this thing up
|
||
|
|
and just leave it running in the background forever. So the script which is this adaptation as I
|
||
|
|
said uses the same methods as the original Pimironi design and it expects messages which contain
|
||
|
|
strings which have the form RGB comma and then a number for the pixel then comma then three numbers
|
||
|
|
separated by commas which represent the RGB color values decimal numbers. So RGB comma 1 comma 255 comma
|
||
|
|
0 comma 255 is specifying that you want LED number 1 they start from 0 to have a red value of 255
|
||
|
|
which is full intensity red a green value of 0 no green at all and a blue value of 255. This is
|
||
|
|
an 8-bit value in each case because it's actually a hex a six digit hex string with the other
|
||
|
|
way of looking at it. So that will set it to that color combination. There's also a CLR message
|
||
|
|
which will clear all the LEDs on the blinkt. They've all still carried over the algorithm which if
|
||
|
|
the pixel value is an asterisk then all pixels are set to that particular color. I'm going to change
|
||
|
|
this but that's what it's doing at the moment. So I've got a mechanism then on the pie zero where
|
||
|
|
I can tell it to switch on a light or switch off a light whatever any of the LEDs can be turned
|
||
|
|
on or off. So I then came up with the first publisher. What I've been doing before this was I've
|
||
|
|
been running a pair of scripts on my desktop machine and these helped me with the process of
|
||
|
|
moderating comments on the HPR website. I've taken that job on from Ken to he's got enough on his
|
||
|
|
plate and so I just need to keep an eye out when a new comment comes in which I either go and
|
||
|
|
look at the website to see is there anything new or I run this script. So the original one was a
|
||
|
|
bash script which was run from cron every 15 minutes. I called this cron job underscore comments.
|
||
|
|
All my cron called scripts I start with cron job just to make it clear what they are. It's included
|
||
|
|
in the with this episode. It runs a purl script which I called scrape underscore comments which
|
||
|
|
goes to a particular page on the HPR website and detect if there are any new comments which require
|
||
|
|
attention. This this page is available to you. I won't share the scrape comments script at the
|
||
|
|
moment anyway but on this page there's quite a lot of statistics. I haven't actually noted what it
|
||
|
|
is. I should maybe add this to the to the notes but on it there's a line that says comments
|
||
|
|
requiring attention or something. It's followed by a number. So I simply look for that and pick up
|
||
|
|
the number. So it runs this scrape script the purl script. If it finds anything it returns or whatever
|
||
|
|
it does it returns a number saying how many comments need attention so it can be zero or any any
|
||
|
|
other number. So if it's non zero then I simply in the bash script call mosquito underscore pub
|
||
|
|
and I tell it that the topic is pymirony slash blinked and the message is one of these RGB blah blah blah
|
||
|
|
thing. So you see here it says there's an example of it here RGB comma dollar LED comma 255 comma 255 comma zero.
|
||
|
|
So that set that switches on the red and the green colors on the LED nominated by whatever the
|
||
|
|
value of dollar LED is. So that sends a message. So this is running on the pi zero I didn't
|
||
|
|
to say that and it sends a message to the MQTT broker and causes that LED to show a yellowish color
|
||
|
|
to yellowish because it's not very clear yellow but then it's a combination of two LEDs. If there's
|
||
|
|
nothing to do then it does an equivalent mosquito pub command where it sets all the RGB values to zero
|
||
|
|
and turns the pixel off. So that's what I have at the moment that is a thing that running on the
|
||
|
|
pi zero it's looking at the website and it's setting LED one actually to this yellow color and that
|
||
|
|
says there's work to be done I go and do the work it then looks again in 15 minutes and says oh there's
|
||
|
|
nothing to do now so it turns the light off again so it's pretty simple but it's some it's fun.
|
||
|
|
So what I want to do with the the listener script so far is to smarten it up quite a lot I
|
||
|
|
probably change the interface but have something quite similar because it's a nice idea I look
|
||
|
|
the way it's signed. I'd very much like to be able to blink one of these lights and maybe just
|
||
|
|
change color briefly and then revert to the previous color or to flash it on and off and so on but
|
||
|
|
there's quite a lot of issues around that that need some need some further work so I might do
|
||
|
|
another show about this if I once I once I've got that done at the moment I've got something that
|
||
|
|
works so I'm happy about that so how else am I using this notification system now that I've got it
|
||
|
|
I've got another mechanism where when a new HBR show appears then I am alerted and I've mentioned
|
||
|
|
this before in the context of the blink stick I'm all into indicator lights all of the plays show
|
||
|
|
number 1971 I talked about building the blink stick and what I'm using it for so I've got a thing
|
||
|
|
which another crown job script that runs every 30 minutes and it scrapes the the website the main
|
||
|
|
website that shows the queue and notices if there are any new shows being in the state being processed
|
||
|
|
and if there are and that particular show number has not yet been processed locally because this
|
||
|
|
this thing also looks at what I've done as a consequence of noticing these things it will it turns
|
||
|
|
the blink stick on red but I added a added code to it to also switch on light zero on the blinked
|
||
|
|
on the pie zero and when I dealt with that particular thing what I do is I grab the show notes
|
||
|
|
from the shows and process them and turn them into HTML for adding to the show and once I've done
|
||
|
|
that then the code that's looking at this script notices that I've done the necessary work and
|
||
|
|
turns the lights off turns the blinked blink stick and the blinked off so that's first thing I
|
||
|
|
am using but I'm going to phase out the blink stick in this context to think and use the
|
||
|
|
the nice notification thingy instead so I've recently added a male notification thing to it
|
||
|
|
I use thunderbird to handle my male on my desktop and I've got a bunch of male accounts
|
||
|
|
which it connects to and pulls stuff down there's loads of filters in thunderbird to move
|
||
|
|
incoming male into folders or chuck it into the spam bucket whatever in particular I've got
|
||
|
|
an add-on a thunderbird add-on called male box alert which can do things to alert me to important
|
||
|
|
male that needs particular attention so this thing can do various actions when male arrives in a
|
||
|
|
folder so this is not just male who arrive in the inbox is male being filtered from the inbox into
|
||
|
|
a folder and so I've got sounds which I've grabbed off the free sound org site and edited
|
||
|
|
down something more manageable and so on I've got pop-up displays and that type of thing my
|
||
|
|
box alert tool can also run a script so I've written one just a simple bash script which uses
|
||
|
|
mosquito pub to make led6 on the pi0 system to engreen and a moment this is just running when I get
|
||
|
|
messages from my son they get dropped into into the appropriate folder and the light comes on
|
||
|
|
so so how do I turn the light off again obviously I can turn it off manually remotely as well by
|
||
|
|
using the mosquito pub come on but I want to be able to do it automatically at the moment I'm
|
||
|
|
working on a script which goes and checks a mailbox because a male folder a male folder as
|
||
|
|
you'd say a male folder which is that's a male concept it's actually a file and it's a file
|
||
|
|
containing male in a standard format called inbox format so I've got tools which which I
|
||
|
|
which I can pass this with a pulse script so I'm experimenting with this it passes the
|
||
|
|
mailbox file and it scans it to see if there are any unseen messages in and since when I go and
|
||
|
|
check see what the message was about it turns from unseen to to read then this can detect it and
|
||
|
|
if it says that if it finds there's no unread messages in them the mailbox it will turn the
|
||
|
|
light off and that couldn't be run from cron it's not at the moment and finished it it's also
|
||
|
|
fairly heavy because if there's a lot of messages in the folder it's going to have to pause them all
|
||
|
|
to find out which one is which ones are read or unread so if you've got thousands messages that's
|
||
|
|
not really a very good solution there isn't anything else that I know of it obviously there's an
|
||
|
|
event in thunderbird which will be triggered when a message goes from unread to read but that doesn't
|
||
|
|
seem to be hookable in any in any sin if I were running some other male system maybe something
|
||
|
|
like mutt and maybe there are better ways of writing hooks for these events I've certainly used
|
||
|
|
male systems in the past where I have written hooks into the the male client to enable me to do
|
||
|
|
these sorts of things but that was going back two days long ago I think I've got a plan for an
|
||
|
|
IRC notify but I haven't started on that yet I use wechat to to contact IRC IRC client and it has
|
||
|
|
got some quite powerful plug-in capabilities so state changes in there can be can cause events
|
||
|
|
to happen the wechat running on another pie and I'm looking at the possibility of writing a plug-in
|
||
|
|
which with which I can use a mosquito pub type call and with that switch on my light on the
|
||
|
|
notification system to say somebody yes just spoken to you in IRC because it would be nice if I
|
||
|
|
if if I had the ability to blink the light I could you know there would hold dash of these things
|
||
|
|
coming in and I could flash it according to the number that were there whatever that's some project
|
||
|
|
for the future so that's nearly all I have to say about this particular project except that
|
||
|
|
cause I got into muskito a bit I've also installed it on my desktop which obviously I had to
|
||
|
|
do in order to be able to talk to the pie zero and it occurred to me I could write another listener
|
||
|
|
on there and use it to interface to the blink stick which is plugged into the the desktop is plugged
|
||
|
|
into a usb hub connected to the desktop machine so I found some work that had been done on the
|
||
|
|
blink stick website which I've pointed to it's a moderately old thing it's dated 2013
|
||
|
|
this protocol has been around for a while I'm using this as a development platform for my
|
||
|
|
python ideas and also get better into python scripting the original script needed some changes
|
||
|
|
because the way the python library works and what it's called and stuff have changed in the
|
||
|
|
interim so what I'm doing here it's just a silly thing really every 30 minutes on the pie zero
|
||
|
|
a cron job runs which calls muskito pub and sends a message to the desktop assuming dead
|
||
|
|
up on the desktop it's not on all day not all night anyway not on 24 hours of turn it off
|
||
|
|
and on in the morning so all it does is every 30 minutes it flashes the blink stick and it
|
||
|
|
that's just because I want to be sure that the pie zero is up and running and doing everything
|
||
|
|
it should what I should really do is to have maybe some means of seeing the the on light on the
|
||
|
|
the thing you can't see it because it's inside this frame but I need some sort of indicated to say
|
||
|
|
I'm alive and well and this was a solution that I came up with it's really just a temporary hack
|
||
|
|
that I can use the reason I wanted to do this because I found in the early days the zero would
|
||
|
|
occasionally vanish from the wi-fi network and I'm not sure if that's an issue with my router or
|
||
|
|
what it is the moment I'm getting a light flashing every 30 minutes and that's that's working fine
|
||
|
|
I'm happy with that and it's also give me a chance to play with the the listener on the
|
||
|
|
workstation and I can try developing blinky things on that and so on and so forth so just to wind up
|
||
|
|
I don't have a lot of interest in the internet of things when it means paying a lot of money for
|
||
|
|
special light bulbs and temperatures sensors and all that sort of stuff and it requires internet
|
||
|
|
access and a remote server etc etc but I'm quite excited about doing this at the level and I've
|
||
|
|
just been describing things where I have full control over it all I found that this MQTT
|
||
|
|
protocol in the shape of the Mosquito server is really nice to set up and simple and has great
|
||
|
|
potential for building into communicating system since the zero is running 24-7 I have to admit
|
||
|
|
that on the odd occasions I've got up in the middle of the night for whatever reason come down
|
||
|
|
stairs to find a glowing yellow light it'd be even worse it was flashing probably I see the new
|
||
|
|
there's a new HPR comment has arrived in while I was asleep it's slightly eerie but it's also
|
||
|
|
quite cool I should say I don't action at that point I haven't put all these various odds and
|
||
|
|
ends of code up on the get repository like I normally do what I'll do is once I've got something I
|
||
|
|
I'm happy with I will share them but to share you know stuff that's in very much in the state of
|
||
|
|
flux doesn't seem to be entirely a good thing final point was that when I started doing this stuff
|
||
|
|
and I was messing started messing with Mosquito and MQTT I noticed that Jezra had started something
|
||
|
|
he mentioned it on Gnosocial and I was asked him about what he was doing and I've indicated
|
||
|
|
he's I've linked to his project where he built a rather nice looking light which is um
|
||
|
|
controllable through the MQTT protocol from his phone I think he ended up doing but check it out
|
||
|
|
for yourself he's a much more experienced Python programmer than I am so if you're interested in
|
||
|
|
doing any of this stuff yourself you'd be you'd do well to kind of look and see what Jezra has done
|
||
|
|
so you could learn from from his his stuff as can I of course so thank you Jezra for making it
|
||
|
|
available so that's it I hope you found that useful and not too long okay bye now
|
||
|
|
you've been listening to Heka Public Radio at Heka Public Radio dot org we are a community podcast
|
||
|
|
network that releases shows every weekday Monday through Friday today's show like all our shows
|
||
|
|
was contributed by an HBR listener like yourself if you ever thought of recording a podcast
|
||
|
|
then click on our contribute link to find out how easy it really is
|
||
|
|
Heka Public Radio was founded by the digital dog pound and the infonomicum computer club
|
||
|
|
and it's part of the binary revolution at binrev.com if you have comments on today's show
|
||
|
|
please email the host directly leave a comment on the website or record a follow-up episode yourself
|
||
|
|
unless otherwise stated today's show is released on the creative comments
|
||
|
|
attribution share a light 3.0 license
|