www.homeseer.com    
 

Go Back   HomeSeer Message Board > HomeSeer Products & Services > HomeSeer Software > HS3 / HS3PRO > HS3 Plug-In Development

HS3 Plug-In Development Discussions related to developing plugins for HS3.

Reply
 
Thread Tools Display Modes
  #1  
Old June 18th, 2015, 03:35 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Smile FitbitSeer, a Fitbit plugin for HS3 - Need beta testers

NEWS: FitbitSeer now supports OAuth2.0 and therefore now works after the removal of OAuth1.0a on August 1 2016.


As a proof that it was possible to actually create a plugin without too much effort using my own plugin sample (currently in development, being released very shortly), I wrote a plugin to fetch data from Fitbit.



My wife and I have Fitbit Ones and we use them 24 hours a day, even when we sleep. We have two girls, 2 and 4 years old, and the youngest is struggling with the last tooth (it's finally over soon!!!), so for us sleep is very important. (But as you can see, the last night wasn't bad at all! First time I've been sleeping through the whole night in two weeks).

Fitbit will keep track on the last nights sleep, and HomeSeer will remind us to get to bed early if your sleep length or quality isn't satisfactory. If the quality and/or actual sleep time is bad enough and the TV is still on, it'll turn everything media related off.

It'll also keep track on our internal daily step count contest.



At the moment it's not very pretty or feature rich, but it should be stable.

Authorization is oAuth-based. The plugin is based on Fitbit.NET which builds on the Fitbit API. The plugin will update data every 5 minutes, and this should be fast enough to be almost "live" as Fitbit devices aren't updated continously, and it's seldom enough so we don't cross the 150 requests pr hour rate limit. However, this refresh time is user configurable. The plugin is multi-threaded so checking more often shouldn't be a problem.

Planned features:
  • User can select whitch data to fetch. Example: If you're not interested in sleep, then FitbitSeer will ignore sleep data.
  • Adding triggers and actions is of course possible, but I don't know which triggers and actions are needed...?
  • Possibly convert datafetch from poll to push making the plugin display "live" data, but this is not something needed right away.


Intallation and updating is pretty straight forward, but a summary is given here:
  1. Updating from 0.1.x.x: Dispable the Fitbit plugin if it's running!
  2. Updating from 0.1.x.x: Remove the two dlls in /Bin/FitbitSeer
  3. Updating from 0.2.0.0x: You can delete the GIF-files in /html/Images/FitbitSeer
  4. Unzip all files to your HomeSeer directory, and overwrite
  5. Updating from 0.1.x.x: You're done, go to the last step!
  6. Go to Plugins -> Manage and enable FitbitSeer.
  7. Go to Plugins -> FitbitSeer -> Configuration
  8. (Optional) Select default location1 and location2
  9. Press "Submit" at the bottom of the page to add a new account
  10. Click the link to the left on the new page, log in to Fitbit to authorize FitbitSeer, and copy the PIN.
  11. Paste the bin in the textbox to the right.
  12. Voilà!
  13. (Optional) The account name will prefix all devices so that it's easier to identify them (in Events or HStouch). This is automatically set to your "display name" (usually your first name), but you can change it if you want.
  14. Updating from 0.1.x.x: Now open the root devices and go to the Fitbit tab. All accounts needs to be re-authenticated.
  15. Updating from 0.2.0.0: Open the root device, check the "Heartrate" checkbox at the bottom if you have a tracker that reads HR.


READ THIS ABOUT AUTHENTICATION:
Authenticating with HomeSeer requires a little "hack". I can't possibly know all the different IPs and ports used for HS, and having a valid return URL is required for OAuth2.0. So that's a problem. I set "http://localhost" as the return URL because then you will KNOW that I am NOT sending this code to anybody else, it is only for you (see privacy statement below). This will not resolve, unless you happen to have a web server (like HS) on the machine you are using. But the URL wont work in any case. We are not interested in the page, but in the URL itself. Here's an example of what you get after you click on the "Authenticate" URL, log in to Fitbit and hit OK:
Code:
http://localhost/?code=c821b14f9abdf90ec154140108f83e613e21e7c9#_=_
Here we are only interested in the part between "code=" and "#_=_", that means the blue bit here:
http:// localhost/?code=c821b14f9abdf90ec154140108f83e613e21e7c9#_=_
Copy that bit, and paste it back into the text box in the device settings on the root. If successful, FitbitSeer will fetch your userID and display alot of checkboxes. Just hit "Done" at the bottom, because you are done.

... and one last thing:
Authentication WILL FAIL WITH NO ERROR (at the moment) if there's a "Newtonsoft.Json.dll" in the HomeSeer directory or in the /Bin-folder (if it's in /bin/some_subfolder is fine, however). I encountered that problem when testing the plugin on my main system. Just a heads upp



