HDMI-CEC actions with Couch Slouch

I am trying to run AppleScript commands from Couch Slouch, an AppleScript software Which has 6 built in functions and takes AppleScript commands. These can run through a pulse eight HDMI-CEC usb to control your tv from your Mac.
The built in functions are

An example script is posted

tell application "Couch Slouch”
    if cec device is available and not tv is on then

        turn on tv

    end if

end tell

However, AppleScript won’t compile it due to wrong syntax.
What is wrong with the code?

I am confused how to find the name of the TV or CEC device by my Mac as well.
Any tips? Help?

I’m pretty new to AppleScript…but this part of script looks odd…should it be tv is not on?

Again, I really don’t know since I’m a rookie, but AppleScript usually uses pretty straight-forward grammar and this looks off.

I’m not familiar with the application, but I suspect the command tv is on needs to be parsed before the not is parsed. Use parentheses to do that, like this:

if cec device is available and not (tv is on) then

If it were me, I’d clarify the parameters of the if/then statement even further:

if (cec device is available) and (not (tv is on)) then

Maybe that will help your situation.

Stan C.