Lights scene setter


(Roberto Santini) #1

Hi, I have made my OH2 configurations on Raspberry, with some lights connected to relay. Now I want to do some scenes, so in scene 1 I turn on only light 1 and 2 (and the other turn off); in scene 2 I turn on light 3 and 4, … and so on.
I have found some examples in this forum, for example: Examples of Scenes. In my config, I have a switch for every scenes, so I can turn ON/OFF the scene. Is this the best way to do this? Or in OH2 there is a better way?

Thanks!
Roberto


(Markus Gehlhaar) #2

You can use a single switch with a mapping like this:

Item:
Number Light_Scene_Item

Sitemap:
Switch item=Light_Scene_Item label="‌‌Scene" mappings=[0="Off", 1="Cozy", 2="Normal", 3="Bright"]

The rule could look like this:

rule "Light_Scene_Item Event"
when
	Item Light_Scene_Item received command
then
	switch receivedCommand{
		case 0:{
			Hue_State_WohnZ2.sendCommand(OFF)
			Swi_WohnZ2_Schrank.sendCommand(OFF)
		}
		case 1:{
			Swi_WohnZ2_Schrank.sendCommand(ON)
			Hue_State_WohnZ2.sendCommand(OFF)
		}
		case 2:{
			Hue_State_WohnZ2.sendCommand(ON)
			Thread::sleep(350)
			Swi_WohnZ2_Schrank.sendCommand(OFF)
		}
		case 3:{
			Hue_State_WohnZ2.sendCommand(ON)
			Swi_WohnZ2_Schrank.sendCommand(ON)
		}
	}
end

(Rich Koshak) #3

Note that your Light_Scene_Item needs to be a Numer Item in this context.


(Markus Gehlhaar) #4

Thanks. I added this to my post above.


(Matthew) #5

Hi, how would I keep the highlighting of the scene (in this case the highlighting of “Off”, “Cozy”,“Normal”,“Bright” switches in BasicUI sitemap) to not highlight when it is not set in said scene?


(Kim Skatun) #6

Hi all,
I am working on a scene tutorial, which is more generic than this example, where you can combine different item types.

The concept is basically that you just tag each item with the scene group that you want it to belong to, so an item can belong to several group.

It should be ready pretty soon…