johnboiles / esphome-hdmi-cec

ESPHome component to send and receive HDMI-CEC messages.
62 stars 10 forks source link

Sony and ESP32 #4

Open nagyrobi opened 1 year ago

nagyrobi commented 1 year ago

I'm testing this now on an ESP32 with a Sony TV. The code in the PR doesn't work, but the code in the parent repo at github://johnboiles/esphome-hdmi-cec@main works nicely while the TV is on. I had to extend the example with:

        - opcode: 0x9F # Give CEC version
          then:
            - hdmi_cec.send:
                destination: 0x0
                data: [0x9e, 0x00]

for the Sony to discover the ESPHome device as an audio unit.

I also try to know of the TV is on or off, and this works:

button:
- platform: template
  name: "Get power state"
  on_press:
    - logger.log: Querying powr state
    - hdmi_cec.send:
        destination: 0x0
        data: [0x8F]

binary_sensor:
- platform: template
  id: tv_power
  name: "TV Power"
  device_class: power

hdmi_cec:
   ...
   on_message:
        - data: [0x90, 0x00] # Power status: On
          then:
            - logger.log: "Power state On"
            - binary_sensor.template.publish:
                id: tv_power
                state: ON
        - data: [0x90, 0x01] # Power status: Standby
          then:
            - logger.log: "Power state Standby"
            - binary_sensor.template.publish:
                id: tv_power
                state: OFF
        - data: [0x90, 0x02] # Power status: Standby > On
          then:
            - logger.log: "Power state Standby > On"
            - binary_sensor.template.publish:
                id: tv_power
                state: ON
        - data: [0x90, 0x03] # Power status: On > Standby
          then:
            - logger.log: "Power state On > Standby"
            - binary_sensor.template.publish:
                id: tv_power
                state: OFF

Turning the TV off or on while the node is connected, reboots the node:

[23:04:14:768] <0x1b>[0;36m[D][hdmi_cec:065]: RX: (0->5) 05:70<0x1b>[0m␍␊
[23:04:14:768] <0x1b>[0;36m[D][hdmi_cec:126]: TX: (5->15) 5F:72:01<0x1b>[0m␍␊
[23:04:14:930] <0x1b>[0;36m[D][hdmi_cec:065]: RX: (0->15) 0F:36<0x1b>[0m␍␊
[23:04:15:248] Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1). ␍␊
[23:04:15:248] ␍␊
[23:04:15:248] Core  1 register dump:␍␊
[23:04:15:248] PC      : 0x4008e6c6  PS      : 0x00060e35  A0      : 0x8008d3e6  A1      : 0x3ffbeb6c  ␍␊
[23:04:15:248] A2      : 0x3ffd032c  A3      : 0x3ffb88f0  A4      : 0x00000004  A5      : 0x00060e23  ␍␊
[23:04:15:270] A6      : 0x00060e23  A7      : 0x00000001  A8      : 0x3ffb88f0  A9      : 0x00000018  ␍␊
[23:04:15:270] A10     : 0x3ffb88f0  A11     : 0x00000018  A12     : 0x3ffc429c  A13     : 0x00060e23  ␍␊
[23:04:15:270] A14     : 0x007bf0b8  A15     : 0x003fffff  SAR     : 0x00000019  EXCCAUSE: 0x00000006  ␍␊
[23:04:15:292] EXCVADDR: 0x00000000  LBEG    : 0x400892fc  LEND    : 0x40089312  LCOUNT  : 0xffffffff  ␍␊
[23:04:15:292] Core  1 was running in ISR context:␍␊
[23:04:15:292] EPC1    : 0x400f3943  EPC2    : 0x00000000  EPC3    : 0x4000bff0  EPC4    : 0x00000000␍␊
[23:04:15:292] ␍␊
[23:04:15:314] ␍␊
[23:04:15:314] Backtrace:0x4008e6c3:0x3ffbeb6c |<-CORRUPTED␍␊
[23:04:15:314] ␍␊
[23:04:15:314] ␍␊
[23:04:15:314] Core  0 register dump:␍␊
[23:04:15:314] PC      : 0x4008e847  PS      : 0x00060035  A0      : 0x8008df2f  A1      : 0x3ffb4dd0  ␍␊
[23:04:15:314] A2      : 0x3ffbf0b8  A3      : 0xb33fffff  A4      : 0x0000abab  A5      : 0x00060023  ␍␊
[23:04:15:336] A6      : 0x00060023  A7      : 0x0000cdcd  A8      : 0x0000abab  A9      : 0xffffffff  ␍␊
[23:04:15:336] A10     : 0x3ffbec64  A11     : 0x3ffb4f1c  A12     : 0x000000fa  A13     : 0x000071fe  ␍␊
[23:04:15:336] A14     : 0x007bf0b8  A15     : 0x003fffff  SAR     : 0x00000019  EXCCAUSE: 0x00000006  ␍␊
[23:04:15:359] EXCVADDR: 0x00000000  LBEG    : 0x400892fc  LEND    : 0x40089312  LCOUNT  : 0xffffffff  ␍␊
[23:04:15:359] ␍␊
[23:04:15:359] ␍␊
[23:04:15:359] Backtrace:0x4008e844:0x3ffb4dd00x4008df2c:0x3ffb4e10 0x4008bd22:0x3ffb4e30 0x4008c1ba:0x3ffb4e50 0x4010cd32:0x3ffb4e90 0x4010d04a:0x3ffb4eb0 0x4010e23b:0x3ffb4ed0 0x401103a9:0x3ffb4ef0 0x400fe807:0x3ffb4f10 ␍␊
[23:04:15:369] ␍␊
[23:04:15:369] ␍␊
[23:04:15:369] ␍␊
[23:04:15:369] ␍␊
[23:04:15:369] ELF file SHA256: 0000000000000000␍␊
[23:04:15:369] ␍␊
[23:04:15:369] Rebooting...␍␊
[23:04:15:392] ets Jun  8 2016 00:22:57␍␊
[23:04:15:392] ␍␊
[23:04:15:392] rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)␍␊
[23:04:15:392] configsip: 0, SPIWP:0xee␍␊
[23:04:15:392] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00␍␊
[23:04:15:392] mode:DIO, clock div:2␍␊
[23:04:15:392] load:0x3fff0030,len:1184␍␊
[23:04:15:392] load:0x40078000,len:13132␍␊
[23:04:15:399] load:0x40080400,len:3036␍␊
[23:04:15:399] entry 0x400805e4␍␊
[23:04:15:788] <0x1b>[0;32m[I][logger:258]: Log initialized<0x1b>[0m␍␊
[23:04:15:788] <0x1b>[0;35m[C][ota:469]: There have been 2 suspected unsuccessful boot attempts.<0x1b>[0m␍␊

It's not related to the 5V connected to pin 18. It happens regardless of this pin being connected or not (actually, the device detects the ESPHome well without the 5V being connected to pin 18).

I observed that the last CEC message decoded in the log before the reboot was either 0F:36 or 0F:84:00:00:00 or 0F:80:00:00:30:00. These seem to be broadcast messages.

Edit: tested with another TV ser, issue is exactly the same. The node reboots when 0F:32:68:75:6E comes in from TV.