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

Doesn't seem to work anymore with HA 2022.3.1 #14

Closed
si458 opened this issue Mar 5, 2022 · 22 comments
Closed

Doesn't seem to work anymore with HA 2022.3.1 #14

si458 opened this issue Mar 5, 2022 · 22 comments
Labels
help wanted Extra attention is needed

Comments

@si458
Copy link

si458 commented Mar 5, 2022

I've created a long access token, set my url, port and new token,
then added a single switch entity
BUT the app says connection error
BUT HA also keeps saying access is denied then after 3 tries opening the app on my watch
HA bans me from logging in for 5mins?

@smirko-dev
Copy link
Owner

@si458
I just read the latest release notes of home assistant. I can't find any changes regarding the RestfulAPI.
Since I can't test it (my HA is currently not working) please wait till I release version 0.6 (still in review by Fitbit). I reworked the error information.
Was the app working before you updated HA?

@maxcanna
Copy link
Contributor

maxcanna commented Mar 5, 2022

@si458 This is not caused by HA itself and nothing changed with the latest release. What happens is that each time you enter the connection details the app tries to connect to HA. This causes a failed connection until you put the access token too. To avoid this behavior start from the token so when you put the address, as last thing, the token will already be in the app settings and everything works smoothly

@si458
Copy link
Author

si458 commented Mar 5, 2022

sorry for delay, i understand the logic behind put the key in first, however the app still isnt working, it just keeps saying 'connect error' and my HA displays a message saying 'unauthorised access' every time i open up the app on my versa 2 even through the token is correct, same with the server url and port?

@smirko-dev
Copy link
Owner

smirko-dev commented Mar 5, 2022

@si458 Did you copy&paste the key correctly (sorry for that stupid question)? Other people old me about issues doing that. In such cases not the whole key was copied which would leads to error. Also check for trailing whitespaces. Did you enable the Rest Api in your HA?

@smirko-dev smirko-dev added the help wanted Extra attention is needed label Mar 5, 2022
@si458
Copy link
Author

si458 commented Mar 5, 2022

@smirko-dev i have deleted my old key, then created a new key, copied it into my Paw app on my laptop, queried the API, and got results from https://myhomeassistantwebsite.duckdns.org:8123/api/states no problems!
so i know the key works,

but if i set it in the fitbit app, the app says 'connect error' and HA then shows a notification saying 'Login attempt or request with invalid authentication from 148.xxx.xxx.xxx (148.xxx.xxx.xxx). See the log for details.'

and ive checked my homeassistant.log file and its the same there '2022-03-05 16:56:51 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 148.xxx.xxx.xxx (148.xxx.xxx.xxx). (Fitbit/3.55 Android/31' so the must be something thats different?

@si458
Copy link
Author

si458 commented Mar 5, 2022

@smirko-dev i have just remembered i have my own developer account 😆,
so ill try copying your repo and building it on my watch and see what happens from the console.log

@smirko-dev
Copy link
Owner

Let me know about your investigation. Since I don't know how to help, I'm curious about the problem/solution :)

@si458
Copy link
Author

si458 commented Mar 5, 2022

@smirko-dev very weird? it works? but ive found a BIG bug 😞

for some reason when changing the settings in the app, it doesnt send the new data to the app on the watch,
YOU MUST HAVE THE APP OPEN ON THE WATCH WHEN CHANGING THE SETTINGS FOR THEM TO APPLY!

e.g: i set it all up with the app closed on my watch, but the watch just receieved 'localhost' as the server url?
so i went into the settings and then re-saved the URL and then the watch recieved that url, and when i open the app back up again after 1min of it being closed, it received the correct URL ?

its also annoying because if you enter the entities, one by one by one, the watch app must be open, as i added 3 switched in, but they where not being sent to the watch, so i had to delete them one by one and then re-add them by trying them in again one by one

im still looking into why it isnt sending the correct url on first start up even if you have setting set?

@si458
Copy link
Author

si458 commented Mar 5, 2022

little debug log for you,

  1. installed app
  2. it autolaunched app, which i then closed straight away
  3. i launched settings app, set my details, and open/closed a few times
  4. launched app on watch,
  5. it then sends localhost back and forth for some reason?
  6. closed/opened app a few times
  7. launched app, then launched settings and modified url
  8. it then sent the correct url
  9. again closed/opened app a few times and it was sending backand forth the correct url
