[No Longer Maintained] Withings Integration

Do you have anything in place (firewall wise) that would be preventing your hub from talking to the internet? That looks like a communication error between your hub and the hubitat cloud.

@dman2306, thanks for this awesome work.

I had an issue that I was able to track down, wanted to share the fix with you. Short version is that I have the (new'ish) Withings Scanwatch. Apparently the API does not return a 'model' for the Scanwatch. Because device.model was null, the prefDevices page in the Withings User app would fail.

I fixed this up by slightly tweaking getWithingsDevices(). Unfortunately I'm not smart enough to figure git out, so here's the closest I can get to formally submitting a fix for this issue:

else if (device.type == 'Activity Tracker') {
if (device.model != null) {
activityTrackers[device.deviceid] = device.model
} else {
activityTrackers[device.deviceid] = 'Undefined Activity Tracker'
}
}

Looking forward to kicking the tires on this integration as I have all 5 devices types. Thanks for your work on this.

@dman2306, are you still maintaing this intergration? I'm having some trouble with 3 of the 5 device types.

Yes. I just have been busy lately. Can you provide details on what isn’t working? I only own a scale and sleep pad personally so those are the only ones I have tested myself.

What are you using the scale integration for? I integrated mine, but can't really find a use for it in hubitat.

1 Like
IF (this week’s weight > last week’s weight)
THEN
Turn on siren, lock fridge door
END-IF
8 Likes

Guess it depends on your routine. I weigh myself every morning right before I get ready. It’s the perfect trigger for my “brew coffee” routine in the morning, for example. I have a fresh cup waiting for me when I start it based on that weight measurement.

@dman2306: Hey, no worries on being busy -- this is pretty slick as-is, and community-developed means community-supported and so no timeline expectations on this side.

So when I first posted, my issue was that many devices weren't getting any data.
Not sure if your 1.3.1 update re: the child devices fixed something or if it was just a matter of re-linking/re-authorizing the Withings account, but it does now look like everything gets data.

So, getting data & working:

  • Aura Dock: Giving detailed sleep details. This is the old alarm clock/sleep sensor v1. I still use the alarm, but no longer use the sleep sensor v1.
  • Aura Sensor V2: Giving present/not present.
  • Body Cardio: Giving detailed weight/body composition figures
  • BPM Connect: Giving blood presure figures (curiously, before I assign it to me in the Thermo app)
  • Scanwatch: Giving detailed step, sleep data

Getting data but not displaying quite properly:

  • Thermo: 97.4 F displays as 2.4111111666666652632152868641747368706597 F. 97.7 F displays as 2.50833294444444416310741669601864284939236. 98.0 F displays as 2.6061121111111083968757561201022730933295355903.

Here is the Hubitat Logs entires for a 98.5F temperature reading, in case it is helpful:

2020-12-16 06:55:00.681 am debug{status=0, body={updatetime=1608119700, timezone=America/New_York, measuregrps=[{grpid=2376505086, attrib=1, date=1608119574, created=1608119688, category=1, deviceid=48e096bb1193927d241ab7a684705a94ce580189, hash_deviceid=48e096bb1193927d241ab7a684705a94ce580189, measures=[{value=369420013, type=71, unit=-7, algo=0, fm=131}], comment=null}]}}

2020-12-16 06:55:00.046 am debugmeasure?action=getmeas -- [startdate:1608119573, enddate:1608119574, category:1]

2020-12-16 06:54:59.939 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1608119574, appli:2, startdate:1608119573, userid:11189638, type:temperature]

Also, I get a NPE after certain updates. Here's the Hubitat Logs entries on that:

2020-12-16 06:23:25.782 am errorjava.lang.NullPointerException: Cannot invoke method multiply() on null object on line 127 (asyncWithingsNotificationHandler)