Privacy statement:
I do not log anything at all. There's only (encrypted over HTTPS) communication between your HomeSeer installation and the Fitbit servers, nothing more (that I am aware of, anyway). I really, really don't care how active or little active you are, if you wear your heartrate monitor during sexy time, how much you weigh or how many bottles of water you drink every day.



Changelog:
0.2.0.10
- Added heartrate devices, see image above.
- New Fitbit.net library
- New icons!

0.2.0.0
- OAuth2.0 conversion with Fitbit.NET 2.0 RC3. BETA!
- You DO NOT have to remove any devices, all current devices will work!
- I had to go back to 0.1.0.2 to make this work, so most of the new features I was planning are gone (for now).
- Known bug: Logging is almost nothing, and I'll fix this soon. If you want to see what's going on, then stop the plugin, enable "Developer Mode" on to of the plugin management page, and restart the plugin. (Remember to uncheck the "Developer Mode" after restarting the plugin or you'll get a console window for each plugin the next time you restart HS!)
- Known bug: I actually don't know if the check boxes on the root device -> Fitbit-tab works or not. I think they do, but I'm not sure.
- Know "bug" (but unfixable): If FitbitSeer or HomeSeer is stopped for more than 8 hours, you will need to re-authenticate your accounts.

0.1.0.1:
- Added stair count
- Hopefully corrected for imperial units
- Corrected "Weight Weight". But please delete that device before upgrading (don't worry, it'll get recreated).
- Moved the submenu lower on the Configuration page

If you're upgrading then you just need the exe-file in the updated zip-file below.


Comments are most welcome!
If would be great if you give me a hint below if you test it.
Attached Files
File Type: zip HSPI_FitbitSeer 0.2.0.0.zip (377.8 KB, 108 views)
File Type: zip HSPI_FitbitSeer 0.2.0.10.zip (458.6 KB, 50 views)
__________________
HSPro 3.0.0.435, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
Running on Windows 10 (64) virtualized
on ESXi (Fujitsu Primergy TX150 S8).
WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

Last edited by Moskus; November 27th, 2017 at 07:42 AM.
Reply With Quote
  #2  
Old June 18th, 2015, 09:58 AM
dcdelong's Avatar
dcdelong dcdelong is offline
Seer Deluxe
 
Join Date: Oct 2011
Location: Indiana\Ohio
Posts: 303
My wife and I also have FitBits. Will load this up over the week-end.

Chris
__________________
HSPRO3 3.0.0.368 on HP 8000, 9 SONOS, Vista p20 alarm, 3 IPads and HP Touch Screen, 22 z-Wave, 54 INSTEON

Plugins :BLBackup:,Pushover 3P:,Wiimote:Winery,HSTV:,Insteon:,PHLocation:,drhsIpPlugIn:, UltraNetatmoWelcome3:,UltraSighthoundVideo3:,Vista Alarm:,UltraCID3:,Random:,EasyTrigger:,iAutomate RFID:,FitbitSeer:,Z-Wave:,HSTouch Server:,weatherXML:,Sonos:,Restart:,UltraGCIR3:,UltraPioneer AVR3:JowiHue;WiiMote;MyQ
Reply With Quote
  #3  
Old June 18th, 2015, 02:20 PM
TechHA's Avatar
TechHA TechHA is offline
Seer Master
 
Join Date: Jul 2005
Location: Dracut, MA USA
Posts: 1,082
Nice job on the plug-in so far. I just got a Fitbit today so just figuring things out.

Some notes so far...
* My weight in Fitbit is 165 lbs., in Fitbitseer it's showing up as 74.7 lbs.
* On the config screen the 'Submit' button for add new account is sitting in Homeseer's bottom tool bar (see picture)
* Also, on the config screen I see how to Add an account but can we also get a list of current accounts and have the ability to remove one? I know it's beta but figured I'd throw the idea out there.

Thanks for a nice way to keep track of the Fitbits. Look forward to seeing how this plug-in evolves.
Attached Images
 
__________________
Bryan
Software/Hardware: Win10 Pro, HS 3 Pro, HS Touch, Echo, Edgeport/4, Z-Net w/88 Devices, Insteon PLM w/19 Devices, Nest, GC-100-6, W800RF32A, WS-2080 Weather Station (KMADRACU10)
Plug-in/Scripts: Alexa API, BLBackup, BLGData, BLLED, BLLock, BLRF, BLTVGuide, Blue Iris, BLUPS, Current Cost 3P, DirectTV, FitbitSeer, Insteon, Nest, Pushover 3P, Random, Restart, Tasker, UltraGCIR3, UltraWeatherWU, Z-Wave
Reply With Quote
  #4  
Old June 18th, 2015, 02:59 PM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Quote:
Originally Posted by TechHA View Post
* My weight in Fitbit is 165 lbs., in Fitbitseer it's showing up as 74.7 lbs.
Thanks for catching this. It appears that Fitbit, even if it's an american company, is using SI-units in their database. 165 lbs is 74.7 kg, so I will need to do some conversion. Thanks!

May I ask you also to double check the "Distance"? Is it the same as it's listed on fitbit.com?


Quote:
Originally Posted by TechHA View Post
* On the config screen the 'Submit' button for add new account is sitting in Homeseer's bottom tool bar (see picture)
Yes, it should be. I noticed that after publishing. I'll solve that later.


Quote:
Originally Posted by TechHA View Post
* Also, on the config screen I see how to Add an account but can we also get a list of current accounts and have the ability to remove one? I know it's beta but figured I'd throw the idea out there.
Perhaps I should explan this:

If you want to remove an account, just delete the root device for that account and all it's child devices. All the account data is stored in the root.
Reply With Quote
  #5  
Old June 18th, 2015, 03:46 PM
gearyt's Avatar
gearyt gearyt is offline
Super Seer
 
Join Date: Apr 2006
Location: Las Vegas
Posts: 1,625
looks like a great way to start a "war" between my wife and I
Will order 2 over the weekend and install plug-in
__________________
Ubuntu 16.10 (64) | HSPro 3.0.0.297 | Z-Wave 3.0.1.124 | Server .94 | BL BackUp | BLOccupied | BLLock | Media Controller | Jowi HUE | HSTouch | DSC-Envisalink | I-Tunes DAAP | DirecTV | Restart | Honeywell WiFi | Weather XML | RFX Com | + Android .117 : IOS 8
Reply With Quote
  #6  
Old June 18th, 2015, 04:10 PM
cheeryfool's Avatar
cheeryfool cheeryfool is online now
Super Seer
 
Join Date: Apr 2008
Location: Jersey Shore
Posts: 1,731
I hope everyone bought FIT stock as well as their gadgets. Up 50% on today's IPO!
Unfortunately I did not.
__________________
cheeryfool
Reply With Quote
  #7  
Old June 18th, 2015, 04:32 PM
gearyt's Avatar
gearyt gearyt is offline
Super Seer
 
Join Date: Apr 2006
Location: Las Vegas
Posts: 1,625
Quote:
Originally Posted by gearyt View Post
looks like a great way to start a "war" between my wife and I
Will order 2 over the weekend and install plug-in
Plug-in installed, devices to be delivered Sat...
Reply With Quote
  #8  
Old June 18th, 2015, 04:35 PM
TechFan's Avatar
TechFan TechFan is offline
Seer Master
 
Join Date: Oct 2013
Location: WA
Posts: 944
No fitbit here. I use my pebble for activity tracking.

I am looking forward to checking out your example plugin code. . .:-)
Reply With Quote
  #9  