Launching app
[17:34:53]       App: App Closed
[17:34:54] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                                                              (js-engine-bootstrap.html:9,1)
[17:34:54] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/17a0bd62-418a-4f3f-98ad-b0d38a548286/0x02c5c2a408d6bdb2/companion.js                 (js-engine-bootstrap.html:9,1)
[17:34:54] Companion: Companion launched by [launchedOnTracker]
[17:34:54]       App: App Started
[17:34:54]       App: Error loading settings                                                                                                                                                          (app/index.js:126,9)
[17:34:54] Companion: Socket open                                                                                                                                                               (companion/index.js:125,9)
[17:34:55]       App: Socket open                                                                                                                                                                     (app/index.js:107,5)
[17:34:55]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:34:55]       App: {"key":"url","value":"localhost"}                                                                                                                                              (common/utils.js:7,9)
[17:34:55]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:34:55]       App: {"key":"port","value":"8123"}                                                                                                                                                  (common/utils.js:7,9)
[17:34:55]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:34:55]       App: {"key":"token","value":""}                                                                                                                                                     (common/utils.js:7,9)
[17:34:55]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:34:55]       App: {"key":"entities"}                                                                                                                                                             (common/utils.js:7,9)
[17:34:55]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:34:55]       App: {"key":"force","value":false}                                                                                                                                                  (common/utils.js:7,9)
[17:34:55] Companion: Received {"key":"url","value":"localhost"}                                                                                                                                (companion/index.js:194,1)
[17:34:55] Companion: Received {"key":"port","value":"8123"}                                                                                                                                    (companion/index.js:194,1)
[17:34:55] Companion: Received {"key":"token","value":""}                                                                                                                                       (companion/index.js:194,1)
[17:34:55] Companion: Received {"key":"entities"}                                                                                                                                               (companion/index.js:194,1)
[17:34:55] Companion: Received {"key":"force","value":false}                                                                                                                                    (companion/index.js:194,1)
[17:35:03]       App: App Closed
[17:35:03] Companion: Socket closed                                                                                                                                                             (companion/index.js:189,1)
[17:35:03]       App: App Started
[17:35:03] Companion: App closed on device, unloading companion in 3 seconds…
[17:35:04]       App: Launch complete - durations: foregrounding(1096ms), first paint(185ms), total(1284ms).
[17:35:06] Companion: Unloading companion…
[17:35:08] Companion: Companion unloaded
[17:35:09]  Settings: Settings Started
[17:35:22] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                                                              (js-engine-bootstrap.html:9,1)
[17:35:23] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/17a0bd62-418a-4f3f-98ad-b0d38a548286/0x02c5c2a408d6bdb2/companion.js                 (js-engine-bootstrap.html:9,1)
[17:35:23] Companion: Companion launched by [settingsChanged], unloading companion in 15 seconds…
[17:35:38] Companion: Unloading companion…
[17:35:40] Companion: Companion unloaded
[17:36:04] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                                                              (js-engine-bootstrap.html:9,1)
[17:36:04] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/17a0bd62-418a-4f3f-98ad-b0d38a548286/0x02c5c2a408d6bdb2/companion.js                 (js-engine-bootstrap.html:9,1)
[17:36:04] Companion: Companion launched by [settingsChanged], unloading companion in 15 seconds…
[17:36:16] Companion: [fetchEntity]: TypeError: Failed to fetch - Please use https:// when communicating with internet endpoints. https://dev.fitbit.com/reference/companion-api/fetch/         (companion/index.js:92,13)
[17:36:19] Companion: Unloading companion…
[17:36:21] Companion: Companion unloaded
[17:36:35]  Settings: Settings Closed
[17:36:38]  Settings: Settings Started
[17:36:40]  Settings: Settings Closed
[17:36:46]       App: App Closed
[17:36:47]       App: App Started
[17:36:47]       App: Launch complete - durations: foregrounding(784ms), first paint(45ms), total(846ms).
[17:36:47] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                                                              (js-engine-bootstrap.html:9,1)
[17:36:47]       App: Socket open                                                                                                                                                                     (app/index.js:107,5)
[17:36:47]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:36:47]       App: {"key":"url","value":"localhost"}                                                                                                                                              (common/utils.js:7,9)
[17:36:47]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:36:47]       App: {"key":"port","value":"8123"}                                                                                                                                                  (common/utils.js:7,9)
[17:36:47]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:36:47]       App: {"key":"token","value":""}                                                                                                                                                     (common/utils.js:7,9)
[17:36:47]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:36:47]       App: {"key":"entities"}                                                                                                                                                             (common/utils.js:7,9)
[17:36:47]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:36:47]       App: {"key":"force","value":false}                                                                                                                                                  (common/utils.js:7,9)
[17:36:47] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/17a0bd62-418a-4f3f-98ad-b0d38a548286/0x02c5c2a408d6bdb2/companion.js                 (js-engine-bootstrap.html:9,1)
[17:36:47] Companion: Companion launched by [launchedOnTracker]
[17:36:47] Companion: Socket open                                                                                                                                                               (companion/index.js:125,9)
[17:36:47] Companion: Received {"key":"url","value":"localhost"}                                                                                                                                (companion/index.js:194,1)
[17:36:47] Companion: Received {"key":"port","value":"8123"}                                                                                                                                    (companion/index.js:194,1)
[17:36:47] Companion: Received {"key":"token","value":""}                                                                                                                                       (companion/index.js:194,1)
[17:36:47] Companion: Received {"key":"entities"}                                                                                                                                               (companion/index.js:194,1)
[17:36:47] Companion: Received {"key":"force","value":false}                                                                                                                                    (companion/index.js:194,1)
[17:36:55]       App: App Closed
[17:36:55] Companion: Socket closed                                                                                                                                                             (companion/index.js:189,1)
[17:36:55] Companion: App closed on device, unloading companion in 3 seconds…
[17:36:55]       App: App Started
[17:36:58] Companion: Unloading companion…
[17:36:58]       App: App Closed
[17:36:58]       App: App Closed
[17:36:58]       App: App Started
[17:36:58]       App: Launch complete - durations: foregrounding(772ms), first paint(46ms), total(835ms).
[17:37:00] Companion: Companion unloaded
[17:37:00] Companion: Loaded and evaluated: file:///android_asset/bootstrap.js                                                                                                              (js-engine-bootstrap.html:9,1)
[17:37:00] Companion: Loaded and evaluated: file:///data/user/0/com.fitbit.FitbitMobile/app_companions/17a0bd62-418a-4f3f-98ad-b0d38a548286/0x02c5c2a408d6bdb2/companion.js                 (js-engine-bootstrap.html:9,1)
[17:37:00] Companion: Companion launched by [launchedOnTracker]
[17:37:00] Companion: Socket open                                                                                                                                                               (companion/index.js:125,9)
[17:37:00] Companion: Received {"key":"url","value":"localhost"}                                                                                                                                (companion/index.js:194,1)
[17:37:00] Companion: Received {"key":"port","value":"8123"}                                                                                                                                    (companion/index.js:194,1)
[17:37:00] Companion: Received {"key":"token","value":""}                                                                                                                                       (companion/index.js:194,1)
[17:37:00]       App: Socket open                                                                                                                                                                     (app/index.js:107,5)
[17:37:00]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:00]       App: {"key":"url","value":"localhost"}                                                                                                                                              (common/utils.js:7,9)
[17:37:00]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:00]       App: {"key":"port","value":"8123"}                                                                                                                                                  (common/utils.js:7,9)
[17:37:00]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:00]       App: {"key":"token","value":""}                                                                                                                                                     (common/utils.js:7,9)
[17:37:00]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:00]       App: {"key":"entities"}                                                                                                                                                             (common/utils.js:7,9)
[17:37:00]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:00]       App: {"key":"force","value":false}                                                                                                                                                  (common/utils.js:7,9)
[17:37:00] Companion: Received {"key":"entities"}                                                                                                                                               (companion/index.js:194,1)
[17:37:00] Companion: Received {"key":"force","value":false}                                                                                                                                    (companion/index.js:194,1)
[17:37:12]  Settings: Settings Started
[17:37:16]  Settings: Settings Closed
[17:37:18]  Settings: Settings Started
[17:37:21] Companion: Sent {"key":"url","value":"https://myhomeassistant.duckdns.org"}                                                                                                                         (common/utils.js:5,1)
[17:37:22]       App: Received: {"data":{"key":"url","value":"https://myhomeassistant.duckdns.org"}}                                                                                                             (app/index.js:59,5)
[17:37:22]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:22]       App: {"key":"url","value":"https://myhomeassistant.duckdns.org"}                                                                                                                              (common/utils.js:7,9)
[17:37:26] Companion: Received {"key":"url","value":"https://myhomeassistant.duckdns.org"}                                                                                                                (companion/index.js:194,1)
[17:37:28] Companion: Sent {"key":"port","value":"8123"}                                                                                                                                             (common/utils.js:5,1)
[17:37:29] Companion: Received {"key":"port","value":"8123"}                                                                                                                                    (companion/index.js:194,1)
[17:37:29]       App: Received: {"data":{"key":"port","value":"8123"}}                                                                                                                                 (app/index.js:59,5)
[17:37:29]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:29]       App: {"key":"port","value":"8123"}                                                                                                                                                  (common/utils.js:7,9)
[17:37:31] Companion: Sent {"key":"token","value":"LONGASSKEYHERE"}                                                                                                                                                                                   (common/utils.js:5,1)
[17:37:31]       App: Received: {"data":{"key":"token","value":"LONGASSKEYHERE"}}                                                                                                                                                                       (app/index.js:59,5)
[17:37:31]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:31]       App: {"key":"token","value":"LONGASSKEYHERE"}                                                                                                                                                                                        (common/utils.js:7,9)
[17:37:32] Companion: Received {"key":"token","value":"LONGASSKEYHERE"}                                                                                                                                                                          (companion/index.js:194,1)
[17:37:32] Companion: Sent {"key":"api","value":"ok","name":"Home"}                                                                                                                                  (common/utils.js:5,1)
[17:37:32]       App: Received: {"data":{"key":"api","value":"ok","name":"Home"}}                                                                                                                      (app/index.js:59,5)
[17:37:37]  Settings: Settings Closed
[17:37:40]       App: App Closed
[17:37:41] Companion: Socket closed                                                                                                                                                             (companion/index.js:189,1)
[17:37:41]       App: App Started
[17:37:41] Companion: App closed on device, unloading companion in 3 seconds…
[17:37:42]       App: App Closed
[17:37:43]       App: App Started
[17:37:43]       App: Launch complete - durations: foregrounding(744ms), first paint(49ms), total(817ms).
[17:37:43] Companion: App was opened on device; companion will no longer be unloaded
[17:37:43] Companion: Socket open                                                                                                                                                               (companion/index.js:125,9)
[17:37:43]       App: Socket open                                                                                                                                                                     (app/index.js:107,5)
[17:37:43]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:43]       App: {"key":"url","value":"https://myhomeassistant.duckdns.org"}                                                                                                                              (common/utils.js:7,9)
[17:37:43]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:43]       App: {"key":"port","value":"8123"}                                                                                                                                                  (common/utils.js:7,9)
[17:37:43]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:43]       App: {"key":"token","value":"LONGASSKEYHERE"}                                                                                                                                                                                        (common/utils.js:7,9)
[17:37:43]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:43]       App: {"key":"entities"}                                                                                                                                                             (common/utils.js:7,9)
[17:37:43]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[17:37:43]       App: {"key":"force","value":false}                                                                                                                                                  (common/utils.js:7,9)
[17:37:43] Companion: Received {"key":"url","value":"https://myhomeassistant.duckdns.org"}                                                                                                                (companion/index.js:194,1)
[17:37:43] Companion: Received {"key":"port","value":"8123"}                                                                                                                                    (companion/index.js:194,1)
[17:37:43] Companion: Received {"key":"token","value":"LONGASSKEYHERE"}                                                                                                                                                                          (companion/index.js:194,1)
[17:37:43] Companion: Received {"key":"entities"}                                                                                                                                               (companion/index.js:194,1)
[17:37:43] Companion: Received {"key":"force","value":false}                                                                                                                                    (companion/index.js:194,1)
[17:37:43] Companion: Sent {"key":"api","value":"ok","name":"Home"}                                                                                                                                  (common/utils.js:5,1)
[17:37:43] Companion: Sent {"key":"api","value":"ok","name":"Home"}                                                                                                                                  (common/utils.js:5,1)
[17:37:43] Companion: Sent {"key":"api","value":"ok","name":"Home"}                                                                                                                                  (common/utils.js:5,1)
[17:37:43]       App: Received: {"data":{"key":"api","value":"ok","name":"Home"}}                                                                                                                      (app/index.js:59,5)
[17:37:44]       App: Received: {"data":{"key":"api","value":"ok","name":"Home"}}                                                                                                                      (app/index.js:59,5)
[17:37:44]       App: Received: {"data":{"key":"api","value":"ok","name":"Home"}}                                                                                                                      (app/index.js:59,5)

