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

Panasonic viera link issues #11

Open 1rado1 opened 5 years ago

1rado1 commented 5 years ago

Hi Dominick, any chance to get his plugin work with panasonic viera link TV? Since previous plugin homebridge-hdmi-cec works just fine, using this one I am not able to control tv at all. Can you please take a quick look at it? Thanks

panasonic TX-55DX603E Here is my log:

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: [ 182] << e0 TRAFFIC: [ 242] << e0:8c TRAFFIC: [ 489] >> 0f:87:00:80:45 TRAFFIC: [ 489] << 44 TRAFFIC: [ 819] << 88 TRAFFIC: [ 1089] << 88 TRAFFIC: [ 1360] << 8f:84:30:00:04 TRAFFIC: [ 1512] << 80:47:43:45:43:54:65:73:74:65:72 TRAFFIC: [ 1812] << 80:8f TRAFFIC: [ 1980] >> 08:00:47:00 TRAFFIC: [ 2242] >> 08:90:01 waiting for input TRAFFIC: [ 2437] >> 08:89:10:01:05 TRAFFIC: [ 3039] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 4289] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 5539] >> 08:a0:00:80:45:06:05 tx 10:04 TRAFFIC: [ 9561] << 10:04 TRAFFIC: [ 9939] >> 0f:a0:00:80:45:20:00:01 waiting for input TRAFFIC: [ 11062] << 80:89:10:02:ff:ff:00:05:05:45:55:5c:58:32 TRAFFIC: [ 541826] >> 0f:82:00:00 TRAFFIC: [ 542667] >> 0f:80:00:00:10:00 TRAFFIC: [ 543022] >> 0f:82:00:00 TRAFFIC: [ 543484] >> 0f:80:10:00:20:00 TRAFFIC: [ 543822] >> 4f:a6:06:10:56:10 TRAFFIC: [ 543969] >> 4f:84:10:00:04 TRAFFIC: [ 544045] >> 4f:85 TRAFFIC: [ 544172] >> 0f:86:20:00 TRAFFIC: [ 544260] >> 4f:90:01 TRAFFIC: [ 544647] >> 0f:84:00:00:00 TRAFFIC: [ 544647] << 8f:84:30:00:04 TRAFFIC: [ 545372] >> 4f:87:00:10:fa TRAFFIC: [ 546075] >> 08:8c TRAFFIC: [ 546075] << 8f:87:00:80:45 TRAFFIC: [ 546549] >> 08:89:10:01:05 TRAFFIC: [ 546549] << 80:89:10:02:ff:ff:00:05:05:45:55:5c:58:32 TRAFFIC: [ 547500] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 548749] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 549999] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 561338] >> 0f:82:00:00 TRAFFIC: [ 561571] >> 0f:80:20:00:10:00 TRAFFIC: [ 562226] >> 0f:86:10:00 TRAFFIC: [ 562698] >> 4f:a6:06:10:56:10 TRAFFIC: [ 562845] >> 4f:84:10:00:04 TRAFFIC: [ 562921] >> 4f:85 TRAFFIC: [ 563026] >> 4f:90:01 TRAFFIC: [ 563482] >> 0f:84:00:00:00 TRAFFIC: [ 563482] << 8f:84:30:00:04 TRAFFIC: [ 564366] >> 4f:90:00 TRAFFIC: [ 564644] >> 4f:82:10:00 TRAFFIC: [ 564975] >> 4f:87:00:10:fa TRAFFIC: [ 565425] >> 08:8c TRAFFIC: [ 565425] << 8f:87:00:80:45 TRAFFIC: [ 565902] >> 08:89:10:01:05 TRAFFIC: [ 565903] << 80:89:10:02:ff:ff:00:05:05:45:55:5c:58:32 TRAFFIC: [ 566854] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 568100] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 569354] >> 08:a0:00:80:45:06:05 TRAFFIC: [ 576684] >> 0f:82:00:00

mandoolorian commented 4 years ago

made it work on my Viera TV by changing some of the cec-client commands in the script, RPi on HDMI 2:

cecClient.stdout.on('data', data => { const traffic = data.toString(); if (traffic.indexOf('<< 40:47:43:45:43:54:65:73:74:65:72') !== -1) { cecClient.stdin.write('tx 40:47:52:50:69\n'); // Set OSD String to 'RPi' } if (traffic.indexOf('>> 04:90:01') !== -1) { tvEvent.emit('POWER_OFF'); } else if (traffic.indexOf('>> 0f:a0:00:80:45:20:01:11') !== -1) { tvEvent.emit('POWER_OFF'); } if (traffic.indexOf('>> 04:90:00') !== -1) { tvEvent.emit('POWER_ON'); } else if (traffic.indexOf('>> 0f:a0:00:80:45:20:00:01') !== -1) { tvEvent.emit('POWER_ON'); } const match = />> (0f:86:\d0:00|0f:86):(\d)0:00/.exec(traffic); if (match) { tvEvent.emit('INPUT_SWITCHED', match[2]); }

and then

getPowerStatus(callback) { this.log.info(Checking TV power status); cecClient.stdin.write('tx 40:8f\n'); // 'pow 0' const handler = () => { handler.activated = true; callback(null, true); this.log.info('TV is on'); }; tvEvent.once('POWER_ON', handler); setTimeout(() => { tvEvent.removeListener('POWER_ON', handler); if (!handler.activated) { callback(null, false); this.log.info('TV is off'); } }, 1000);

and then

                    // Send on or off signal
                    cecClient.stdin.write(value ? 'tx 40:04\n' : 'tx 40:36\n');
            }

            setInput(value, callback) {
                    this.log.info(`Switching to HDMI${value}`);
                    if (!this.tvService.getCharacteristic(Characteristic.Active).value) {
                            this.log.info(`TV is off; Retrying to switch input after TV turns on`);
                            tvEvent.once('POWER_ON', () => { this.setInput(value, callback); });
                            return;
                    }
                    // const handler = () => {
                    //      handler.activated = true;
                    //      callback();
                    //      this.log.info(`TV is switched to HDMI${value}`);
                    // };
                    // tvEvent.once('INPUT_SWITCHED', handler);
                    // setTimeout(() => {
                    //      tvEvent.removeListener('INPUT_SWITCHED', handler);
                    //      if (!handler.activated) {
                    //              callback(`TV is not switching to HDMI${value}`);
                    //              this.log.info(`TV is not switching to HDMI${value}`);
                    //      }
                    // }, 30000);
                    cecClient.stdin.write(`tx 4f:82:${value}0:00\n`);

I'm a hobbyist diy kinda guy and not a programmer but hope this helps