Skip to content

Plugin: BS440runalyzel

keptenkurk edited this page Mar 4, 2017 · 9 revisions

What is it

BS440runalyzel stores the scale data into a local hosted Runalyze database. Runa;yze is a Running/Fitness data tracker / analyser which receives data from manual enty or fitness trackers like Runtastic, Polar etc. The tool can be used locally where the data is stored in a MySQL database or in the cloud. An API to store data in the cloud is not yet available. Runalyze also tracks body data and BS440runalyze is used to read the scale data and store it into the local Runalyze database.

Prequisits

This plugin assumes a MySQL database and server running On a RPi Install MySQLdb and the MySQL server with sudo apt-get install mysql-server python-mysqldb Installing Runalyze on a local machine from https://github.com/Runalyze/Runalyze/releases/ will create a database named "runalyze". The table we are updating here looks like this:

CREATE TABLE IF NOT EXISTS `runalyze_user` (
`id` int(10) unsigned NOT NULL,
  `time` int(10) unsigned NOT NULL,
  `weight` decimal(5,2) DEFAULT NULl,
  `pulse_rest` tinyint unsigned DEFAULT NULl,
  `pulse_max` tinyint unsigned DEFAULT NULl,
  `fat` decimal(3,1) DEFAULT NULl,
  `water` decimal(3,1) DEFAULT NULl,
  `muscles` decimal(3,1) DEFAULT NULl,
  `sleep_duration` smallint(3) unsigned DEFAULT NULl,
  `notes` text,
  `accountid` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8

ALTER TABLE `runalyze_user`
 ADD PRIMARY KEY (`id`), ADD KEY `time` (`accountid`,`time`);

ALTER TABLE `runalyze_user`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;

Installation of Runalyze_local will create the database/table according to the SQL statements above.

BS440runalyzel.ini file

Assign the proper ID to each user and sql server properties: host, user, password and databasename.

Output

Weighing results are inserted into the runalyze_user table but only if the do not already exist (i.e. the time value is unique):

mysql> select * from runalyze_user;
+----+------------+--------+------------+-----------+------+-------+---------+----------------+-------+-----------+
| id | time       | weight | pulse_rest | pulse_max | fat  | water | muscles | sleep_duration | notes | accountid |
+----+------------+--------+------------+-----------+------+-------+---------+----------------+-------+-----------+
|  1 | 1488656938 |  79.50 |       NULL |      NULL | 19.0 |  63.9 |    17.3 |           NULL | NULL  |         2 |
|  2 | 1488656947 |  74.30 |       NULL |      NULL | 19.0 |  64.4 |    16.3 |           NULL | NULL  |         2 |
|  3 | 1488656953 |  75.50 |       NULL |      NULL | 19.2 |  65.7 |    17.6 |           NULL | NULL  |         2 |
+----+------------+--------+------------+-----------+------+-------+---------+----------------+-------+-----------+
3 rows in set (0.01 sec)