dominick-han / homebridge-tv-cec

Homebridge support for TV power on/off, source selection, using HDMI-CEC
GNU General Public License v3.0
35 stars 9 forks source link

fail to work with systemd #1

Closed Rabelbeat closed 6 years ago

Rabelbeat commented 6 years ago

Hi

I'm running homebridge on Rpi 3 and configure to run it with systemd.

The only way that I success to run this plugin and switch inputs, Only when i run:

~ $ homebridge -U /var/homebridge/

But If homebridge is runing as usual with homebridge service, When I want to switch Input from the app, I get an error and hombridge crush

Log:

Oct 20 15:51:35 Homebridge_RPI systemd[1]: Started Node.js HomeKit Server. Oct 20 15:51:38 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:38] Loaded config.json with 1 accessories and 2 platforms. Oct 20 15:51:38 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:38] --- Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] Loaded plugin: homebridge-config-ui-x Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] Registering platform 'homebridge-config-ui-x.config' Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] --- Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] Loaded plugin: homebridge-hdmi-cec Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] Registering platform 'homebridge-hdmi-cec.CEC' Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] --- Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] Loading 2 platforms... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [Config] Initializing config platform... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [Config] Spawning homebridge-config-ui-x with PID 6966 Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initializing CEC platform... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initializing platform accessory 'TV'... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initialized Power Switch Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initializing platform accessory 'Apple TV'... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initialized Source: Apple TV at 10:00 Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initializing platform accessory 'HDMI Switcher'... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initialized Source: HDMI Switcher at 20:00 Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initializing platform accessory 'Yes'... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initialized Source: Yes at 30:00 Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initializing platform accessory 'HDMI Side'... Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] [CEC] Initialized Source: HDMI Side at 40:00 Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Setup Payload: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: X-HM://0023ISK4UD3O0 Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Scan this code with your HomeKit app on your iOS device to pair with Homebridge: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Or enter this code with your HomeKit app on your iOS device to pair with Homebridge: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: ┌────────────┐ Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: │ 333-22-999 │ Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: └────────────┘ Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: Oct 20 15:51:39 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:39] Homebridge is running on port 51826. Oct 20 15:51:45 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:45] [Config] Using Form Authentication Oct 20 15:51:45 Homebridge_RPI homebridge[6946]: [2018-10-20 15:51:45] [Config] Console v3.8.11 is listening on port 8080.

############## HERE I PRESS THE IPNUT BUTTON FROM THE APP ################

Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: Error: This socket is closed Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at Socket._writeGeneric (net.js:733:18) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at Socket._write (net.js:787:8) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at doWrite (_stream_writable.js:396:12) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at writeOrBuffer (_stream_writable.js:382:5) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at Socket.Writable.write (_stream_writable.js:290:11) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at Socket.write (net.js:711:40) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at Source.setState (/usr/lib/node_modules/homebridge-hdmi-cec/index.js:175:20) Oct 20 15:52:01 Homebridge_RPI homebridge[6946]: at emitMany (events.js:147:13) Oct 20 15:52:01 Homebridge_RPI systemd[1]: homebridge.service: Main process exited, code=exited, status=1/FAILURE Oct 20 15:52:01 Homebridge_RPI systemd[1]: homebridge.service: Unit entered failed state. Oct 20 15:52:01 Homebridge_RPI systemd[1]: homebridge.service: Failed with result 'exit-code'. Oct 20 15:52:11 Homebridge_RPI systemd[1]: homebridge.service: Service hold-off time over, scheduling restart. Oct 20 15:52:11 Homebridge_RPI systemd[1]: Stopped Node.js HomeKit Server. Oct 20 15:52:11 Homebridge_RPI systemd[1]: Started Node.js HomeKit Server.

config.json file:

{

"bridge": { "name": "Homebridge", "username": "CC:2A:3B:E1:CE:3A", "port": 51826, "pin": "333-22-999" }, "description": "My Home", "platforms": [ { "name": "Config", "port": 8080, "auth": "form", "theme": "blue", "restart": "sudo -n systemctl restart homebridge", "tempUnits": "c", "sudo": true, "log": { "method": "systemd", "service": "homebridge" }, "platform": "config" }, { "platform": "CEC", "manufacturer": "Test", "model": "V1.1", "sources": [ { "name": "Apple TV", "manufacturer": "Apple Inc", "model": "4K", "address": "1.0.0.0" }, { "name": "HDMI Switcher", "manufacturer": "Test", "model": "Test", "address": "2.0.0.0" }, { "name": "Yes", "manufacturer": "Yes", "model": "Max", "address": "3.0.0.0" }, { "name": "HDMI Side", "manufacturer": "Panasonic", "model": "ST55", "address": "4.0.0.0" } ] } ], "accessories": [ { } ] }

Hope that anyone can help :)

Rabelbeat commented 6 years ago

Solved! add homebridge to video group

sudo usermod -a -G video homebridge

I also did

sudo chown -R homebridge:homebridge /usr/bin/cec-client

https://github.com/jbree/homebridge-cec-accessory/issues/5#issuecomment-383562965