2020-12-16 06:23:25.724 am debug{status=0, body={series=[{id=1759136186, timezone=America/New_York, model=32, model_id=63, startdate=1607998980, enddate=1608028500, date=2020-12-15, data={wakeupduration=1860, lightsleepduration=12360, deepsleepduration=10980, wakeupcount=1, durationtosleep=1320, remsleepduration=4140, durationtowakeup=0, hr_average=67, hr_min=58, hr_max=82, rr_average=13, rr_min=10, rr_max=26, breathing_disturbances_intensity=15, snoring=0, snoringepisodecount=0, sleep_score=90}, created=1608020810, modified=1608117792}, {id=1758937126, timezone=America/New_York, model=16, model_id=93, startdate=1607999760, enddate=1608028740, date=2020-12-15, data={wakeupduration=840, lightsleepduration=16800, deepsleepduration=11340, wakeupcount=1, durationtosleep=120, durationtowakeup=180, hr_average=68, hr_min=63, hr_max=77, sleep_score=79}, created=1608012734, modified=1608029174}, {id=1760531815, timezone=America/New_York, model=32, model_id=63, startdate=1608090900, enddate=1608113400, date=2020-12-16, data={wakeupduration=3240, lightsleepduration=13320, deepsleepduration=3720, wakeupcount=1, durationtosleep=3180, remsleepduration=2100, durationtowakeup=0, hr_average=66, hr_min=59, hr_max=95, rr_average=12, rr_min=8, rr_max=20, breathing_disturbances_intensity=19, snoring=0, snoringepisodecount=0, sleep_score=35}, created=1608104254, modified=1608117793}, {id=1760714910, timezone=America/New_York, model=16, model_id=93, startdate=1608091320, enddate=1608113460, date=2020-12-16, data={wakeupduration=1260, lightsleepduration=14400, deepsleepduration=6480, wakeupcount=3, durationtosleep=120, durationtowakeup=60, hr_average=67, hr_min=43, hr_max=81, sleep_score=44}, created=1608113366, modified=1608115354}], more=false, offset=0}}

2020-12-16 06:23:25.081 am debugv2/sleep?action=getsummary -- [startdateymd:2020-12-15, enddateymd:2020-12-16, data_fields:breathing_disturbances_intensity,deepsleepduration,durationtosleep,durationtowakeup,hr_average,hr_max,hr_min,lightsleepduration,remsleepduration,rr_average,rr_max,rr_min,sleep_score,snoring,snoringepisodecount,wakeupcount,wakeupduration]

2020-12-16 06:23:24.598 am errorjava.lang.NullPointerException: Cannot invoke method multiply() on null object on line 127 (asyncWithingsNotificationHandler)

2020-12-16 06:23:24.255 am debug{status=0, body={series=[{id=1757427221, timezone=America/New_York, model=16, model_id=93, startdate=1607913180, enddate=1607978760, date=2020-12-14, data={wakeupduration=5580, lightsleepduration=40920, deepsleepduration=19080, wakeupcount=8, durationtosleep=120, durationtowakeup=180, hr_average=72, hr_min=61, hr_max=114, sleep_score=74}, created=1607927249, modified=1607979901}, {id=1757646018, timezone=America/New_York, model=32, model_id=63, startdate=1607912100, enddate=1607979780, date=2020-12-14, data={wakeupduration=2280, lightsleepduration=36240, deepsleepduration=7080, wakeupcount=6, durationtosleep=1500, remsleepduration=20400, durationtowakeup=0, hr_average=69, hr_min=55, hr_max=91, rr_average=13, rr_min=9, rr_max=24, breathing_disturbances_intensity=27, snoring=180, snoringepisodecount=1, sleep_score=83}, created=1607936046, modified=1608117792}, {id=1759136186, timezone=America/New_York, model=32, model_id=63, startdate=1607998980, enddate=1608028500, date=2020-12-15, data={wakeupduration=1860, lightsleepduration=12360, deepsleepduration=10980, wakeupcount=1, durationtosleep=1320, remsleepduration=4140, durationtowakeup=0, hr_average=67, hr_min=58, hr_max=82, rr_average=13, rr_min=10, rr_max=26, breathing_disturbances_intensity=15, snoring=0, snoringepisodecount=0, sleep_score=90}, created=1608020810, modified=1608117792}, {id=1758937126, timezone=America/New_York, model=16, model_id=93, startdate=1607999760, enddate=1608028740, date=2020-12-15, data={wakeupduration=840, lightsleepduration=16800, deepsleepduration=11340, wakeupcount=1, durationtosleep=120, durationtowakeup=180, hr_average=68, hr_min=63, hr_max=77, sleep_score=79}, created=1608012734, modified=1608029174}], more=false, offset=0}}

2020-12-16 06:23:24.243 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1608113400, appli:44, startdate:1608090900, userid:11189638, type:sleep]

2020-12-16 06:23:24.215 am errorjava.lang.NullPointerException: Cannot invoke method multiply() on null object on line 127 (asyncWithingsNotificationHandler)

