oh-my-posh icon indicating copy to clipboard operation
oh-my-posh copied to clipboard

Withings Segment Issue

Open GHRoss opened this issue 2 years ago • 1 comments

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

What happened?

Sorry @JanDeDobbeleer, another one!

I've noticed that weight only shows for today, but weight isn't necessarily recorded everyday like the other data. I manually have to input this, as I don't have their scales, for example, so it would be good to just get the latest available weight data, rather than today's weight.

Theme

clean-detailed

What OS are you seeing the problem on?

Linux

Which shell are you using?

powershell

Log output

N/A

GHRoss avatar Jul 27 '22 16:07 GHRoss

@GHRoss can you help me with the API output in your case? I only have mine, and probably I need to loop all measurements until I have the right value but want to be certain.

JanDeDobbeleer avatar Jul 27 '22 16:07 JanDeDobbeleer

Hello @JanDeDobbeleer, my Withings segment is not working. Debug is not showing any logs from the withings api only this line in segments: withings(false) - 0 ms -

Any ideas?

CaptnCodr avatar Aug 17 '22 12:08 CaptnCodr

@CaptnCodr can I get the full logs and the Withings segment config?

JanDeDobbeleer avatar Aug 17 '22 12:08 JanDeDobbeleer

Config:


        {
          "type": "withings",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "green",
          "background": "#ffffff",
          "template": "{{ if gt .Weight 0.0 }} {{ round .Weight 2 }} kg {{ end }} {{ .SleepHours }} {{ .Steps }}",
          "properties": {
            "access_token": "redacted",
            "refresh_token": "redacted",
            "expires_in": 10800,
            "http_timeout": 1500
          },
          "leading_diamond": "\ue0b2",
          "trailing_diamond": "\ue0b2"
        },

Log: omp.log

CaptnCodr avatar Aug 17 '22 12:08 CaptnCodr

@CaptnCodr can you have a look at what's inside the cache? You can get the location using oh-my-posh cache path and open the omp.cache file. If there's some Withings data, remove the cached responses (not the access_token etc.). And try again.

JanDeDobbeleer avatar Aug 17 '22 12:08 JanDeDobbeleer

After removing those cached element I ran oh-my-posh debug following came out:

2022/08/17 14:40:47 error: OAuth
no data in cache
2022/08/17 14:40:47 debug: HTTPRequest
POST /v2/measure HTTP/1.1
Host: wbsapi.withings.net
User-Agent: Go-http-client/1.1
Content-Length: 93
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip

action=getactivity&category=1&data_fields=steps&enddateymd=2022-08-17&startdateymd=2022-08-16
2022/08/17 14:40:47 debug: HTTPRequest
{"status":501,"error":"Invalid Session: sessionid missing"}
2022/08/17 14:40:47 HTTPRequest duration: 202.176ms, args: https://wbsapi.withings.net/v2/measure
2022/08/17 14:40:47 error: OAuth
no data in cache
2022/08/17 14:40:47 debug: HTTPRequest
POST /measure HTTP/1.1
Host: wbsapi.withings.net
User-Agent: Go-http-client/1.1
Content-Length: 59
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip

action=getmeas&category=1&lastupdate=1659530447&meastypes=1
2022/08/17 14:40:47 debug: HTTPRequest
{"status":503,"body":{},"error":"Invalid Params"}
2022/08/17 14:40:47 HTTPRequest duration: 46.6973ms, args: https://wbsapi.withings.net/measure
2022/08/17 14:40:47 error: OAuth
no data in cache
2022/08/17 14:40:47 debug: HTTPRequest
POST /v2/sleep HTTP/1.1
Host: wbsapi.withings.net
User-Agent: Go-http-client/1.1
Content-Length: 50
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip

action=get&enddate=1660737600&startdate=1660683600
2022/08/17 14:40:47 debug: HTTPRequest
{"status":503,"error":"Invalid Params: Missing [access_token]"}
2022/08/17 14:40:47 HTTPRequest duration: 54.9086ms, args: https://wbsapi.withings.net/v2/sleep

CaptnCodr avatar Aug 17 '22 12:08 CaptnCodr

@CaptnCodr yup, that's a Withings API bug. I also had that a few times during development. Can you remove the entire cache and re-authenticate? That could solve the issue.

JanDeDobbeleer avatar Aug 17 '22 13:08 JanDeDobbeleer

I did now, but the access_token in omp.cache does not match with my access_token, is this correct? Re-authentication does not help. Same error messages.

CaptnCodr avatar Aug 17 '22 13:08 CaptnCodr

@CaptnCodr yes, that's correct. It will refresh when needed. I also had that during my testing and couldn't find the root cause. Unless I did ruin something lately. Will try when I'm at home (but did validate that).

JanDeDobbeleer avatar Aug 17 '22 13:08 JanDeDobbeleer

@lnu could this be the same issue you were trying to fix?

JanDeDobbeleer avatar Aug 17 '22 14:08 JanDeDobbeleer

Exactly

lnu avatar Aug 17 '22 15:08 lnu

@CaptnCodr can you try again with the latest? Might need to remove the cache values although it shouldn't.

JanDeDobbeleer avatar Aug 18 '22 06:08 JanDeDobbeleer

Yes, I will test this as soon as I can.

CaptnCodr avatar Aug 18 '22 07:08 CaptnCodr

That works now. Thank you very much. 🙂

CaptnCodr avatar Aug 18 '22 12:08 CaptnCodr

No, not anymore. After 2nd refresh the access_token and refresh_token are now missing from the cache.

Edit: Unfortunately, I did a re-authentication and that might have helped.

CaptnCodr avatar Aug 18 '22 12:08 CaptnCodr

It seems to work properly after deleting cache and re-authenticating. 🙂

CaptnCodr avatar Aug 18 '22 12:08 CaptnCodr

@GHRoss can you help me with the API output in your case? I only have mine, and probably I need to loop all measurements until I have the right value but want to be certain.

@GHRoss any pointers? Would love to fix this one for you ;-)

JanDeDobbeleer avatar Aug 27 '22 19:08 JanDeDobbeleer

@JanDeDobbeleer Sorry for the radio silence, I think this might have solved itself! Also, it's a good reminder to actually measure your weight. I was impacted by the bug that @CaptnCodr raised, but didn't have time to raise it.

GHRoss avatar Aug 29 '22 10:08 GHRoss

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.

github-actions[bot] avatar Jan 01 '24 00:01 github-actions[bot]