Monitor Oral-B Toothbrush

I just integrated my Oral-B toothbrush via MQTT into my OpenHab system and want to share my solution with you.

What you need:

  • Oral-B toothbrush which supports bluetooth
  • Device with an bluetooth adapter (in my case a raspberry pi)

The logic behind this little project is the following:
Toothbrush → Bluetooth → Raspberry Pi Service → MQTT → OpenHAB

The toothbrush sends a bluetooth low energy signal including the data. This is received by a Raspberry Pi service. The incoming data is processed and sent to OpenHAB via a MQTT.

1. Raspberry Pi

Requirements: Python 3, MQTT Broker (e.g. Mosquitto)

  1. Download the prepared file by vogler.
  2. Install the requirements: sudo pip install bluepy paho-mqtt.
  3. Find the mac-address of your toothbrush (e.g. sudo hcitool lescan)
  4. Create and change the service for your needs (file destination, host, topic):
    /etc/systemd/system/toothbrush.service:
[Unit]

Description=Zahnbuerste Ueberwachung Mqtt

[Service]

User=pi

Type=simple

ExecStart=sudo python3 /home/pi/toothbrush/toothbrush2mqtt.py 11:22:33:44:55:66 host topic

[Install]

WantedBy=multi-user.target

Start the service with sudo systemctl start toothbrush.service.

Optional: If you have authentication enabled at your MQTT broker you have to add the following line above mqttc.connect(host):
mqttc.username_pw_set(username="username", password="password")

2. OpenHAB

Requirements: configured MQTT Binding, JSONPATH transformation

toothbrush.things (replace the stateTopic with your topix):

Thing mqtt:topic:toothbrush "toothbrush" (mqtt:broker:mqttbroker) @ "Mqtt"
  {
    Channels:
      Type switch : running "running" [ stateTopic = "toothbrush", transformationPattern="JSONPATH:$.running", on ="true", off = "false" ]
      Type number : pressure "pressure" [ stateTopic = "toothbrush", transformationPattern="JSONPATH:$.pressure" ]
      Type number : time "time" [ stateTopic = "toothbrush", transformationPattern="JSONPATH:$.time" ]
      Type number : mode "mode" [ stateTopic = "toothbrush", transformationPattern="JSONPATH:$.mode" ]
      Type number : quadrant "quadrant" [ stateTopic = "toothbrush", transformationPattern="JSONPATH:$.quadrant" ]
      Type number : quadrant_percentage "quadrant_percentage" [ stateTopic = "toothbrush", transformationPattern="JSONPATH:$.quadrant_percentage" ]
    }

toothbrush.items:

Group                       gToothbrush                                       "Toothbrush"                                                                                                                                                                                                                                          ["Sensor"]
Switch                      Toothbrush_Running                                "Toothbrush Running"                                                                                                                                                                        (gToothbrush)                                             ["Power"]               {channel="mqtt:topic:toothbrush:running"}
Number                      Toothbrush_Pressure                               "Toothbrush Pressure"                                                                                                                                                                       (gToothbrush)                                             ["Pressure"]            {channel="mqtt:topic:toothbrush:pressure"}
Number                      Toothbrush_Time                                   "Toothbrush Time"                                                                                                                                                                           (gToothbrush)                                             ["Duration"]            {channel="mqtt:topic:toothbrush:time"}
Number                      Toothbrush_Mode                                   "Toothbrush Mode"                                                                                                                                                                           (gToothbrush)                                             ["Measurement"]         {channel="mqtt:topic:toothbrush:mode"}
Number                      Toothbrush_Quadrant                               "Toothbrush Quadrant"                                                                                                                                                                       (gToothbrush)                                             ["Measurement"]         {channel="mqtt:topic:toothbrush:quadrant"}
Number                      Toothbrush_Quadrant_Percentage                    "Toothbrush Quadrant Percentage"                                                                                                                                                            (gToothbrush)                                             ["Measurement"]         {channel="mqtt:topic:toothbrush:quadrant_percentage"}

Have fun with the incoming data and creating awesome rules :slight_smile:

10 Likes

I’ve seen it all now! A toothbrush!!

Fantastic work, thanks for sharing!

I used to work for Braun many years ago, so I think this is really my must have for my openHAB installation in the long run - love the idea :heart:

1 Like

Waiting for someone displaying these data on a smart mirror.

2 Likes

This is the epitome of silly and mostly pointless home automation, and I love it.

Out of curiousity, did you try the newer code that the auther published last November?

DEPRECATED: See smart-home/toothbrush2mqtt.py which is just one file, only needs bluepy , and reports every second. This fork is too complicated, has too many dependencies, and blus only reports every 10s.

I don’t know if it is that silly. It sure sounds like it, but for lots of people brushing their teeth is the last thing they will do before going to bed. It could be a good trigger to start a routine for going to bed, e.g. dimming lights, closing blinds, turing down heating etc.

Oh, for sure. I should have said that it “sounds” silly and mostly pointless. As in, relative to most people’s understanding of home automation being about lights and plugs.

Honestly, no. But I had a look and added it.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.