2020-12-16 06:23:24.135 am debug{status=0, body={series=[{id=1755778551, timezone=America/New_York, model=32, model_id=63, startdate=1607828820, enddate=1607881740, date=2020-12-13, data={wakeupduration=6540, lightsleepduration=26280, deepsleepduration=6600, wakeupcount=10, durationtosleep=3000, remsleepduration=12300, durationtowakeup=0, hr_average=74, hr_min=60, hr_max=92, rr_average=13, rr_min=9, rr_max=22, breathing_disturbances_intensity=20, snoring=0, snoringepisodecount=0, sleep_score=75}, created=1607840656, modified=1607892126}, {id=1756190113, timezone=America/New_York, model=16, model_id=93, startdate=1607829240, enddate=1607884200, date=2020-12-13, data={wakeupduration=5580, lightsleepduration=34020, deepsleepduration=15360, wakeupcount=8, durationtosleep=240, durationtowakeup=0, hr_average=76, hr_min=55, hr_max=99, sleep_score=74}, created=1607857519, modified=1607892127}, {id=1757427221, timezone=America/New_York, model=16, model_id=93, startdate=1607913180, enddate=1607978760, date=2020-12-14, data={wakeupduration=5580, lightsleepduration=40920, deepsleepduration=19080, wakeupcount=8, durationtosleep=120, durationtowakeup=180, hr_average=72, hr_min=61, hr_max=114, sleep_score=74}, created=1607927249, modified=1607979901}, {id=1757646018, timezone=America/New_York, model=32, model_id=63, startdate=1607912100, enddate=1607979780, date=2020-12-14, data={wakeupduration=2280, lightsleepduration=36240, deepsleepduration=7080, wakeupcount=6, durationtosleep=1500, remsleepduration=20400, durationtowakeup=0, hr_average=69, hr_min=55, hr_max=91, rr_average=13, rr_min=9, rr_max=24, breathing_disturbances_intensity=27, snoring=180, snoringepisodecount=1, sleep_score=83}, created=1607936046, modified=1608117792}], more=false, offset=0}}

2020-12-16 06:23:23.631 am debugv2/sleep?action=getsummary -- [startdateymd:2020-12-14, enddateymd:2020-12-15, data_fields:breathing_disturbances_intensity,deepsleepduration,durationtosleep,durationtowakeup,hr_average,hr_max,hr_min,lightsleepduration,remsleepduration,rr_average,rr_max,rr_min,sleep_score,snoring,snoringepisodecount,wakeupcount,wakeupduration]

2020-12-16 06:23:23.586 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1608028500, appli:44, startdate:1607998980, userid:11189638, type:sleep]

2020-12-16 06:23:23.530 am debugv2/sleep?action=getsummary -- [startdateymd:2020-12-13, enddateymd:2020-12-14, data_fields:breathing_disturbances_intensity,deepsleepduration,durationtosleep,durationtowakeup,hr_average,hr_max,hr_min,lightsleepduration,remsleepduration,rr_average,rr_max,rr_min,sleep_score,snoring,snoringepisodecount,wakeupcount,wakeupduration]

2020-12-16 06:23:23.472 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1607979780, appli:44, startdate:1607912100, userid:11189638, type:sleep]

2020-12-16 06:23:23.057 am debug{status=0, body={activities=[{steps=81, distance=64.47, elevation=2, soft=600, moderate=0, intense=0, active=0, calories=2.338, totalcalories=1767.471, hr_average=64, hr_min=61, hr_max=69, hr_zone_0=8436, hr_zone_1=0, hr_zone_2=0, hr_zone_3=0, deviceid=null, timezone=America/New_York, date=2020-12-16, brand=18, is_tracker=true}], more=false, offset=0}}

2020-12-16 06:23:22.470 am debugv2/measure?action=getactivity -- [startdateymd:2020-12-16, enddateymd:2020-12-16, data_fields:steps,distance,elevation,soft,moderate,intense,active,calories,totalcalories,hr_average,hr_min,hr_max,hr_zone_0,hr_zone_1,hr_zone_2,hr_zone_3]

2020-12-16 06:23:22.412 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, date:2020-12-16, appli:16, userid:11189638, type:activity]

2020-12-16 06:23:22.014 am debug{status=0, body={updatetime=1608117801, timezone=America/New_York, measuregrps=}}

2020-12-16 06:23:21.300 am debugmeasure?action=getmeas -- [startdate:1608117701, enddate:1608117702, category:1]

2020-12-16 06:23:21.240 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1608117702, appli:1, startdate:1608117701, userid:11189638, type:weight]

Let me know if there's anything you'd find useful, I'll make it happen!

I like your idea of triggering actions based on scale activity! I've also been kicking the tires on using bed sensor presence blended with time of day to trigger wake-up actions -- seems fast enough (~5 seconds or so).

Thanks, again, for this integration.

Interesting, the code looks correct and when I ran those values through my function by hand it worked so something not obvious is happening. Can you try out this Withings_user.groovy? https://raw.githubusercontent.com/dcmeglio/hubitat-withings/debug_1216/apps/Withings_User.groovy I added a debug message in the temperature conversion method to see what's going on. Also, I think I fixed the NPE.

Hi @dman2306 thanks for this integration. I have a Smart Body Analyser that gives me a temperature reading & air quality reading both on the scale & health mate app. Neither of these appear in HE, I only see weight & fat mass data. Is it possible to get that data ??
I also just bought a Sleep Analyser, which pushes data to health mate app & web site. But I do not see any data in HE. Just laid on bed for 10 minutes & no log entries. Any ideas or suggestions ??
Thanks.