@smirko-dev
Copy link
Owner

@si458
Thanks for that feedback and trying out so fast.
As I wrote in the docs, I just tested it by simulation. That means your use case is so far unknown to me. I will check the Fitbit SDK docs for that even though most of the functions are based on Fitbit example code.

@si458
Copy link
Author

si458 commented Mar 5, 2022

@smirko-dev its perfectly fine, i love the little app!
but it might also explain why i keep getting the 'connect error' because its not sending the token correctly to my watch unless i have both settings and the app open at the same time!

@si458
Copy link
Author

si458 commented Mar 5, 2022

@smirko-dev also another weird bug, the state doesnt get updated?
e.g. i added a switch which says OFF, so i click it and i see in the logs it sending the turn_on state and it turns on,
but the watch doesnt update its state or even check its new state?

[18:01:49]       App: Received: {"data":{"key":"api","value":"ok","name":"Home"}}                                                                                                                      (app/index.js:59,5)
[18:01:50]       App: Received: {"data":{"key":"add","id":"switch.woox_r4785_socket","name":"Bedside Lamp Socket","state":"on"}}                                                                       (app/index.js:59,5)
[18:01:51]       App: Sent                                                                                                                                                                           (common/utils.js:7,9)
[18:01:51]       App: {"key":"change","entity":"switch.woox_r4785_socket","state":"turn_off"}                                                                                                        (common/utils.js:7,9)
[18:01:51] Companion: Received {"key":"change","entity":"switch.woox_r4785_socket","state":"turn_off"}                                                                                          (companion/index.js:194,1)

