The python script checks the service status every five minutes and shows it with colors on the unicorn phat.
Since the unicorn phat is just a grid of 8×4 rgb leds, I needed to color code the different service statuses (more on the statuses later in this post). I came up with these color combinations. It doesn’t matter what combinations they are as long as they mean something to you (or as long as you can decode them).
🟩 🟩 🟩 🟩 ServiceOperational
🟩 🟩 🟩 🟨 ServiceRestored
🟪 🟪 🟪 🟪 Investigating
🟩 🟩 🟩 🟪 FalsePositive
⬜️ ⬜️ ⬜️ ⬜️ InformationUnavailable
🟥 🟥 🟥 🟥 ServiceInterruption
🟥 🟥 🟥 🟨 ExtendedRecovery
🟥 🟥 🟨 🟩 ServiceDegradation
🟩 🟩 🟩 🟦 PIRPublished
🟥 🟨 🟨 🟩 RestoringService
There is a list of all possible statuses you can get for Microsoft 365 Services, and it is here:
Install the cli-microsoft365 npm package globally.
sudo npm i -g @pnp/cli-microsoft365
You have to log in, admin consent (if you run this for the first time) and then you can get the status of the Microsoft 365 Services by running:
m365 tenant status list
There are many services in Microsoft 365. I choose the 8 most important ones (from my point of view), because there are only 8 rows on the unicorn phat, you can choose your services and order them as you prefer of course. Beware the spelling and the casing:
Assembling the hardware
I had my raspberry pi zero w, with raspberry pi os already installed. I attached the unicorn phat using solderless pogo pins. I found a little white cardboard box, cut out a rectangular hole for the unicorn phat and glued the raspberry pi with unicorn inside the box. On the front side I put a sticker with the actual service names for every led row. I connected it to the power, ran the script.
Other tips and tricks
The pogo pins were to loose and the leds did not work. I had to shorten the plastic holders a little to tighten the the pins.
Login to cli-microsoft365 as sudo
When I explored the m365 commands, it worked perfectly. My login was cached. Then I needed to run my scripts as sudo, since it requires communication with GPIO pins and the unicorn phat. It didn’t work. The login cache is in different place if you run as sudo. Obvious, when I look at it afterwards, but it took some time to realize that. So, if you are going to do the same, just make sure you log in to m365 as sudo as well, before running the script:
sudo m365 login
This web resource is gold, it shows the pinout and connections to many hats etc:
This post is about my setup of the popular MagicMirror2 application. I show the steps needed to set it up on a Raspberry Pi Zero W and connect it to a TV set. As a bonus, I share my thoughts on the Chuvash localization work.
MagicMirror2 is a DIY project and an open-source application, voted to number one of the best Raspberry Pi Projects. In essence, it shows information of your choice (weather, calendar, news) on a screen that is embedded in a mirror.
I was introduced to MagicMirror2 by my colleague, who uses it in another way: rather than having it in a mirror, he has it on his smart tv. The customisability is the beauty of the whole DIY and the Raspberry Pi.
I also decided to use it on my tv, through the built-in web browser. My raspberry pi zero w required some special steps due to its processor architecture. Fortunately, I found a guide for MagicMirror2 and Raspberry Pi Zero W which I used as a starting point.
After trying it, I found that I needed those steps for my server-only magic:
Every time I work with software I try to think: can I help to translate/localize it to Chuvash. Chuvash is a “little” language, it is only spoken by 1.5 million people. Almost in all cases, it is hard to even to register the Chuvash as such (like in Windows, or macOS), and it is even harder to localize applications, because they tend to have thousands or sometimes millions of strings to translate (and maintain!).
With MagicMirror I experienced how work from the past can help today, how small pieces can become connected parts of a bigger picture.
That was nice! I changed language to “cv” in the config/config.js and the most of the interface turned into Chuvash. (cv – is the iso code for Chuvash language). What a feeling of joy!
Why that excitement? Well, almost everything in the Chuvash IT (UX, localization, keyboard layouts, speech recognition, machine translation etc) is driven and sponsored by volunteers and a community. That’s why it is a special joy to see pieces come together, even though it is a small DIY project.
The MagicMirror2 itself does a minimal set of strings to translate. I translated it and submitted a Pull Request, which has been already merged to the develop branch.
Elio wrote his blog post in April this year – in the times of the lockdown in Belgium. In Sweden, we hadn’t a real lockdown, but it seems that it might come times when my children would need to be at home more while I work. In that case a superclear system that shows when I have important meetings is just awesome. Maybe, with that I am prepared for such times.
But to be really honest, the main driving factor is the fact that it is very satisfying to tinker around with this DIY stuff 😜😎
There is a python wrapper for MSGraph which is awesome, but it needs more contributors:
What if you put together Work From Home and Home Automation? Well, removing the common denominator (HOME) would mean Work Automation (sic!). I want to tell you about a tiny hobby project I have had at home, still related to work of mine: Whenever an Azure alert is triggered, my Trådfri smart light from IKEA flashes for a couple of seconds.
Summary (if you want to skip the long story below): The solution is a tiny web application. The publicly accessible url, exposed using ngrok, is registered as a webhook in an Azure Alert. It’s on Github, you’re welcome to use it as you please 😎:
When I was done setting up an alert, I thought: besides a notification in a Teams channel, I thought: what if I could show the alert visually using some LED or similar? Then I thought about Home Automation and a Trådfri RGB bulb I’ve got. That’s the beauty of the mentioned equation: Work From Home and Home Automation. We can pick the best parts of it and combine to something unique.
Since I have a kit from IKEA containing a gateway, a remote, and an RGB lamp, I wanted to do something with that. Unfortunately I didn’t find any routines (Google Home), applets (IFTTT) or automations (Home app in iOS) that could do it.
Luckily, there is a way of controlling the Trådfri lights, best described in this tutorial:
As in this tutorial I also used a Raspberry Pi Zero W, and it went very well, except one thing: Trådfri team introduced a change for the security code, I needed an additional step that was missing, more on that later.
The tutorial says: the world is your lobster. My “lobster” is a webhook that makes lights flash on an alert, so I needed to have a simple web server (http.server) and a tunnel to my network (ngrok). It was best to take one step at a time.
Step 1. Connect
First, I wanted to make sure I could have a simple web server that could host my webhook. I followed the advice from that tutorial and used http.server python module:
I opened that page, (192.168.0.193:8000), and I could see “hej”, time to go further.
Step 2. Connect World
Next step was to open up this “web app” for the world, to make it accessible from outside my local network. ngrok is the best solution for that. I followed that guide to install ngrok on my Raspberry Pi Zero W.
When I knew I could have a simple webhook service, locally (step 1) and on the WWW (step 2), and that I could control the smart light I’ve got from IKEA using code running on my raspberry pi, then connecting everything was easy. I created a repo for that and you can see that it is a very simple one:
The main part is in the server.py. When it gets invoked, it calls the flash function. It uses os.system to call the libcoap-client and time.sleep for delay parts needed in the flash action. The configuration is parsed using configparser and the server is a simple http.server.
In the end I registered the ngrok endpoint in my Azure Alert Rule Action Group:
Then I triggered my test logic app that failed reliably 🙂
This is a game changer: rather than wait for an alert to be triggered, you can just Replay it over and over again while you mickle-muckle your python code locally.
Keep running your server after logout
You just need to to have “nohup” when you start your server, ngrok has already what’s needed: nohup python3 server.py. With that the server will run even when you log out or, your ssh connection disappears.
I’d like to end this post also by saying: The world is your lobster. Try out the flashing lights on Azure Alerts, or why not to replace Azure Alerts with Exoprise Alarms, or some triggers in Power Automate, perhaps, when a new site has popped up 🙂 Or maybe you want to elaborate the flashing behaviour, why not to use Morse code to send a message? Or maybe color-code the different types of alarms/alerts. Once again, the world is your lobster 🦞(or oyster 🦪, well whatever) .
I have set up Raspberry Pi as a Dashboard Monitor a couple of times. Here I want to summarize my steps. In fact, it is nothing special, a raspberry pi that is used as a browser showing a web based dashboard in full screen, but there are some important configuration steps needed to make it as good as possible.
Raspbian is the best operating system for Raspberry Pi. Just stick with that.
Expand file storage
When you boot up Raspberry Pi, the first thing you should do is to expand the file storage, otherwise it is hard to install anything. To do so, run raspi-config from command line and restart your raspberry pi after that.
Rename your raspberry
You are advised to change the password. In my case I usually just want to keep the default password: “raspberry”. What I want is to change the hostname from raspberrypi to some unique hostname (in my example it will be “kallerasp”), so that I can access it from my network without running risk for name conflicts. To rename your raspberry, update the /etc/hostname file:
sudo vim /etc/hostname
After that restart your computer.
Iceweasel is a Firefox fork, which works just fine on the raspberry pi. Update your raspberry pi and install it:
To use your raspberry pi as a dashboard monitor we need to prevent the screen from getting blank (dark).
sudo cp lightdm.conf lightdm.conf.bak
sudo vim lightdm.conf
Update it so you have the following:
xserver-command=X -s 0 -dpms
Start dashboard page on startup
To automatically start iceweasel on startup, we need to configure autostart. To do so, run this from terminal:
In the .desktop file write following:
Previously I had chromium-browser –kiosk http://someurl, but Chromiums is no longer available, and iceweasel does not have –kiosk parameter. On the other hand, you have to activate Full Screen the first time, then after OS restart iceweasel automatically will activate Full Screen and your dashboard page from the previous session.
Recently I have looked more at IoT, Raspberry Pi in my spare time. In my blog post I want to share my experience in a series of posts. This post is about measuring temperature, humidity and pressure with Raspberry Pi 2 Model B and Sense Hat and posting this data to Azure Table Storage.
The python script is on github. Along the way I learned that only python 2.x can be used with azure and table names cannot contain underscore (I got Bad Request error when I tried to create a table with the name “climate_data”). But overall, the process was straightforward. The temperature is not correct, maybe because the sensor is inbetween Raspberry Pi and Sense Hat where it gets warm. But it is just a Proof-of-Concept.