estruyf / homebridge-presence-switch-msgraph

Homebridge Presence Switch for Microsoft Graph
MIT License
46 stars 12 forks source link

No sign in prompt shown in the logs #6

Closed ydogandjiev closed 3 years ago

ydogandjiev commented 3 years ago

After installing the plugin, configuring it as instructed, and restarting my Homebridge server all I see in the logs is:

[12/5/2020, 6:57:58 PM] Loaded plugin: homebridge-presence-switch-msgraph@1.3.0 The homebridge-presence-switch-msgraph plugin version is: 1.3.0. Installed on Homebridge version: 2.6. [12/5/2020, 6:57:58 PM] Registering accessory 'homebridge-presence-switch-msgraph.presence-switch' [12/5/2020, 6:58:01 PM] [Presence Indicator] Initializing presence-switch accessory...

I don't get any sign in prompts as expected. Restarting the server several times yielded the same results.

Here is the full config:

{
  "name": "Presence Indicator",
  "appId": "66204339-daf1-40fa-aa31-57342272edce",
  "interval": 1,
  "setColorApi": "http://192.168.7.199:5000/api/switch",
  "offApi": "http://192.168.7.199:5000/api/off",
  "onApi": "http://192.168.7.199:5000/api/on",
  "startTime": "8:00",
  "endTime": "20:00",
  "weekend": true,
  "statusColors": {
      "available": {
          "red": 0,
          "green": 144,
          "blue": 0
      },
      "away": {
          "red": 255,
          "green": 191,
          "blue": 0
      },
      "busy": {
          "red": 179,
          "green": 0,
          "blue": 0
      },
      "donotdisturb": {
          "red": 149,
          "green": 0,
          "blue": 0
      }
  },
  "lightType": "switch",
  "debug": false,
  "accessory": "presence-switch"
}

Any idea what I might be missing? How do I go about debugging this issue?

estruyf commented 3 years ago

That looks good, but it seems you haven't turned on the presence switch, by default this will be off. Clicking on it, should change its state and you'll get the device auth request in the console.

ps: you'll notice 5 other switched, they are there for homekit if you want to configure automation that way. You can ignore these. You need to use the Presence Indicator one.

Screenshot 2020-12-07 at 10 17 08

ydogandjiev commented 3 years ago

Thanks @estruyf! That did the trick. Now if I can only convince the Microsoft tenant admins to allow your app (or the one I registered myself in the tenant) then I can finally get this baby working!

estruyf commented 3 years ago

@ydogandjiev be aware that it requires admin consent hopefully that changes in the future.

Spanishu commented 3 years ago

Hi I have just installed the Plugin. I am not getting the prompt either with the indications you are making. { "name": "Presence Indicator", "appId": "14d99f8a-70da-4d2b-ae0c-b021e91bfd21", "interval": 1, "startTime": "9:00", "endTime": "20:00", "weekend": true, "statusColors": { "available": { "red": 0, "green": 144, "blue": 0 }, "away": { "red": 255, "green": 191, "blue": 0 }, "busy": { "red": 179, "green": 0, "blue": 0 }, "donotdisturb": { "red": 149, "green": 0, "blue": 0 } }, "lightType": "switch", "debug": false, "accessory": "presence-switch" } I clicked on the switch, which then pulls all the FHEM status but I only get

[Presence Indicator] Failed to retrieve an accessToken: undefined

estruyf commented 3 years ago

@Spanishu the input looks fine. Please open another issue if the issue persists.

Things to test:

Spanishu commented 3 years ago

@estruyf figured it ;) Now I need admin access (work at MSFT) and I am not sure where to get it.

estruyf commented 3 years ago

Great to hear! What was the problem?

For the consent, this is something to check with someone that can manage your Azure AD. Might be that MS disabled to approve your own MS Graph consents.

Spanishu commented 3 years ago

@estruyf I will check. There is an app https://github.com/isaacrlevin/PresenceLight Which does something similar however does not integrate with Homebridge. This app does work for me (technically) however does not allow me to do the simple think I look for. Turn on a light when I am "red".

estruyf commented 3 years ago

@Spanishu thank you for sharing.

  1. I see you used a different APP ID. Did you create your own app registration?
  2. Checked the app you mentioned, and that uses the same permission set.
  3. Just released a new version that uses the v1.0 API endpoint and not the beta one anymore. Shouldn't make a difference.
Spanishu commented 3 years ago

@estruyf AppID: I did use a different one but changed it back to the one you have provided. That is when I got at least the option to enter the code. The App that I mention requires me to login in if I am not mistaken (need to install it again). I think from then it pulls the permissions and keeps them ( I had it running and I logged in only once!)

  1. Just installed the update from you and the problem persists. I will see if I have the time to install the Presencelight app and if I get it to work. Will post tomorrow.
Spanishu commented 3 years ago

Just checked and I have the following parameter ClientID ClientSecret Instance RedirectUri CallbackPath ApiScopes

Starting the app it took me to the login screen on the browser. Not sure it helps to further investigate. If