Coder Social home page Coder Social logo

Comments (23)

smirko-dev avatar smirko-dev commented on July 24, 2024

Hi @chengjwk
Is your REST Api enabled in your HA instance?
Did you try to reach the REST api by e.g. curl -X GET -H "Authorization: Bearer <your_token>" -H "Content-Type: application/json" <your_url>:<your_port>/api/?

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

{
"message": "API running."
}

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

Can you provide a Fitbit log?
Since the REST Api on your HA is working I need to see what happens on the app side.
Please remove private data like the token becausde of I don't need that.

Stupid question: You granted internet access for the app?

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

How can I pull the log off?

Internet acces is enabled. I checked it a couple times. :-P

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

I wasn't sure if there was a way to see the logs with the released version so I built and installed the app. I cannot confirm the same error as with the released version as I had to uninstall it, but this time I noticed my token was throwing a 401 (via curl). I created a new one and got the valid respone again. I assume I was missing some characters in my token this time? In your code in the fetchApiStatus method:
let data = await response.json(); if (response.status === 200) {
If the response is invalid, the json parsing will fail and obscure the actual error. You probably want:
if(response.ok) { let data = await response.json();
I didn't play much beyond that to ensure the 401 was surfaced to the user, but the error message might be worth the check, to ensure the user has verified settings.

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

Happy that you found the issue.
Thx for the feedback, I will add your suggestion in the next release (most probably v0.6).

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

I'm not sure if this a fitbit sync thing or an app thing... but I retried the release version and got a connection error (on my watch) this time.
I went in (on my phone) and manually clicked all the settings fields and clicked "save" without editting anything as I noticed in the code that those all fired events. After doing that I did manage to connect.

On a likely unrelated note. When I toggle a switch to "ON". I notice that my light turns on, but the UI does NOT change. When I was debugging I noticed that subsequent taps fired continual "ON" events. I see the sendData call, is it also updating the local button state?

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

As I wrote in the description, I just tested the app with the simulation. I'm happy to get feedback from a real device ^^.
In version 0.5 I added a setting to force UI updates with missing HA response. For SDK4 devices the app update is already approved. Check out the branch feature/scripts.

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

I'm running a sense, so SDK5. I'm happy to continue testing with a device if it helps. Thanks for the work!

from fitbit-homeassistant.

blablazzz avatar blablazzz commented on July 24, 2024

I have same issue with duckdns and port 443.

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

Hi @blablazzz,
What exactly is your issue? The problem here was a wrong token. The changes, which @chengjwk suggested you can find in branch feature/bugfixes and are planned for version 0.6.

from fitbit-homeassistant.

blablazzz avatar blablazzz commented on July 24, 2024

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

Hi @blablazzz
Is your REST Api enabled in your HA instance?
Did you try to reach the REST api by e.g. curl -X GET -H "Authorization: Bearer <your_token>" -H "Content-Type: application/json" <your_url>:<your_port>/api/?

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

I can't go back and remember what I did, I also tried creating 4 or 5 tokens before getting it to work, but I have a therory. My mobile device is an Android. In the HA app, when I create a token, the dialog comes up that tells you to "Copy your access token...". If I long-press on the token, and select "cut", it appears to alaways leave some characters there. I assume copy is the same. I made 5 tokens, and they were all missing characters. I suspect I did the same thing originally.

Given the single line text field there, it's really hard to see if you've selected everything. Visually it totally looks like the whole thing is selected. Given there is I think always a period in there, it'll never selct the whole token by default. @blablazzz, I might suggest (assuming you've verified everything else), you try Select all prior to Copy?

@smirko-dev: Assuming this is in fact the issue, t might be worth adding a note to the readme, to avoid more questions like this. :-P It'd be cool if the HA app added a "Copy" button, or at least made it a multiline box so you can easily tell you're missing characters.

from fitbit-homeassistant.

chengjwk avatar chengjwk commented on July 24, 2024

That all said, while I have had it working (I just loaded the app on my watch), currently, I am once again seeing Home Assistant N/A on the app, and I also see a:
Login attempt or request with invalid authentication from in my dashboard notifications. I don't know if it's the watch, but I don't have any other devices on my network that should be trying to connect. I haven't changed any config in the app. I was running I think still 0.6 locally compiled. I don't know if somehow sideloaded apps don't preserve settings or something? I recompiled, repushed and readded all the settings (inluding a new token) and it is working again.

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

Hi @chengjwk

  1. I will add some notes to the README :).
  2. You should see in the logs the token transfered from app (triggered by loading the settings during start) to companion. If it doesn't match your expected token it means with the app something is not working correctly (loading settings maybe).

from fitbit-homeassistant.

blablazzz avatar blablazzz commented on July 24, 2024

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

@blablazzz
Which version are you running? Release or a dev build? In version 0.6, branch feature/bugfixes, I show error codes in the UI. This helps to figure out what's going wrong. Either you test that or you need to wait till I release 0.6.

from fitbit-homeassistant.

blablazzz avatar blablazzz commented on July 24, 2024

from fitbit-homeassistant.

 avatar commented on July 24, 2024

@blablazzz Which version are you running? Release or a dev build? In version 0.6, branch feature/bugfixes, I show error codes in the UI. This helps to figure out what's going wrong. Either you test that or you need to wait till I release 0.6.

same issue here. how do i install dev build for logging feedback?

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

@lucifudge
Either you build it with Fitbit Studio which can connect to your devices or you wait (maybe till next week) till I release version 0.6.

from fitbit-homeassistant.

Saviq avatar Saviq commented on July 24, 2024

I reported my findings in the other bug: #14 (comment)

from fitbit-homeassistant.

smirko-dev avatar smirko-dev commented on July 24, 2024

Close this issue and track this topic with #14.

from fitbit-homeassistant.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.