Hi, I’m running into an issue with HDMI input switching by CEC. Switching to HDMI input 1 from any other input works fine but switching to HDMI input 2 (NintendoSwitch) results in input 4 (RPi) being used. I’ve tried “direct mapping” and “port mapping” config methods as documented in the CEC documentation as well as referencing the device in the script by name, CEC address, or entity ID which all result in the same behavior.
The logs (pasted below) indicate that the config and scripts are working as intended but the TV still responds incorrectly.
Home Assistant 0.112.0 - HassOS 4.10 - RPi3 connected directly to LG TV
Here’s the CEC scanner dump which matches my physical setup:
device #0: TV
address: 0.0.0.0
active source: no
vendor: LG
osd string: TV
CEC version: 1.3a
power status: on
language: eng
device #1: Recorder 1
address: 4.0.0.0
active source: no
vendor: LG
osd string: CECTester
CEC version: 1.3a
power status: on
language: eng
device #4: Playback 1
address: 2.0.0.0
active source: no
vendor: Unknown
osd string: NintendoSwitch
CEC version: 1.3a
power status: on
language: ???
device #8: Playback 2
address: 1.0.0.0
active source: yes
vendor: Unknown
osd string: SHIELD
CEC version: 1.4
power status: on
language: ???
currently active source: Playback 2 (8)
Here’s my config
# Direct mapping
hdmi_cec:
devices:
TV: 0.0.0.0
Shield: 1.0.0.0
NintendoSwitch: 2.0.0.0
Laptop: 3.0.0.0
Pi3: 4.0.0.0
# Alternate config by port mapping. Same result
# hdmi_cec:
# devices:
# 0: TV
# 1: Shield
# 2: NintendoSwitch
# 3: Laptop
# 4: Pi3
Here’s my script
tv_input_shield:
sequence:
- data:
device: 1.0.0.0
service: hdmi_cec.select_device
alias: TV Input Shield
tv_input_switch:
sequence:
- data:
device: 2.0.0.0 # by CEC ID
# device: switch.hdmi_8 # by Entity ID same result
# device: NintendoSwitch # by CEC device name same result
service: hdmi_cec.select_device
alias: TV Input Nintendo Switch
Here’s the log:
2020-07-03 09:32:54 INFO (SyncWorker_11) [pycec] HDMI network starting...
2020-07-03 09:32:54 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2020-07-03 09:32:54 INFO (ThreadPoolExecutor-0_0) [pycec.cec] found a CEC adapter:
2020-07-03 09:32:54 INFO (ThreadPoolExecutor-0_0) [pycec.cec] port: RPI
2020-07-03 09:32:54 INFO (ThreadPoolExecutor-0_0) [pycec.cec] vendor: 0x2708
2020-07-03 09:32:54 INFO (ThreadPoolExecutor-0_0) [pycec.cec] product: 0x1001
2020-07-03 09:32:55 WARNING (ThreadPoolExecutor-1_0) [pycec] Not initialized. Waiting for init.
2020-07-03 09:32:55 INFO (MainThread) [homeassistant.core] Timer:starting
2020-07-03 09:32:56 INFO (ThreadPoolExecutor-0_0) [pycec.cec] connection opened
2020-07-03 09:32:56 INFO (ThreadPoolExecutor-1_0) [pycec] Looking for new devices...
2020-07-03 09:32:56 INFO (MainThread) [homeassistant.components.switch] Setting up switch.hdmi_cec
2020-07-03 09:32:56 INFO (SyncWorker_14) [homeassistant.components.hdmi_cec.switch] Setting up HDMI devices ['hdmi_cec.hdmi_0']
2020-07-03 09:32:57 INFO (MainThread) [homeassistant.components.switch] Setting up switch.hdmi_cec
2020-07-03 09:32:57 INFO (SyncWorker_7) [homeassistant.components.hdmi_cec.switch] Setting up HDMI devices ['hdmi_cec.hdmi_4']
2020-07-03 09:32:59 INFO (MainThread) [homeassistant.components.switch] Setting up switch.hdmi_cec
2020-07-03 09:32:59 INFO (SyncWorker_19) [homeassistant.components.hdmi_cec.switch] Setting up HDMI devices ['hdmi_cec.hdmi_8']
2020-07-03 09:33:26 INFO (ThreadPoolExecutor-1_0) [pycec] Looking for new devices...
2020-07-03 09:33:46 INFO (MainThread) [homeassistant.components.script] TV Input Nintendo Switch: Running script
2020-07-03 09:33:46 INFO (MainThread) [homeassistant.components.script] TV Input Nintendo Switch: Executing step call service
2020-07-03 09:33:46 DEBUG (SyncWorker_12) [homeassistant.components.hdmi_cec] Selecting entity <state switch.hdmi_4=on; vendor_id=2495, vendor_name=0x9bf, type_id=4, type=Playback, physical_address=2.0.0.0, friendly_name=0x9bf NintendoSwitch, icon=mdi:play @ 2020-07-03T09:32:57.997189+09:00>
2020-07-03 09:33:46 DEBUG (SyncWorker_12) [homeassistant.components.hdmi_cec] Address acquired: 2.0.0.0
2020-07-03 09:33:46 INFO (SyncWorker_12) [homeassistant.components.hdmi_cec] Selected switch.hdmi_4 (2.0.0.0)
2020-07-03 09:33:53 INFO (MainThread) [homeassistant.components.script] TV Input Shield: Running script
2020-07-03 09:33:53 INFO (MainThread) [homeassistant.components.script] TV Input Shield: Executing step call service
2020-07-03 09:33:53 DEBUG (SyncWorker_1) [homeassistant.components.hdmi_cec] Selecting entity <state switch.hdmi_8=on; vendor_id=1099, vendor_name=0x44b, type_id=4, type=Playback, physical_address=1.0.0.0, friendly_name=0x44b SHIELD, icon=mdi:play @ 2020-07-03T09:32:59.260928+09:00>
2020-07-03 09:33:53 DEBUG (SyncWorker_1) [homeassistant.components.hdmi_cec] Address acquired: 1.0.0.0
2020-07-03 09:33:53 INFO (SyncWorker_1) [homeassistant.components.hdmi_cec] Selected switch.hdmi_8 (1.0.0.0)
2020-07-03 09:33:56 INFO (ThreadPoolExecutor-1_0) [pycec] Looking for new devices...
2020-07-03 09:34:26 INFO (ThreadPoolExecutor-1_0) [pycec] Looking for new devices...