It’s not the same context as your issue, but this could be useful:
Specifically creating a hass switch, and getting the switch to send the CEC commands, e.g:
platform: command_line
switches:
tv_kodi:
command_on: ssh root@[Kodi IP] "echo 'on 0' | cec-client -s"
command_off: ssh root@[Kodi IP] "echo 'standby 0' | cec-client -s"
friendly_name: TV