Old June 18th, 2015, 04:58 PM
TechHA's Avatar
TechHA TechHA is offline
Seer Master
 
Join Date: Jul 2005
Location: Dracut, MA USA
Posts: 1,082
Looks like the Distance is also off, as you thought. Fitbit website says: .37 miles and Fitbitseer says: .6 miles

Thanks
Reply With Quote
  #10  
Old June 18th, 2015, 10:53 PM
cjohlandt's Avatar
cjohlandt cjohlandt is online now
Seer Plus
 
Join Date: Aug 2002
Location: Maryland, USA
Posts: 83
I just installed and I'm very impressed for an initial beta. I can confirm that weight and distance are incorrect. The name of the weight device is "Chris Weight Weight".

I have a Charge HR and would like to add Stairs and Resting Pulse to the wish list for data to fetch.

Thoughts for triggers and actions... I'm currently using IFTTT to send me a text message if I haven't hit my steps or stairs goals by a certain time each day. It would be great if I could have HomeSeer prompt me to walk a bit more through the speaker interface. Another great use would be if Fitbit says I'm sleeping, put the house in sleep mode.

I originally got a Fitbit when they first came out to track my sleep and got hooked on all of the other data. I moved to a Beddit about a year ago for sleep tracking - it provides a more detailed analysis of your sleep and you don't have to wear anything.

