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

Cannot call write after a stream was destroyed #12

Open gardenalr opened 4 years ago

gardenalr commented 4 years ago

Error happens when i try to turn on/off the TV.

[12/13/2019, 10:32:08 PM] [TV] Checking TV power status [12/13/2019, 10:32:08 PM] Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed at doWrite (_stream_writable.js:411:19) at writeOrBuffer (_stream_writable.js:399:5) at Socket.Writable.write (_stream_writable.js:299:11) at TV.getPowerStatus (/usr/local/lib/node_modules/homebridge-tv-cec/index.js:89:20) at Characteristic.Active.emit (events.js:198:13) at Characteristic.Active.Characteristic.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:164:10) at Bridge. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:771:20) at Array.forEach () at Bridge.Accessory._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:735:8) at HAPServer.emit (events.js:198:13) [12/13/2019, 10:32:08 PM] Got SIGTERM, shutting down Homebridge...

Below my CEC log:

hoobs@hoobs:~ $ cec-client -d 8 log level set to 8 No device type given. Using 'recording device' CEC Parser created - libCEC version 4.0.4 no serial port given. trying autodetect: path: Raspberry Pi com port: RPI

opening a connection to the CEC adapter... TRAFFIC: [ 357] << e0 TRAFFIC: [ 447] << e0 TRAFFIC: [ 539] << 11 TRAFFIC: [ 812] << 11 TRAFFIC: [ 1088] << 1f:84:20:00:01 TRAFFIC: [ 1243] << 10 TRAFFIC: [ 1336] << 10 TRAFFIC: [ 1432] << 10 TRAFFIC: [ 1525] << 10 waiting for input TRAFFIC: [ 7789] >> 0f:87:00:e0:91 TRAFFIC: [ 7790] << 1f:87:00:15:82 TRAFFIC: [ 8030] << 1f:87:00:15:82 TRAFFIC: [ 22929] >> 0f:87:00:e0:91 TRAFFIC: [ 22929] << 1f:87:00:e0:91 TRAFFIC: [ 23173] << 1f:87:00:e0:91 TRAFFIC: [ 38086] >> 0f:87:00:e0:91 TRAFFIC: [ 38086] << 1f:87:00:e0:91 TRAFFIC: [ 38357] << 1f:87:00:e0:91 TRAFFIC: [ 53218] >> 0f:87:00:e0:91 TRAFFIC: [ 53218] << 1f:87:00:e0:91 TRAFFIC: [ 53609] << 1f:87:00:e0:91 TRAFFIC: [ 68371] >> 0f:87:00:e0:91 TRAFFIC: [ 68371] << 1f:87:00:e0:91 TRAFFIC: [ 68582] << 1f:87:00:e0:91 TRAFFIC: [ 83523] >> 0f:87:00:e0:91 TRAFFIC: [ 83523] << 1f:87:00:e0:91 TRAFFIC: [ 83764] << 1f:87:00:e0:91 TRAFFIC: [ 98658] >> 0f:87:00:e0:91 TRAFFIC: [ 98658] << 1f:87:00:e0:91 TRAFFIC: [ 98898] << 1f:87:00:e0:91

cec-client -d 1 log level set to 1 No device type given. Using 'recording device' CEC Parser created - libCEC version 4.0.4 no serial port given. trying autodetect: path: Raspberry Pi com port: RPI

opening a connection to the CEC adapter... waiting for input scan requesting CEC bus information ... CEC bus information

device #1: Recorder 1 address: 2.0.0.0 active source: no vendor: LG osd string: CECTester CEC version: 1.4 power status: on language: eng

currently active source: unknown (-1) cec-client -d 1 log level set to 1 No device type given. Using 'recording device' CEC Parser created - libCEC version 4.0.4 no serial port given. trying autodetect: path: Raspberry Pi com port: RPI

opening a connection to the CEC adapter... waiting for input waiting for input scan requesting CEC bus information ... CEC bus information

device #1: Recorder 1 address: 2.0.0.0 active source: no vendor: LG osd string: CECTester CEC version: 1.4 power status: on language: eng waiting for input waiting for input waiting for input waiting for input waiting for input waiting for input waiting for input waiting for input requesting CEC bus information ... ^Csignal caught: 2 - exiting CEC bus information

device #0: TV address: 0.0.0.0 active source: no vendor: LG osd string: TV CEC version: 1.3a power status: unknown language: eng

device #1: Recorder 1 address: 2.0.0.0 active source: no vendor: LG osd string: CECTester CEC version: 1.3a power status: on language: eng

reidab commented 4 years ago

This is likely caused by the user that's running homebridge not having access to /dev/vchiq. If you're running homebridge as a user named homebridge, you can grant that access by adding them to the video group with:

sudo usermod -a -G video homebridge
nimbling commented 4 years ago

This solved this problem for me, thanks!

Perhaps it's an idea to throw an error when a check for "does current user own that folder" fails?