** Update March 2nd 2018 **
Documentation is extended, scripts will now create the Homeseer virtual devices automatically and icons are added.
Unfortunately after several years my Oregon body weight scale died. It drained many batteries the last months which is very uncommon, and even the last reading were not picked up anymore my RFXCOM. When I shake the scale in the air, you will hear many looseparts…time to find a new one.
A must have is a connection to my smart home, preferable via wifi and not via bluetooth. Another challenge will be retrieve the data into Homeseer. Most of the brands provide a free dashboard, even an API. I’m still struggling with API’s, so for now I connected it to IFTTT. I prefer no connection to the outside world, but for a non security system device, it is oke.
Let’s start
First create a new applet on IFTTT.com for Fitbit and connect it to a Dropbox account.
- When a new weight is logged on Fitbit, IFTTT will update a text file in my Dropbox folder with the new weight value, see example below:
2. From the download at the bottom of the page, copy the “Fitbit” folder (with the icons), to the following location: “\Homeseer HS3\html\images\”
3. Copy both vb scripts to the following location: \Homeseer HS3\Scripts
The Fitbit-Aria.vb script will do the following:
- It will create 4 virtual device in Homeseer 3: Weight, BMI, (weight) difference and File update.
- It reads the value from the Dropbox text file and compare it to the the last saved value in MySQL table.
- It will do some calculations, like the weight difference between the old and the new value and calculate the new BMI.
- It will save the new device values to Homeseer
- It deletes the text file on Dropbox
- It store the new devices values to MySQL (In case there is already data saved today to the MySQL table, no new updates will be done.).
Screenshot of the created devices in Homeseer:
4. Open your MySQL environment.
Create the table from the screenshot below manually or use the sql file from the download to do the import in MySQL(1 row is already added as an example). In the end you should have this:
5. Create an recurring Homeseer event, to run the “Fitbit-aria.vb” script (in my case the script will check every 30 minutes for the file in the local Dropbox\IFTTT folder):
6. Create a second event (to store the final weight, bmi results). I prefer to have a seperate script for this, which is manually triggered by the Fitbit-Aria.vb script):
In the end the “MySQL_Weight.vb” script will update the data in the table:
7. Open the “Fitbit-Aria.vb” script, and change the following data, related to your environment:
Line 39-43:
- Dim server = “localhost”
- Dim user = “xxxxx”
- Dim password = “xxxxx”
- Dim database = “xxxxx”
- Dim table = “weight”
The location of the local Dropbox textfile in lines 173, 192 and 202:
- If My.Computer.FileSystem.FileExists(“D:\Dropbox\IFTTT\fitbitweight.txt”) Then
- Dim Ariafile as New StreamReader(“D:\Dropbox\IFTTT\fitbitweight.txt”)
- FileToDelete = “D:\Dropbox\IFTTT\fitbitweight.txt”
Line 48:
- Dim personlength = “1,93”
8. Open the “MySQL_Weight.vb” script and change the following data, related to your environment:
Line 21:
- Dim person as String = “Rutger”
Lines 24-28:
- Dim server = “localhost”
- Dim user = “xxxxx”
- Dim password = “xxxxx”
- Dim database = “xxxxx”
- Dim table = “weight”
9. The MySQL.Data.dll file is added to the downloads as well. Put this file in the root of the Homeseer folder. The “settings.ini” file in the \Config folder has to be changed for this as well. If not done already:
- Stop Homeseer 3
- Edit the settings.ini file with the following data: “ScriptingReferences=MySql.Data.MySqlClient;MySql.Data.dll” (comma seperated with mutiple entries)and save the file
- Start Homeseer 3
In the End, run the earlier created event with the “Fitbit-Aria.vb” script once. The devices are created automatically and if it’s a recurring event, you don’t have to take care about it anymore. In both scripts you may decide to change the Debug value to “false”.
Downloads:
Last release: 04-03-2018:
Fitbit.zip (60.7 KiB, 373 hits)
Related Posts
June 11, 2016
Mailbox sensor
October 2, 2015
New GPS tracker TK103-2
November 29, 2014
In de aria-update log zie ik staan:
aug-20 19:04:31 Aria-txt Contains text: Weight logged: 71.6 kilograms
Ik heb verder overal als decimaal een komma staan.
The content of the created file by IFTTT should contain only the weight value itself, not including the text “The logged weight: xxx kilograms”.
So, in IFTTT please select the variable “Weight” only into the Content field. I’ve added now a screenshot of IFTTT into the blog post.
ik heb je script geprobeerd, maar krijg een foutmelding:
Running script C:\Program Files (x86)\HomeSeer HS3\scripts\FitbitAria.vb :Het doel van een aanroep heeft een uitzondering veroorzaakt.De conversie van tekenreeks Weight logged: 71,6 kilograms naar type Double is ongeldig.
Het enige wat ik veranderd heb zijn de deviceID.
Import van Veld Aria Update gaat wel goed overigens.
Wat doe ik verkeerd
Hi Marcel,
als je de regel “hs.setdevicevaluebyref(xxx, weight, true)” als commentaar toevoegd (enkel quote aan het begin van de regel), werkt ‘t dan wel?
Staan jouw overige devicevalues in Homeseer als comma of als punt weergegeven?
gr. Rutg3r