From 52423f5977049f55fa2463ed94390720c529f3dd Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 19:51:07 +0100 Subject: [PATCH 01/10] Create BS440runalyzel.py --- BS440runalyzel.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 BS440runalyzel.py diff --git a/BS440runalyzel.py b/BS440runalyzel.py new file mode 100644 index 0000000..c309e02 --- /dev/null +++ b/BS440runalyzel.py @@ -0,0 +1,33 @@ +import logging +import MySQLdb + +def UpdateRunalyzeLocal(config, persondata, weightdata, bodydata): + log = logging.getLogger(__name__) + personsection = 'Person' + str(weightdata[0]['person']) + scaleuser = config.get(personsection, 'username') + runalyzeID = config.get(personsection, 'runalyzeID') + + sql_host = config.get('RunalyzeLocal', 'host') + sql_user = config.get('RunalyzeLocal', 'user') + sql_passwd = config.get('RunalyzeLocal', 'passwd') + sql_db = config.get('RunalyzeLocal', 'db') + + log.info('Updating Runalyze per SQL-Query for user %s (ID %s) with weight %s, fat %s, water %s and muscle: %s' % + (scaleuser, runalyzeID, weightdata[0]['weight'], bodydata[0]['fat'], bodydata[0]['tbw'], bodydata[0]['muscle'])) + + try: + db=MySQLdb.connect(sql_host, sql_user, sql_passwd, sql_db) + + cur=db.cursor() + + log.info("INSERT INTO runalyze_user (time, weight, fat, water, muscles, accountid) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')" % (weightdata[0]['timestamp'], weightdata[0]['weight'], bodydata[0]['fat'], bodydata[0]['tbw'], bodydata[0]['muscle'], runalyzeID)) + + a=cur.execute("INSERT INTO runalyze_user (time, weight, fat, water, muscles, accountid) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')" % (weightdata[0]['timestamp'], weightdata[0]['weight'], bodydata[0]['fat'], bodydata[0]['tbw'], bodydata[0]['muscle'], runalyzeID)) + + cur.close() + db.commit() + db.close() + + log.info('Update successful!') + except: + log.error('Unable to update Runalyze per SQL-Query: Error sending data.') From 201b134ffdb99beda7cba293c3602bff60f7d93d Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 19:54:23 +0100 Subject: [PATCH 02/10] Add [RunalyzeLocal] --- BS440.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BS440.ini b/BS440.ini index ff1f8d5..50a78cc 100644 --- a/BS440.ini +++ b/BS440.ini @@ -45,3 +45,8 @@ sender_pwd: yourpassword #Uncomment [Google] to enable Google FIT updating #[Google] +[RunalyzeLocal] +host=localhost +user=root +passwd= +db=runalyze From 283aa695f03d63a02cc0581679d640fc95022b2c Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 19:55:42 +0100 Subject: [PATCH 03/10] minor changes --- BS440.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BS440.ini b/BS440.ini index 50a78cc..667c56e 100644 --- a/BS440.ini +++ b/BS440.ini @@ -46,7 +46,7 @@ sender_pwd: yourpassword #[Google] [RunalyzeLocal] -host=localhost -user=root -passwd= -db=runalyze +host: localhost +user: root +passwd: enter_your_password_here +db: runalyze From 0cc4191f17678b265a53511cad45f63a56656d02 Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 19:56:59 +0100 Subject: [PATCH 04/10] Add runalyzeID to User-Section --- BS440.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BS440.ini b/BS440.ini index 667c56e..6735dde 100644 --- a/BS440.ini +++ b/BS440.ini @@ -5,16 +5,19 @@ # The persons secion lists all the scale users # The list maybe extended to 8 persons +# runalyzeID: User ID from runalyze installation [Person1] username: John useremail: johndoe@gmail.com googleauthfile: google-john.json +runalyzeID: 1 [Person2] username: Jill useremail: jilldoe@gmail.com googleauthfile: google-jill.json +runalyzeID: 2 # Scale properties [Scale] From 6c95b545acb609483942ec77cf76d8e26e09be69 Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 20:04:13 +0100 Subject: [PATCH 05/10] Tested Scales and Runalyze Section --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 940df5e..a9f544c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ https://keptenkurk.wordpress.com/2016/02/07/connecting-the-medisana-bs440-blueto # Tested on * Raspberry Pi B+ (Linux raspberrypi 4.1.13+ #826 PREEMPT Fri Nov 13 20:13:22 GMT 2015 armv6l GNU/Linux). + +# Tested Scales +* Medisana BS440 +* Medisana BS444 # Description BS440 listens for information from a BS440 or compatible bluetooth scale. @@ -45,6 +49,17 @@ while the other sensors are identified by _idx_ in _BS440domoticz.ini_. ![domoticz](https://raw.githubusercontent.com/Tristan79/BS440/master/BS440domoticz.png) +# Runalyze +Uncomment the following lines in the _BS440.ini_ and fill in your MySQL-Settings as you used for your Runalyze installation: + +``` +[RunalyzeLocal] +host: localhost +user: root +passwd: insert_your_password_here +db: runalyze +``` + # Disclaimer This software is build out of personal interest and not related to Medisana AG in any way. From 8cf0a043e283eb12e68c1b9aa58e3ee14bd82e3f Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 20:04:28 +0100 Subject: [PATCH 06/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9f544c..25021d0 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ https://keptenkurk.wordpress.com/2016/02/07/connecting-the-medisana-bs440-blueto * Raspberry Pi B+ (Linux raspberrypi 4.1.13+ #826 PREEMPT Fri Nov 13 20:13:22 GMT 2015 armv6l GNU/Linux). -# Tested Scales +# Tested scales * Medisana BS440 * Medisana BS444 From c54fe20c9e8aef1c7a56c53ade8cc1188236bff1 Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 20:07:59 +0100 Subject: [PATCH 07/10] Update BS440.py --- BS440.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BS440.py b/BS440.py index 72929fa..34c0db3 100644 --- a/BS440.py +++ b/BS440.py @@ -10,6 +10,7 @@ from BS440mail import * from BS440domoticz import * from BS440google import * +from BS440runalyzel import * @@ -170,5 +171,8 @@ def init_ble_mode(): if config.has_section('Google'): UpdateGoogle(config, persondata, weightdatasorted, bodydatasorted) log.info('Google') + if config.has_section('RunalyzeLocal'): + UpdateRunalyzeLocal(config, persondata, weightdatasorted, bodydatasorted) + log.info('Runalyze local') else: log.error('Unreliable data received. Unable to process') From 0407a8f9de7f58ee2a9239b78a796715ce4a2f19 Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 20:11:59 +0100 Subject: [PATCH 08/10] Minor changes --- BS440.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BS440.ini b/BS440.ini index 6735dde..8753d8e 100644 --- a/BS440.ini +++ b/BS440.ini @@ -48,8 +48,8 @@ sender_pwd: yourpassword #Uncomment [Google] to enable Google FIT updating #[Google] -[RunalyzeLocal] -host: localhost -user: root -passwd: enter_your_password_here -db: runalyze +#[RunalyzeLocal] +#host: localhost +#user: root +#passwd: enter_your_password_here +#db: runalyze From 8f739f30e09553bcea0f1011978c4adf09ee9239 Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 20:12:37 +0100 Subject: [PATCH 09/10] Minor changes --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 25021d0..39058b3 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,11 @@ while the other sensors are identified by _idx_ in _BS440domoticz.ini_. Uncomment the following lines in the _BS440.ini_ and fill in your MySQL-Settings as you used for your Runalyze installation: ``` -[RunalyzeLocal] -host: localhost -user: root -passwd: insert_your_password_here -db: runalyze +#[RunalyzeLocal] +#host: localhost +#user: root +#passwd: enter_your_password_here +#db: runalyze ``` # Disclaimer From f09b4b32ef9c11520416c3fe63310bd3eda69882 Mon Sep 17 00:00:00 2001 From: genlinut Date: Wed, 15 Feb 2017 20:15:05 +0100 Subject: [PATCH 10/10] Minor changes --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 39058b3..24f12ab 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ file _BS440.ini_, to the following possibilities: * Update weight and fat parameters in Google fit (http://fit.google.com) For creating an account and authentication file please see the Wiki for this repository.(https://github.com/keptenkurk/BS440/wiki/How-to-use-Google-Fit) +* Update weight, water, fat and muscel parameters in Runalyze (https://github.com/Runalyze/Runalyze) # Preferences Before using this app, personalize your settings in the file _BS440.ini_.