Thanks for writing this plugin and I look forward to its evolution!

-Chris
Reply With Quote
  #11  
Old June 19th, 2015, 03:04 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Hi everyone, and thanks for testing!
I'll get a new version out today with the most urgent bug fixes (such as metric vs imperial conversion, and "weight weight").



Quote:
Originally Posted by TechFan View Post
No fitbit here. I use my pebble for activity tracking.

I am looking forward to checking out your example plugin code. . .:-)
I didn't even know Pebble could do activity tracking. It's a "Pebble Time", right? As I'm pretty sure my Kickstarter Pebble can't do that.

I'm always wearing three devices. My phone (Lumia 930), my Pebble and my Fitbit One.


Quote:
Originally Posted by TechHA View Post
Looks like the Distance is also off, as you thought. Fitbit website says: .37 miles and Fitbitseer says: .6 miles
Thanks!

Quote:
Originally Posted by cjohlandt View Post
I just installed and I'm very impressed for an initial beta. I can confirm that weight and distance are incorrect. The name of the weight device is "Chris Weight Weight".

I have a Charge HR and would like to add Stairs and Resting Pulse to the wish list for data to fetch.

Thoughts for triggers and actions... I'm currently using IFTTT to send me a text message if I haven't hit my steps or stairs goals by a certain time each day. It would be great if I could have HomeSeer prompt me to walk a bit more through the speaker interface. Another great use would be if Fitbit says I'm sleeping, put the house in sleep mode.

I originally got a Fitbit when they first came out to track my sleep and got hooked on all of the other data. I moved to a Beddit about a year ago for sleep tracking - it provides a more detailed analysis of your sleep and you don't have to wear anything.

Thanks for writing this plugin and I look forward to its evolution!

-Chris
Fitbit.NET haven't made fetching data for "stairs" easy, we use it alot so I would love to get that into the plugin. I may have to build my own datafetcher for that, but I'm hoping to avoid it. The same goes for "Resting pulse".

However, I don't think it's impossible, it's just a matter of knowing where to look. We might have to test a little bit (I don't have a HR so "Resting pulse" isn't available to me), but we'll try. Instead of sending beta-versions of the plugin, I might just send you a single exe-file. You run it and paste the data to me.


Triggers and actions:
So far I haven't done anything special with those, as I can't imagine a scenario not covered by the options already offered by HomeSeer. All the devices are populated with device values and can therefore be used as triggers or conditions.

Here's a brief description of the device values:
- Active minutes: The sum of "fairly active" and "very active" (the same as the Fitbit apps)
- Calories burned: Self explanatory
- Distance: ...
- Steps: ...
- Speep start / end: The sum of hour * 60 + minutes
- Quality: Just the "Efficiency" in a range from 0 to 100 (percent)
- Time asleep: Total minutes
- Time in bed: Total minutes
- Weight: ...

So if you want a condition set to something like "IF time slept is less than 7 hours", it should be set "this device has a value less than" and the value is 420 (7*60).

