Getting IoT notifications on the Linux Desktop

August 12, 2023

If something important should happen with the IoT setup I’d like to know. I don’t want to spend my time on Earth checking up on machines though. I know, it’s less reliable, but I’d prefer to have the machines tell me when there’s a problem. I don’t want to be notified when things are going well.

I settled on using MQTT for device to device communications in my setup. It’s lightweight and I like the messaging model. So using it for notifications seems perfect.

Luckily the code for it was already written by David Lor. All I needed to do was create a service to run it in the background on my Linux Desktop. Here’s the script: mqtt2notifysend.sh

Linux Mint uses systemd so I used the instructions here: https://www.baeldung.com/linux/bash-daemon-script

I added a flow to my node-red setup to catch errors and send them via MQTT.

Thanks David! It works like a champ.


Shell script to rename files from United States dates to international dates

November 13, 2010

I ended up with a lot of files named using US style dates ( month-day-year.txt ). These don’t sort nicely into chronological order so I wrote a small shell script to rename them. The files are changed from “month-day-year.txt” to “20year-month-day.txt”. The extension isn’t checked and is preserved so it works with any file extension. This does require a relatively modern version of Linux/Unix bash shell.

#!/bin/bash
regex=^[0-9]\{1,2\}-[0-9]\{1,2\}-[0-9]\{1,2\}\..*
for f in `ls *`
do
 if [[ $f =~ $regex ]]; then
 m=0`expr match "$f" '\(^[0-9]\{1,2\}\)'`
 m=${m:(-2)}
 d=0`expr match "$f" '.*-\([0-9]\{1,2\}\)-.*'`
 d=${d:(-2)}
 y=0`expr match "$f" '.*-\([0-9]\{1,2\}\)\..*'`
 y=${y:(-2)}
 e=`expr match "$f" '.*\.\(.*\)$'`

 echo $f "20$y-$m-$d.$e"
 mv $f "20$y-$m-$d.$e"
 fi
done

++djs