@dman2306 I also just noticed my scale has a device network id "withings:1234567: followed by a 37 alpha numeric string" & the sleep has a standard alpha numeric HE device network id "12345678-1234-1234-1234-123456789***" Don't know if this means anything or even matters.
As far as I remember both devices were created in the same manner ie as virtual devices then assigned the relevant withings type.

I’ll have to do more research on your other questions but if the device has an id like that, it wasn’t created by my app. The app will create child devices with the withings: as a prefix. This sounds like a device you manually created as a virtual device which won’t have any data since the app knows nothing about it.

@dman2306 Yes I created the sleep device as it was not created by the app. How do I get your app to create it ?? There is now two nights worth of data on health mate that HE does not see. Do all devices need to exist before the app is installed ?? My scale existed on health mate before your app was installed & it picked it up. Two days ago I received & installed my sleep analyser. As no data appeared in HE I created the virtual device.
Do I need to remove your app & everything & start from scratch ?

Just run through the app again. It has to create the devices otherwise it has no clue how to communicate with withings to fetch the data.

OK thanks, deleted everything & started again. Now working. Thank you.

@doogles any chance you were able to give this a try?

Woah, what the heck is up with my username?

Ok, so I confess I am a little embarassed, as it appears my problem was of my own making.
After swapping your user app back in place, I started getting more reasonable-looking temperature values:
app:8342021-01-05 05:46:11.304 am debugTemp: 368720016 Unit: -7 Result: 36.8720016
app:8342021-01-05 05:46:11.292 am debug{status=0, body={updatetime=1609843570, timezone=America/New_York, measuregrps=[{grpid=2406502578, attrib=1, date=1609843483, created=1609843559, category=1, deviceid=48e096bb1193927d241ab7a684705a94ce580189, hash_deviceid=48e096bb1193927d241ab7a684705a94ce580189, measures=[{value=368720016, type=71, unit=-7, algo=0, fm=131}], comment=null}]}}
app:8342021-01-05 05:46:10.570 am debugmeasure?action=getmeas -- [startdate:1609843482, enddate:1609843483, category:1]
app:8342021-01-05 05:46:10.488 am debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1609843483, appli:2, startdate:1609843482, userid:11189638, type:temperature]

The C figure tickled my brain and reminded me that a number of weeks back I tried modifying the Withings user app myself, specifically to output a F value instead of V. But apparently I broke it and gave up working on it, forgot I did that, and then came here and reported the behavior as anissue. My apologies. :frowning:

I'm a little more Groovy-savvy after hacking on Hubitat for a couple of months now, I'll take a second go at it and see if I can add in a C/F toggle as an app-level parameter.

-jd

Ok, so I misspoke/misremembered the situation.

So the debug looks okay:

app:8342021-01-05 03:49:13.466 pm debugTemp: 369609985 Unit: -7 Result: 36.960998499999995
app:8342021-01-05 03:49:13.453 pm debug{status=0, body={updatetime=1609879752, timezone=America/New_York, measuregrps=[{grpid=2407365351, attrib=1, date=1609879680, created=1609879738, category=1, deviceid=48e096bb1193927d241ab7a684705a94ce580189, hash_deviceid=48e096bb1193927d241ab7a684705a94ce580189, measures=[{value=369609985, type=71, unit=-7, algo=0, fm=131}], comment=null}]}}
app:8342021-01-05 03:49:11.854 pm debugmeasure?action=getmeas -- [startdate:1609879679, enddate:1609879680, category:1]
app:8342021-01-05 03:49:11.811 pm debugNotification Received: [access_token:ebce1657-0991-4ec1-867e-5aecb2d7ac8f, enddate:1609879680, appli:2, startdate:1609879679, userid:11189638, type:temperature]

But the device itself gets the weird number:

|id:|992868|
|---|---|
|Date:|2021-01-05 15:49:13.000|
|Name:|bodyTemperature|
|isStateChange:|true|
|source:|DEVICE|
|unit:|F|
|value:|2.75611027777777511321093900025718741946750217014|

I think I spotted the bug but I can't really test since I don't have a Thermo. Could you try grabbing the latest code from https://raw.githubusercontent.com/dcmeglio/hubitat-withings/debug_1216/apps/Withings_User.groovy again?

Hi there,

Thanks for this useful app and drivers, I use this method to integrate my 2 Sleep Sensors (on different accounts) and Scale with HE. I noticed that my lighting automation override didn’t fire up today, and when I checked in the logs I can see under both accounts I have added the following error appears:

Do you know if this is a bug on Withings end via their API - it seems strange that both accounts are doing it.

Cheers
Guy