We've been using Fitbit for sleep tracking when we got the Ones, in desember 2013. So we have 2.5 years of sleep data. While not perfect, it still gives a "guesstimate" on how the night was. However, I've ordered a Luna bed cover to take care of this, and a user here says he has ordered the SDK version so he can write a plugin for that as well.
Reply With Quote
  #12  
Old June 19th, 2015, 03:19 AM
TechFan's Avatar
TechFan TechFan is offline
Seer Master
 
Join Date: Oct 2013
Location: WA
Posts: 944
Yes, there are at least two apps for the original (what I have) that do tracking. Misfit and another, plus I use Morpheuz for sleep tracking and smart alarm (wake up while you are already moving during a range). And of course the pebble app to control HS.


Sent from my iPad using Tapatalk
Reply With Quote
  #13  
Old June 19th, 2015, 03:38 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
OK, I've been digging a little more in the Fitbit API and the dataset is HUGE! Yes, all the data is there. It's just a matter of finding the correct data.
Reply With Quote
  #14  
Old June 19th, 2015, 05:58 PM
TechHA's Avatar
TechHA TechHA is offline
Seer Master
 
Join Date: Jul 2005
Location: Dracut, MA USA
Posts: 1,082
Just installed FitbitSeer 0.1.0.1.

Some things I noticed:
* Weight and Distance are now correct for lbs and miles.
* Add user button is out of the toolbar and looks much better
* Weight Weight is fixed

Great update!
Reply With Quote
  #15  
Old June 19th, 2015, 06:09 PM
macromark's Avatar
macromark macromark is offline
HomeSeer Technologies
 
Join Date: Oct 2004
Location: NH
Posts: 3,207
Very cool!

Just tweeted this thread!

https://twitter.com/HomeSeer/status/612021121953759232
__________________


website | products | support | youtube
Reply With Quote
  #16  
Old June 19th, 2015, 09:59 PM
pcp pcp is offline
Super Seer
 
Join Date: Jan 2006
Location: MA
Posts: 1,679
Just installed FitbitSeer 0.1.0.1. Easy setup and reporting fine the values. Thanks!
Reply With Quote
  #17  
Old June 19th, 2015, 10:24 PM
cjohlandt's Avatar
cjohlandt cjohlandt is online now
Seer Plus
 
Join Date: Aug 2002
Location: Maryland, USA
Posts: 83
I just upgraded to 0.1.0.1. So far all looks great - weight in pounds and distance in miles. Double "weight" is gone, but I did have to manually remove the old weight device in kgs. Interestingly, the name had changed to the new "Chris Profile Weight".

Thanks for adding Stairs!

-Chris
Reply With Quote
  #18  
Old June 19th, 2015, 10:30 PM
Mr_Resistor Mr_Resistor is online now
Seer Deluxe
 
Join Date: Jan 2010
Location: San Francisco Bay Area
Posts: 389
Would be awesome to add Battery Level. But working great.
Reply With Quote
  #19  
Old June 20th, 2015, 01:48 PM
cjohlandt's Avatar
cjohlandt cjohlandt is online now
Seer Plus
 
Join Date: Aug 2002
Location: Maryland, USA
Posts: 83
Quote:
Originally Posted by jfryhling View Post
Would be awesome to add Battery Level. But working great.
+1
Reply With Quote
  #20  
Old June 20th, 2015, 05:19 PM
gearyt's Avatar
gearyt gearyt is offline
Super Seer
 
Join Date: Apr 2006
Location: Las Vegas
Posts: 1,625
Fit Bits are here !!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fitbit tracker / Aria Scale potential plugin? danchallis HomeSeer General Discussion Area 10 April 14th, 2015 04:55 AM
Beta testers Rauco ROC Plug-Ins 0 May 13th, 2008 05:22 PM
Looking for Beta Testers.. pjcolley pjc Network 6 January 28th, 2008 04:40 AM
Looking for UK Beta Testers rjh HomeSeer Z-Wave Plug-in 5 June 6th, 2007 09:49 AM
IRTrans .net Plugin BETA Testers Wanted YoYo Plug-In Development 0 March 25th, 2006 05:56 PM


All times are GMT -4. The time now is 11:52 PM.


Copyright HomeSeer Technologies, LLC