Store and produce statistics of sensor reading time series
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



saal stands for Sensor and Actuator Abstraction Layer, and it aims to handle the mechanics of accessing sensors and actuators and logging their state over time. In its present state it is capable of reading from any set of one wire sensors attached one or more owserver processes from the owfs project. It is also able to read and actuate the DIN mounted IP relay from digital loggers ( In the future other forms of sensors as well as actuators can be added.

Based on a single definition of available sensors/actuators several features are available:

  • An API to read/write to sensors/actuators

  • A daemon that periodically records all sensor values into a MySQL database

  • An API to interrogate the database of recorded values

  • A graphing API and full program to produce charts from the stored sensor reads

An example of the usage of saal can be seen at

Basic Usage

After you install the gem:

$ gem install saal

Define your sensors in /etc/saal/sensors.yml.

  name: "A fake temperature sensor"
    serial: /10.4AEC29CDBAAB/temperature

This gives you one available sensor:

require 'saal' do {|sensor| puts} 
# "fake_temp"

Now if you run owserver in test mode:

owserver --fake 1F,10

you can read from the sensor: # Returns a random value with owserver --fake # Forces an actual physical read of the sensor instead of using any cache

Sensor Logging

To store readings you would need to setup an /etc/saal/database.yml. For example:

host: localhost
user: sensor_reads
pass: somepass
db: sensor_reads_production

This sets up access to the 'sensor_reads_production' MySQL database on 'localhost', using user 'sensor_reads' and pass 'somepass'. With this in place you can now run the daemon to periodically store sensor values:

$ saal_daemon /var/run/

And then you can query the stored values:,

Both arguments to average are unix timestamps in UTC timezone.


After you've gotten sensor logging working and some values in the database you can start creating charts based on it. Here's an example /etc/saal/charts.yml file:

  sensors: [temp_exterior, hum_exterior, pressure]
  last: 24
  periods: hours

  sensors: [temp_exterior, hum_exterior, pressure]
  last: 7
  periods: days

  sensors: [temp_exterior, hum_exterior, pressure]
  last: 4
  periods: weeks
  alignlabels: left

  sensors: [temp_exterior, hum_exterior, pressure]
  last: 12
  periods: months

  sensors: [temp_exterior, hum_exterior, pressure]
  last: 4
  periods: years

With this in place you can now run “saal_chart <some_directory>” and get 5 png files produced with the Google charts API that show the data recorded in the database over the given periods. This is almost exactly the config that generates the graphs at

The charting code handles range selection and period naming automatically, so all possibilities of number and type of periods are possible.


Pedro Côrte-Real <>