Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting entities showing up. #6

Closed
chengjwk opened this issue Dec 1, 2021 · 23 comments
Closed

Not getting entities showing up. #6

chengjwk opened this issue Dec 1, 2021 · 23 comments
Labels
enhancement New feature or request

Comments

@chengjwk
Copy link

chengjwk commented Dec 1, 2021

New to fitbit, and no idea how the fitbit environment/API(s) work, but was excited to see your app pop up.

I think I've configured everything correctly:
My settings are:
URL: https://something.duckdns.org
PORT: 443
Token: myrandomlonglivetokenhere
Not sure how to debug, but there's no error just:
Home Assistant N/A

I also don't see any errors in my HA logs. I've tried with an internal IP, with/without the port, and with/without the protocol. I've also set up the prequisites in your readme. Honestly haven't looked to deep, so very possible I am missing how it's all wired together, but in companion/index.js won't that Token always be pulling the hard coded global at the top?
else if (evt.key === "entities") { sendData({key: "clear"}); JSON.parse(evt.newValue).forEach(element => { fetchEntity(address(), Token, element["name"]); }) }

@smirko-dev smirko-dev added the bug Something isn't working label Dec 2, 2021
@smirko-dev
Copy link
Owner

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/?

@chengjwk
Copy link
Author

chengjwk commented Dec 2, 2021

{
"message": "API running."
}

@smirko-dev
Copy link
Owner

smirko-dev commented Dec 2, 2021

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?

@chengjwk
Copy link
Author

chengjwk commented Dec 2, 2021

How can I pull the log off?

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

@chengjwk
Copy link
Author

chengjwk commented Dec 3, 2021

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.

@smirko-dev
Copy link
Owner

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

@smirko-dev smirko-dev added enhancement New feature or request and removed bug Something isn't working labels Dec 3, 2021
@chengjwk
Copy link
Author

chengjwk commented Dec 3, 2021

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?

@smirko-dev
Copy link
Owner

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.

@chengjwk
Copy link
Author

chengjwk commented Dec 3, 2021

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

@blablazzz
Copy link

I have same issue with duckdns and port 443.

@smirko-dev
Copy link
Owner

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.

@blablazzz
Copy link

blablazzz commented Dec 13, 2021 via email

@smirko-dev
Copy link
Owner

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/?

@chengjwk
Copy link
Author

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.

@chengjwk
Copy link
Author

chengjwk commented Dec 13, 2021

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.

@smirko-dev
Copy link
Owner

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).

@blablazzz
Copy link

blablazzz commented Dec 13, 2021 via email

@smirko-dev
Copy link
Owner

@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.

@blablazzz
Copy link

blablazzz commented Dec 14, 2021 via email

@ghost
Copy link

ghost commented Jan 30, 2022

@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?

@smirko-dev
Copy link
Owner

@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.

@Saviq
Copy link

Saviq commented Apr 2, 2022

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

@smirko-dev
Copy link
Owner

Close this issue and track this topic with #14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants