kopiro / homebridge-playstation

Playstation integration for Homebridge / HOOBS.
ISC License
101 stars 8 forks source link

Can't switch to homebridge user from Homebridge terminal. #108

Open reboot81 opened 4 months ago

reboot81 commented 4 months ago

Describe Your Problem: Can't switch to homebridge user from Homebridge terminal.

Note: This is a restricted shell, sudo cannot be used here.

Homebridge Terminal

Node.js Version: v20.15.0
Node.js Path: /opt/homebridge/bin/node
Plugin Path: /var/lib/homebridge/node_modules

Update Node.js: hb-service update-node

Install Plugin: hb-service add homebridge-plugin-name
Remove Plugin: hb-service remove homebridge-plugin-name

root@c14:/var/lib/homebridge $ su homebridge
This account is currently not available.
root@c14:/var/lib/homebridge $ 

Logs:

[7/14/2024, 2:32:20 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules -D --strict-plugin-resolution
[7/14/2024, 2:32:20 PM] [HB Supervisor] Started Homebridge v1.8.2 with PID: 2961
[7/14/2024, 2:32:22 PM] Loaded config.json with 4 accessories and 4 platforms.
[7/14/2024, 2:32:22 PM] Loaded 0 cached accessories from cachedAccessories.
[7/14/2024, 2:32:22 PM] ---
[7/14/2024, 2:32:22 PM] Disabled plugin: homebridge-glue@3.0.6
[7/14/2024, 2:32:22 PM] ---
[7/14/2024, 2:32:23 PM] Loaded plugin: homebridge-messenger@0.0.8
[7/14/2024, 2:32:23 PM] Registering accessory 'homebridge-messenger.HomebridgeMessenger'
[7/14/2024, 2:32:23 PM] ---
[7/14/2024, 2:32:23 PM] Disabled plugin: homebridge-miot@1.7.1
[7/14/2024, 2:32:23 PM] ---
[7/14/2024, 2:32:24 PM] Loaded plugin: homebridge-playstation@1.6.0
[7/14/2024, 2:32:24 PM] Registering platform 'homebridge-playstation.playstation'
[7/14/2024, 2:32:24 PM] ---
[7/14/2024, 2:32:25 PM] Loaded plugin: homebridge-xiaomi-fan@1.5.9
[7/14/2024, 2:32:25 PM] Registering platform 'homebridge-xiaomi-fan.xiaomifan'
[7/14/2024, 2:32:25 PM] ---
[7/14/2024, 2:32:28 PM] Disabled plugin: homebridge-xiaomi-roborock-vacuum@0.31.1
[7/14/2024, 2:32:28 PM] ---
[7/14/2024, 2:32:28 PM] Disabled plugin: @gluehome/homebridge-gluehome@0.2.0
[7/14/2024, 2:32:28 PM] ---
[7/14/2024, 2:32:28 PM] Loading 4 platforms...
[7/14/2024, 2:32:28 PM] Ignoring config for the platform "GlueHomebridge" in your config.json as the plugin "@gluehome/homebridge-gluehome" has been disabled.
[7/14/2024, 2:32:28 PM] [xiaomifan] Initializing xiaomifan platform...
[7/14/2024, 2:32:28 PM] [xiaomifan] Initializing child bridge MAC:ADRESS
[7/14/2024, 2:32:28 PM] Ignoring config for the platform "miot" in your config.json as the plugin "homebridge-miot" has been disabled.
[7/14/2024, 2:32:28 PM] Loading 4 accessories...

Plugin Config:

{
    "bridge": {
        "name": "Homebridge IDID",
        "username": "MAC:ADRESS?",
        "port": 51511,
        "pin": "123-45-678",
        "advertiser": "bonjour-hap"
    }

Screenshots:

Environment:

loginov-rocks commented 4 months ago

Hi @reboot81 , I have the same problem although connecting over SSH, even passing the password check the login operation does not work, reported here https://github.com/kopiro/homebridge-playstation/issues/72#issuecomment-2229505094

DasKraut37 commented 2 months ago

Anyone ever figure out how to get this to work?

EDIT: I’m using the official Homebridge docker image, by the way.

DasKraut37 commented 2 months ago

UPDATE: I figured out how to get the homebridge user active in the Homebridge docker container. SSH into the container and edit the /etc/passwd file in nano. Go to the line that starts with “homebridge” and will end with /usr/sbin/nologin, and change that last part to /bin/bash. Then restart the Homebridge container and you will be able to log in at the Homebridge user.

Now for a NEW problem, when you try to run homebridge-playstation-login it gives you this error: bash: homebridge-playstation-login: command not found

No clue where to go from here. I have the plugin running in a child bridge, I’m going to see if running it on the host bridge is any better. I will report back what I find.

DasKraut37 commented 2 months ago

Running this plugin on the host bridge did not work either. I think this plugin is broken for the Homebridge docker container.

kopiro commented 2 months ago

Can you try instead node ./dist/cli.js?

DasKraut37 commented 2 months ago

Can you try instead node ./dist/cli.js?

Tried to run that as homebridge user and got: bash: node: command not found

Then tried to run it as normal root user and got this:

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module '/homebridge/dist/cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.17.0

I'm running the official Homebridge docker image, and it's running homebridge v1.8.4.

DasKraut37 commented 2 months ago

I found that cli.js script in /homebridge/node_modules/homebridge-playstation/dist/ ...should I run it from there?

DasKraut37 commented 2 months ago

I was able to run that as a root user, but not as a homebridge user. But when I tried to go to the link, I got this error: Screen Shot 2024-09-10 at 10 42 43 PM

loginov-rocks commented 1 month ago

Hey @DasKraut37 I was able to make it work, shared in the comments to the issue I mentioned above https://github.com/kopiro/homebridge-playstation/issues/72#issuecomment-2229619707

DasKraut37 commented 1 month ago

Oh awesome! Thanks! I'm going to try this out right now!

DasKraut37 commented 1 month ago

Quick Update (have not tried your method yet): So it turns out the problem with going to the link was that uBlock Origin was blocking it. I fixed that and was able to get a successful redirect URL. Only problem now is when I try to authenticate I get this error

Registering with device via Remote Play.
Go to Settings > System > Remote Play > Link Device
Enter PIN here> [redacted]
Registration error: 403: Forbidden: Other Error

Discovering next device...

Did not authenticate to any consoles.
DasKraut37 commented 1 month ago

Regarding the 403 Error: I came across this post today and even though I still get the error, for some reason I can control my PS5 in HomeKit now. The trick was adding it to HomeKit first as an accessory. Also...HomeKit makes you define an Input channel for some reason... So I just called mine PS5. No idea what that's about... but I can turn the PS5 on and off now. So... I guess we're good!

Some final wrap-up notes:

  1. Disable uBlock Origin in your webrowser before you start to set this up
  2. Install the plugin as directed but do not try to authenticate yet
  3. Add the homebridge-playstation child bridge to your HomeKit
  4. Then add the PlayStation Accessory to HomeKit (assign any name when it asks you for an Input, or it will fail to add)
  5. Now go into the Homebridge docker container's terminal, and run homebridge-playstation-login
  6. Once you follow the rest of the directions and get the 403 Error, ignore it. You should see the PlayStation in your HomeKit now and be able to power it on/off.

If anyone tries these steps and find that it doesn't work for them, I'd love to know about it since I got there the long way around. I may have left something out, etc.

DasKraut37 commented 1 month ago

Never mind to all of the above. It worked once and then never again. ¯_(ツ)_/¯ I’m calling it a day. Been fighting with this for hours and I have other stuff to do. I’ll try the other method later when I’m less frustrated.