You need two Rule triggers. You need to trigger at the right time and you need to trigger when the TV turns OFF.
When the Rule triggers because the TV turned off, you need to check if now is between 22:00 and some time in the morning.
rule "Lights off" // the quotes are required I beleive
when
Time cron "0 0 22 ? MON-THU *" or
Item TV changed to OFF
then
// do nothing unless it is Monday through Thursday
if(now.getDayOfWeek < 1 && now.getDayOfWeek > 5) return;
val morningStart = now.withTimeAtStartOfDay.plusHours(6) // choose an appropriate time
val nightStart = now.withTimeAtStartOfDay.plusHours(22)
// do nothing unless it is night time
if(now.isAfter(morningStart) && now.isBefore(nightStart)) return;
// turn OFF the light if the TV is OFF
if(TV.state != ON) Switch01.sendCommand(OFF)
end
The Rule triggers at 22:00 and whenever the TV turns OFF. It immediately exits if it isn’t between Monday and Thursday and if it isn’t between 22:00 and 06:00. If it didn’t immediately exit is means we should turn OFF the Switch but only if the TV isn’t ON.