[SOLVED] Rule lights on if TV on after sunset

Hey Guys,

I need a rule for this scene:
I want to switch some lights on if the TV went on:

rule "Szene TV an"
when
	Item TV_Switch changed to ON
then
		Lichtleiste.sendCommand(ON)
		Hue_Color_Wohnzimmer_links.sendCommand("35,90,50")
		Hue_Color_Wohnzimmer_rechts.sendCommand("35,90,50")
		Hue_Color_Kueche_links.sendCommand("35,90,50")
		Hue_Color_Kueche_rechts.sendCommand("35,90,50")
		Hue_Toole_Leselampe.sendCommand(OFF)
	}
end

So far so good. But, I want that the lights switched only on after sunset. Somebody an idea how to do this? I already use the Astro function astro:sun:local:set#event for some other events.

Thank you!

Kind regards,

Add a number item for the sun elevation
Then

rule "Szene TV an"
when
    Item TV_Switch changed to ON
then
    if (SunElevationItem.state < 0) { // Sun is down
        Lichtleiste.sendCommand(ON)
        Hue_Color_Wohnzimmer_links.sendCommand("35,90,50")
        Hue_Color_Wohnzimmer_rechts.sendCommand("35,90,50")
        Hue_Color_Kueche_links.sendCommand("35,90,50")
        Hue_Color_Kueche_rechts.sendCommand("35,90,50")
        Hue_Toole_Leselampe.sendCommand(OFF)
        }
    }
end

I use an additional item which represents the day state.
You can use it then for different rules.

A tutorial can be found here:

1 Like

Hey Guys,

the rule is working fine. But I have a new issue.

Yesterday I switched the TV off at 22.42 o’clock:
2020-01-05 22:42:59.262 [vent.ItemStateChangedEvent] - SamsungTV_Power changed from ON to OFF

After round about 2 minutes, the state of the TV changed automatically again to on:
2020-01-05 22:44:44.329 [vent.ItemStateChangedEvent] - Samsung_Power changed from OFF to ON

So the lights will be switched again on, and will stay on till the next morning.

The TV is a Samsung and connected via LAN cable to the network.

Somebody with an similar problem? How do you resolved it?

Thanks a lot!

You have two individual items in your event.log:
SamsungTV_Power
Samsung_Power

And in your initial post the triggered item in the rule was “TV_Switch”.

1 Like

Well I changed the Name of switch, because i want to integrated further switches.

You are right. I use two different *_Power items. Thank you. Now the rule is working…