It all started with my granddad always asking for the lottery numbers every week. Since he is old (92 years) and always forgets to watch the live broadcast when the numbers are getting revealed I have to give the numbers to him the morning after on a piece of paper. This was a task I really wanted to automate. I’ve also had the idea to make him a screen with information about the date, weather and weather forecast. So I had a RP3 laying around and wanted to start making something cool with it.
This is my first project on a Raspberry Pi so dont except anything amazing. I am not an experienced programmer neither very good at Linux. But I got some basic knowledge and a bachelors in IT Security. I also work with automation in the welfare state in Norway using mostly RPA with VB.net and some Python.
First off, the biggest issue. The Raspberry PI OS are using ARMv8-A architecture, which gave me huge issues trying to use the geckodriver for my Python web scraping script. Seems it only supports ARMv7, and not 8. If you got a solution for this just pm me. So I ended up running the script on a separate Ubuntu machine.
So, this is what I ended up with. The numbers are big since he is an old man. I show the lottery numbers, the date and time and of course the weather :)
Smashing is a Sinatra based framework that lets you build beautiful dashboards. This project is a fork of Dashing, an excellent framework created at Shopify for displaying custom dashboards on TVs around the office. So, there that goes. https://smashing.github.io/ It is very easy to set up and maintain. To be clear I use a RP4 as a host, and an old RP3 as a client just to show the dashboard on chromium using full screen. Could have used a chromecast or any other device that can show a webpage.
Setting up smashing were easy, as long as you have the correct version of python. At the start I used an old version of Raspberry Pi OS, which had the wrong version of Python installed. No matter how I updated stuff, the python version stayed the same. So I got a fresh .iso file from https://www.raspberrypi.org/software/operating-systems/ and redid it. After that this worked very fine:
So, what we did earlier makes a sample dashboard with the code in separate directories. I watched this dashing workshop video to get an fast introduction to how the folders and code talked together (https://vimeo.com/95307499). Also reading the documentation on this site is very useful: https://smashing.github.io/ which links to this https://github.com/Smashing/smashing/wiki.
Notice that I link to some dashing videos and documentation since smashing is forked from dashing. Dashing is no longer maintained and used.
List of additional widgets are found here: https://github.com/Smashing/smashing/wiki/Additional-Widgets
My smashing setup: https://github.com/Vigdals/adriansSmashing
Here is my Python code which scrapes the lottery site. By using helium you must be on ARMv7 or lower when on Linux. So, I must run the script on a different machine than the RP4, therefore this is run on an Ubuntu virtual machine for the time being.
What it does it opening up Firefox, navigating to the lottery site, scrape the lottery numbers. Reformatting them into something readable, writing them to a file. Reading this file and posting that to my smashing dashboard. Easy as that! I still have to fix this so it runs every Saturday at 20:30 in the evening. The code is messy and not well written. But it works!
First of all you do what is written down below:
Then we got the Python script which gets the info from the lottery site the lottery site in Norway
To schedule the job I used cron which makes automating the jobs easy. To find the correct cron expression I used this site: https://crontab.guru/#45_20_*_*_6
Copyright © 2022 Vigdal.dev - All Rights Reserved.
Powered by GoDaddy