Rule definitions
In my previous post I detailed the changes to the data collecting Python script and an additional script fired by crontab. In this post I will describe the code behind the rule-engine.
In my previous post I detailed the changes to the data collecting Python script and an additional script fired by crontab. In this post I will describe the code behind the rule-engine.
I recently noticed that when I was using Google Public DNS I could not reach my own domain at littlegemsoftware.com. Using other DNS services like my own ISP or for instance OpenDNS everything was working fine.
If it would have been just for me, switching to another DNS service would have been fine. However I am running services on littlegemsoftware.com for my iOS application WoW Realms and obviously I have no say in the matter what my users will be using for their DNS service.
In my previous post I talked about using the Pushover service for sending notifications from the Raspberry Pi to my mobile devices. Now it is time to actually define some of these events.
Event | Condition | Interval |
---|---|---|
New Record | New highest/lowest temperature detected | 5 min |
No Data Logged | No new data since at least 5 minutes | 5 min |
Temperature Difference | Rise/Drop >= 1°C | 30 sec |
Performance for the charts pages was getting worse and worse the more data was collected from all the sensors connected to the Raspberry Pi. It was not only taken a lot of time to get any results, but also CPU usage by the MySQL process jumped to around 90%.
High time to do some further optimization.
My Raspberry Pi has been humming along for quit some time now. Next thing to add to the project is a mechanism to send notifications when certain events occur (sudden increase/drop in temperature, etc.). Probably the simplest method for sending these type of notifications would probably be via email, but I don’t like it. I would rather implement some sort of push notifications.
I am already using Pushover to have IFTTT send notifications from several services to my mobile devices. So for me it makes sense to use the Pushover service. The Pushover service itself is free (no monthly fees), however the client applications are priced at $4.99 (iOS or Android).
In my previous two post (Part 1 and 2) I described how I moved all of the processes for tracking the sensor data onto the Raspberry Pi. I ended the second post with some concerns in relation to CPU usage of the php-cgi
process being to high (around 100% when accessing the charts).
The php-cgi
process was taking care of calling the PHP script, which then would access the SQLite database and return data for one particular sensor. Since a SQLite database can only be accessed by one process at the time (database locked until released/closed) special steps had been taken to wait for the database to be available to be queried (i.e. by using the busyTimeout()-routine). In most scenarios this would work fine, but since the sensor page fetches data for three sensors simultaneously, these processes were mainly waiting for each other to finish.
In my last post, (Running it all on the Raspberry Pi (Part 1), I went through the additional software and services that were required to move all the processes to the Raspberry Pi.
In this installment I describe the updates required to my own scripts involved in the project
My ‘project’ for logging environmental data now relies on an additional server for logging and displaying the data. To make the project completely self-contained the web server component is going to be moved onto the Raspberry Pi as well.
Based on the current setup, roughly the following tasks will need to be performed to get rid of the additional server;