homebridge-webos-tv: Can't get config to work
I’m trying to get the config setup to connect to my TV and I’m clearly missing something. I used this guide to setup homebridge, so my config.json is located in /var/homebridge/
directory instead of /home/pi/.homebridge
.
Here’s my accessory config:
"accessories": [
{
"accessory": "webostv",
"name": "My webOS TV",
"ip": "192.168.1.27",
"mac": "XXXXXXXXXXX",
"keyFile": "",
"volumeControl": "slider",
"channelControl": false,
"mediaControl": false,
"pollingEnabled": true,
"appSwitch":[
"com.webos.app.hdmi2",
"com.webos.app.externalinput.component"
]
}
],
Here is the log file for the error:
Dec 09 20:21:16 raspberrypi systemd[1]: Started Node.js HomeKit Server.
Dec 09 20:21:18 raspberrypi homebridge[4544]: [2018-12-9 20:21:18] Loaded config.json with 1 accessories and 1 platforms.
Dec 09 20:21:18 raspberrypi homebridge[4544]: [2018-12-9 20:21:18] ---
Dec 09 20:21:18 raspberrypi homebridge[4544]: [2018-12-9 20:21:18] Loaded plugin: homebridge-neato
Dec 09 20:21:18 raspberrypi homebridge[4544]: [2018-12-9 20:21:18] Registering platform 'homebridge-neato.NeatoVacuumRobot'
Dec 09 20:21:18 raspberrypi homebridge[4544]: [2018-12-9 20:21:18] ---
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] Loaded plugin: homebridge-webos-tv
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] Registering accessory 'homebridge-webos-tv.webostv'
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] ---
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] Loading 1 platforms...
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] [NeatoVacuumRobot] Initializing NeatoVacuumRobot platform...
Dec 09 20:21:19 raspberrypi homebridge[4544]: Sun, 09 Dec 2018 20:21:19 GMT homebridge-neato Extra Care Navigation: 1
Dec 09 20:21:19 raspberrypi homebridge[4544]: Sun, 09 Dec 2018 20:21:19 GMT homebridge-neato Get all robots
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] Loading 1 accessories...
Dec 09 20:21:19 raspberrypi homebridge[4544]: [2018-12-9 20:21:19] [My webOS TV] Initializing webostv accessory...
Dec 09 20:21:19 raspberrypi homebridge[4544]: path.js:28
Dec 09 20:21:19 raspberrypi homebridge[4544]: throw new TypeError('Path must be a string. Received ' + inspect(path));
Dec 09 20:21:19 raspberrypi homebridge[4544]: ^
Dec 09 20:21:19 raspberrypi homebridge[4544]: TypeError: Path must be a string. Received undefined
Dec 09 20:21:19 raspberrypi homebridge[4544]: at assertPath (path.js:28:11)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at join (path.js:1236:7)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at module.exports (/usr/lib/node_modules/homebridge-webos-tv/node_modules/persist-path/index.js:19:22)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at new LGTV (/usr/lib/node_modules/homebridge-webos-tv/node_modules/lgtv2/index.js:47:16)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at new webosTvAccessory (/usr/lib/node_modules/homebridge-webos-tv/index.js:55:17)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at Server._loadAccessories (/usr/lib/node_modules/homebridge/lib/server.js:297:29)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:87:38)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:45:10)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
Dec 09 20:21:19 raspberrypi homebridge[4544]: at Module._compile (module.js:653:30)
Dec 09 20:21:19 raspberrypi systemd[1]: homebridge.service: Main process exited, code=exited, status=1/FAILURE
Dec 09 20:21:19 raspberrypi systemd[1]: homebridge.service: Unit entered failed state.
Dec 09 20:21:19 raspberrypi systemd[1]: homebridge.service: Failed with result 'exit-code'.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (5 by maintainers)
Had the same error with a Raspberry Pi 2 (Raspbian), using systemd and the following config,:
TL;DR… The problem’s not in this library. It’s not even in lgtv2. It’s in a library called persist-path.
Basically, persist-path can’t find a good place to store temporary data because it can’t find my home directory. To fix this problem, I had to go into my systemd service
And make sure a
User
was defined, like so:How did I get there?
Here's the unnecessary, long story
Stuck in some
console.log
in and here’s what I found…The error’s being thrown when the Lgtv2 instance is being created.
The
this.keyFile
being passed into the instance, at least in my case, is definitely a string. So, diving deeper…lgtv2/index.js:47:16
It looks like the fun happens around here:
So
config.clientKey
is undefined (expected behavior), so we proceed tomkdirp(ppath('lgtv2'));
, where we crash. Not too surprising, considering that the stack trace came frompersist-path/index.js:19:22
. So what’s going on in there?Here’s the entirety of persist-path.
The error is occurring in the
return
statement. Why? because pathArr is defined as[ undefined, '.lgtv2' ]
. There’s ourundefined
! How did we get here? Well, we’re actually going to theelse
block at the end of the config because we’re not on adarwin
mac. And I’m not sure what thatprocess.env.APPDATA
is about. Windows, probably. And of course, because I’m running from systemctl,process.env.HOME
isundefined
. Bam. Error.What do we do now to fix it? Well, the problem’s not in this project. It’s not even in lgtv2, though it looks like they’re aware. If I had found that thread earlier, I could’ve skipped this whole effort… It’s lower, in persist-path.
And really, all that can be done is run on a mac or in an environment where process.env.APPDATA or process.env.HOME is defined. So how do we define HOME for a systemd service?
We make sure a user is defined. Which I didn’t define in my
/etc/systemd/system/homebridge.service
.Fixing that fixed the problem.
Ok I just installed homebridge on a spare Pi I had left. Now it works, I wonder where is the plugin trying to put the file if you leave the path option blank. I guess I need to set specific rights for the homebridge user to that directory.