as for kodi turning off your tv, that is an option in the kodi settings for the cec plugin, iirc it is in settings / system / peripherals / cec-plugin
as for controlling cec from jivelite, you could check out the cec-utils linux package which allows reacting to cec signals, you can install it with
sudo apt-get install cec-utils
in a terminal. to see info about it you can read the manual by entering
man cec-utils