EDIT: if i enable force status this works as expected (der... 🤦 )

@smirko-dev
Copy link
Owner

@si458
I tried to fix the bug. Can you check
#16?

@Saviq
Copy link

Saviq commented Apr 2, 2022

I had a similar problem and having used the debugger realized that settings retrieval is what's breaking. Even though in the Fitbit App I had the correct settings, HA Remote was reporting default values.

When I went through the settings top to bottom again, opening and saving them, HA Remote finally connected OK.

I then reproduced it with v0.6, so can confirm the released version is working.

@davomyster
Copy link

davomyster commented Aug 9, 2022

I’m still having this issue. HA Remote says “connection error” and I’m seeing “Login attempt or request with invalid authentication” in the logs.

I know my long lived tokens are working because I’ve sent authenticated requests with another device. I’m assuming the URL and port are correct because I’m seeing the failed login attempt in the logs.

I’ve tried opening the app on my watch while updating the settings but that didn’t work. Any ideas?

*edit: I kept trying to change values and it somehow eventually started working. It has something to do with making sure the app is open on the watch while configuring the settings. I was doing that and it didn’t work for a while, then eventually it suddenly connected. Bizarre

@smirko-dev
Copy link
Owner

@davomyster

  1. With the current Fitbit app unsecured traffic is blocked (https://community.fitbit.com/t5/SDK-Development/Fetch-API-doesn-t-work/m-p/5204923#M17769).
  2. The current version doesn't catch empty strings in the settings. This causes the invalid authentification. I fixed that with New entities #19.

Besides that I have no idea since I tested it with 2 different watches and my HA.
Changing entities worked for me without having the app open.

As long as the Fitbit app is not fixed I can't test since my HA runs without SSL :(

@dustrat
Copy link

dustrat commented Aug 15, 2022

What is the status making it work using nabu casa? That's the only way I can get a secure connection to my HA installation. I don't see why it shouldn't work though since a normal curl request to the api via nabu casa works exactly like a local request.

@smirko-dev
Copy link
Owner

smirko-dev commented Aug 16, 2022

@dustrat When you access you HA instance via NabuCasa do you need to use the port in your url or it works without like in this post? https://community.home-assistant.io/t/use-nabu-casa-url-to-use-ha-api/382563/2

@dustrat
Copy link

dustrat commented Aug 16, 2022

@dustrat When you access you HA instance via NabuCasa do you need to use the port in your url or it works without like in this post? https://community.home-assistant.io/t/use-nabu-casa-url-to-use-ha-api/382563/2

I use the nabu casa url and specifies port 443 explicitly. It seems to connect now, but I get "connection failure" and a "login failed" notification in HA, so at least that part works. Tried to create a new token, doesn't work anyway, so seems to be the same issue @davomyster has.

@dustrat
Copy link

dustrat commented Aug 16, 2022 via email

@ecto1a2003
Copy link

It's working for me as well but I still get authentication errors on app starting, it eventually connects after a moment.

@smirko-dev
Copy link
Owner

@ecto1a2003 Thats because of an incomplete setup. I tried to fix that with #21. As soon as I have a working setup again and Fitbit supports again http access via IP I will test that.

@si458 si458 closed this as completed Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants