[Release] Withings Integration (New Management)

With the previous developer no longer maintaining the Withings Integration, I am releasing this version as being under new management. This version includes all original features, including support for integrating Withings Sleep Sensors, Activity Trackers, Scales, Blood Pressure Monitors, and Thermometers via the official Withings cloud API. This version also adds additional features including:

  • Support for logging more detailed data to a local file, via the File Manager driver. Access this feature in the parent app. At the moment I only coded to log certain data that was useful for me, but I'll consider adding other data as others find a use for it. Coupled with the Quick Chart app, this allows you to replicate the sleep state chart from Withings (see below), the heart rate chart, etc.
  • Adds additional fields for the sleep driver
  • Adds ability to restrict updates to sleep data to a certain time window (e.g., between 5-9am). This avoids polluting the sleep data from brief moments during the day when something or someone is on the bed.

My goal with these enhancements was to recreate the Withings sleep dashboard, which resulted in the example dashboard below (still a work in progress)

I've put the new code on HPM, as well as on GitHub. Search HPM for tags Health & Fitness or Sleep.

Migration Instructions for not losing existing devices (if installed via HPM)

  1. Unmatch old version from HPM
  2. Copy/paste in new code from github manually.
  3. Perform HPM Matchup to the new version.
  4. In each Withings Device child app, open the app and go through the process to click Done (shouldn't have to reauthorize though).
  5. If you end up with duplicate code in the App Code or Driver Code section, you can safely delete the old code (under the dcmeglio namespace) once you confirm everything is working with the new code (under the lnjustin namespace)
14 Likes

@JustinL

I'm getting the following when I try to add a user.

Hm. Haven't seen that one before. I will try to reproduce. How did you transition to the new code? Did you unmatch from HPM and re-match up?

@JustinL Thank you!!!! While I only have my Withings scale, I am sure others with Withings products will appreciate your effort and time. Thank you again sir! Are you gonna get this into HPM?

1 Like

Yes, it’s there

1 Like

Do you have to do a matchup in HPM or will it just continue updating normally?

Unmatch first. Copy/paste in new code. Then matchup to the new listing.

Or otherwise you’d have to reinstall everything, which I’m sure is undesirable for everyone.

Will be interesting to see if this works to keep the devices all installed without a hiccup. I’m skeptical given the namespace change but it’s been working for me

1 Like

Can someone confirm successful migration? Would be helpful to know it's all set up correctly and that the namespace change didn't mess existing installations up.

I was not able to reproduce this error after adding a new user and new device to my account.

Overall, my migration was successful. It is very likely I goofed something up along the way as I ended up with duplicate code for the apps and drivers . I just deleted the older entries and all was well. No re-auth or additional setup needed. Thank you for sharing!

1 Like

The first time I just added your version via HPM because I rely heavily on this integration and didn't want to break what was otherwise working.

When that didn't work, I deleted everything (including the old version and users). Unfortunately, I'm still getting that message.

I tried installing without HPM and got the same result.

I can't replicate it either. I manually installed the apps and drivers from GitHub then unmatched it in HPM and was able to match the correct one in HPM.

Working fine for me even with adding new users.

I'm afraid I'm at a loss as to how to troubleshoot the error on my end, especially since I can't replicate it and some others can't either. I can confirm that the code shows the right parent-child relationship, so the code description doesn't lead me down a path that would fix the error. I wonder if contacting support as the error suggests would help...

Okay, I got to the bottom of this. I recalled some time last year I ran into a similar problem and the solution was to repair HPM.(see post 124 of [RELEASE] Xiaomi Aqara and Mijia Drivers with Device Presence - #124 by csteele) So, I did that and voilà, installed no problem after that.

4 Likes

So now I have a new mystery. Since going to bed last night and getting up this morning I've received three emails from Withings with "Impossible to reach your server" in the subject line. Here's a redacted version of the email:

The User Id checks out, and the first bit of info is my hub UID, but token info doesn't match anything I can find. So, I suspect that is where the problem lies. If I click on the link in the email I get this:

At the Withing's developer portal page I tested the registered URL and it gave me this error:

Odd thing is, everything is updating properly within the Hubitat app as far as I can tell and it's correctly passing on the state to node-RED. But, the developer site does say my user (me) will be removed from the app if this happens four consecutive times in 20 days.

Thoughts?

My guess is this is a relic from your previous install and it won’t matter if the notification gets removed by Withings. Anything to suggest that might be the case?

I suspected the same thing. So, as an experiment I deleted the app in the Withings developer portal, deleted everything from my hub and started over. I'm still getting Partner error: Host Unreachable on the Withings page, but otherwise it seems like it's working fine and I haven't received any additional emails. To be fair, I don't recall ever testing the registered URL under the old version so I can't say this is new.

The main thing that concerned me was on this page:

"If during a period of 20 days, there are more than 4 consecutive failures for a specific user the subscription for this user will be removed." I'll see how it plays out and let you know if anything interesting comes up.

On to a feature request note. When setting up the users there is a section about turning something on when getting into bed and turning it off when getting out of bed. Could we get an option to do the exact opposite. For example, turning on a night light getting out of bed, but turning it off getting into bed?

Thanks a ton for taking this project over. I use the presence attribute extensively with my node-red presence flows, so I very much appreciate your work. You're not the hero we deserve, but you're the hero we need. :wink:

1 Like

I understand your use case. But I believe Rule Machine or Simple Automations is more appropriate for this sort of thing. You wouldn't want the night light to turn on every time bed presence goes to 'not present', even during the middle of the day. You would want to limit the night light to being turned on only during cetaint times of day (when it's night). Otherwise your night light might turn on after someone or something gets off the bed during the day.

The point of having the switch as an output in the Withings app was simply to have a switch reflect the presence status, so that the switch can then be used in other apps (like Rule Machine) for automations. It's simple to set up a Rule Machine rule to turn the night light on and off based on the output switch's status. It would become a slippery slope as to what automations Withings should have built-in if rules like this were to be added. And this is the model that most apps adopt. Do you get my point?

3 Likes

I hadn't thought about using a switch to reflect presence but that makes a lot of sense. I always wondered why that option was in there. Your point about the slippery slope is more than valid.

Since I'm using node-red, I never use the rule machine so I didn't think about that either. I do have flows in node-red to turn on a nightlight; which has time gates and timers to control the when and how long aspects. There's just enough of a delay to make that solution less than ideal. In my use case I need the light to be as instant as possible. It's a long story, but the short version is my cat has severe asthma and I frequently have to wake up in the middle of the night to give him his rescue inhaler.

Anyway, I've been putting it off for the sake of consolidation, but if I'm being honest with myself, I've got automation scattered all over the place at this point. So, I suppose it's time to get my hands dirty with rule machine. :wink:

I truly appreciate the response and the effort you're putting into this project. As I mentioned earlier, I have a fairly complex presence detection scheme (see pic) and this component is one of the keys to its continued success.

Cheers!

1 Like

@JustinL nice job consolidating this automation -- thank you.

I reinstalled the new automation via HPM and created my two new users from scratch, so just everything was clean. When I did, I noticed a recurrence of an old problem--my scale shows up with the name "Null", even though when I look at the device with the Withings web portal, it has the correct name.

So I reached out to Withings support, and they're asking me what link I'm using to access the API? Do I just give them the API endpoint URL or is the answer specific to this app? TIA...