recently I’ve added my BS440 body analysis scale to my home automation system.
In order to achieve a fault tolerant system a Raspberry Pi Zero W was used in the close surrounding of the scale. It served as Bluetooth enabled gateway, which forwards measurements to Home Assistant using MQTT messages.
The Bluetooth communication was done using the project of keptenkurk, which is available on GitHub. In order to install the Bluetooth stack on the Raspberry Pi, the following step by step instructions were used: https://keptenkurk.wordpress.com/2017/03/05/connecting-the-medisana-bs440-bluetooth-scale-epilogue/. I’ve implemented a generic MQTT plugin for the project. It’s currently available on https://github.com/jinnerbichler/BS440 until the pull request was accepted. The plugin is configured by renaming BS440mqtt.example.ini to BS440mqtt.ini and replacing the proper parameters of the MQTT client. Delete username and password if no credentials are necessary. Don’t forget to install the MQTT client by executing pip install paho-mqtt.
The MQTT client sends the measured data using the topics bs440/person1/ to bs440/person8/ and the following JSON encoding:
Home Assistant and the MQTT broker are running on a Raspberry 3, which is placed further away from the scale.
The following MQTT sensor was added to the configuration file:
in the meantime mqqt issue seems to be fixed but I’m receiving an error when running the command manually
python BS440.py
2017-08-29 21:30:57,867 INFO <module> Configured plugins: BS440mqtt
2017-08-29 21:30:57,868 INFO <module> Loading plugin: BS440mqtt
Traceback (most recent call last):
File "BS440.py", line 225, in <module>
mod = __import__(plugin)
File "plugins/BS440mqtt.py", line 41, in <module>
import paho.mqtt.publish as publish
ImportError: No module named paho.mqtt.publish
erorr above gone, restarted the service, mqqt plugin seems to be activated, went on the scale but nothing was reported in the log file… something wrong wit mqqt config as posted above?
config BSS440.ini
Enable your plugins here, use the comma separated basename from the plugins/
Example:
plugins: BS440mqtt
root@DietPi:/opt/BS440# service bs440 status
● bs440.service - Run BS440 bluetooth scale monitor
Loaded: loaded (/etc/systemd/system/bs440.service; enabled)
Active: active (running) since Wed 2017-08-30 09:51:05 CEST; 1h 1min ago
Main PID: 15601 (python)
CGroup: /system.slice/bs440.service
└─15601 /usr/bin/python BS440.py
Aug 30 09:51:05 DietPi systemd[1]: Started Run BS440 bluetooth scale monitor.
Aug 30 09:51:05 DietPi python[15601]: 2017-08-30 09:51:05,899 INFO Configured plugins: BS440mqtt
Aug 30 09:51:05 DietPi python[15601]: 2017-08-30 09:51:05,899 INFO Loading plugin: BS440mqtt
root@DietPi:/opt/BS440# tail -v -f BS440.log
==> BS440.log <==
Wed, 30 Aug 2017 09:51:05 INFO Configured plugins: BS440mqtt
Wed, 30 Aug 2017 09:51:05 INFO Loading plugin: BS440mqtt
Wed, 30 Aug 2017 09:51:05 INFO init Initialising plugin: BS440mqtt
Wed, 30 Aug 2017 09:51:05 INFO init Read config from: /opt/BS440/plugins/BS440mqtt.ini
Have you setup persons on the scale?
It might be necessary in order to let the scale report its analysis.
You can do this using the companion App from Medisana.
Great project, would this also work for a BS A40 that anyone knows?
Edit: alright, everything came along pretty good, just this error:
root@raspberrypi:~# journalctl -l -f -u bs440
-- Logs begin at Sat 2019-08-17 20:21:17 BST. --
Aug 17 20:21:43 raspberrypi systemd[1]: Started Run BS440 bluetooth scale monitor.
Aug 17 20:21:45 raspberrypi python[411]: Traceback (most recent call last):
Aug 17 20:21:45 raspberrypi python[411]: File "BS440.py", line 199, in <module>
Aug 17 20:21:45 raspberrypi python[411]: config.get('Program', 'loglevel').upper(),
Aug 17 20:21:45 raspberrypi python[411]: File "/usr/lib/python2.7/ConfigParser.py", line 607, in get
Aug 17 20:21:45 raspberrypi python[411]: raise NoSectionError(section)
Aug 17 20:21:45 raspberrypi python[411]: ConfigParser.NoSectionError: No section: 'Program'
Aug 17 20:21:45 raspberrypi systemd[1]: bs440.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 20:21:45 raspberrypi systemd[1]: bs440.service: Failed with result 'exit-code'.
Any idea where to start fixing this?
I was able to connect to my scale and follow the guide.
It works for the BS A40.
Also I’m trying to get this on bt-mqtt-gateway but It doesn’t respond on the command with data. Is there anybody who has a Medisana scale + python + bluetooth knowledge who wants to help? I can share the code that I have so far.
Got it working for now, but the only problem is I have to have my rPi Zero W within 1 meter from my scale, is the BLE antenna so weak?
I want to have my rPi on top of the ceiling in the bathroom, and the scale on the ground, distance is 2 meters, but that doesn’t work.
And another question. I want to have my google home speaker talk to me when I weigh myself, so the speaker can say You are too fat, start running! whenever I measure… But, it seems it take 1 or 2 minutes before the results are transferred over MQTT, which is my trigger for google home, is there any way it can go faster?
@eh50, had a similar problem with the version mentioned here (which fixes the configparser-problem).
Traceback (most recent call last):
File "/home/pi/BS440-HA-AD/BS440.py", line 204, in <module>
config.get('Program', 'loglevel').upper(),
File "/usr/lib/python3.9/configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.9/configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'Program'
In my case I forgot to rename BS440.example.ini into BS440.ini.
Quick update on this: Pretty neat project I have to say. Issued two bugfixes as PRs. Would be happy to contribute further if time permits / if others are interested in contributing as well.