I’m trying to get HDMI CEC to work consistently but every time the source is switched away from Kodi then back it no longer responds.
CE and BD connected to an Auto HDMI switch, when the BD powers on the switch changes it’s inputs to the BD.
When the BD is powered off it switches back to CE but no CEC commands are working from the remote as they were before switching to BD.
I monitored CEC messages on aocec and I see no inactive source message from the BD when powered off.
The only way to regain CEC control of CE (Kodi) is to restart kodi with systemctl then everything is fine again.
I was working on perhaps querying device active states through CEC at a regulated interval so I could stop Kodi on source change then start it back up with the BD active state goes down.
I just don’t know where to go from here, I don’t even know if this is even a CE problem or a Kodi one.
Can someone point to a direction for me to look, please?
I wrote a service to monitor the hdmi connection state at /sys/class/amhdmitx/amhdmitx0
Based on the connection state stop kodi, start kodi or simply restart kodi on connect.
Restarting on connect with a 2s delay seems to be the most effective, stopping on disconnect then starting on connect often results in the same inability to control kodi via cec.
I’m going to fine tune it and see what can be improved but that’s all.
Fine tuning and grinding out what is happening during Kodi restart I found a second solution.
Simply sending an HDMI-CEC “Active Source” on HDMI connect works as well.
it’s pretty well limited to the rocktek i wrote it for, i made no attempts to make it generic to run across other devices and the CEC active device address is hard coded to my device’s address
i could generalize what you need if i know what that is
meh … i’ll just explain it and then you can write it in c, cpp, bash or a kodi addon whatever you’d like
monitor changes to /sys/class/amhdmitx/amhdmitx0/hpd_state
possible states are 0 (disconnected), 1 (connected), 2 (handshake)
check the value and record it in a variable, when current state is not previous state perform action based on current state
action for restart kodi, execute systemctl with start/stop/restart kodi
to send a cec message write to /dev/aocec
grab “Source Physical Address[a.b.c.d]:” from /sys/class/amhdmitx/amhdmitx0/edid
(i did manually and hardcoded but you can do programmatically)
use https://www.cec-o-matic.com/ to create a cec active source from your device to “Broadcast”
for me my source is 8, broadcast is F message id is 82 for active source, address is 31 00 for 3.1.0.0
so i write the CEC message 8F 82 31 00 to switch active source