Kodi on-off based on Tv status (created script, need some help)

I’ll give it a look.
Can this script check tv status inside Kodi with CEC, without interfer with internal kodi-cec ?

If one should cec control status of tv when Kodi is started, without interfer with internal kodi cec, we can make a script that tells kodi to stop mediacenter when tv is off (instead close Kodi, that automatic restarts). And when kodi is closed, standard cec control to view status to run Kodi when tv is on.