[SOLVED] Creating a Scene

My question was actually answered and i willl set this back to “resolved”, but i first have another additional question and issue.
Unless this should be put in a different post, then i will :slight_smile:

So i got this working with method nr2 of your link.
I do have another question tho.
Could you explain what the postupdate is for please, i dont get it?

Scene_Wakeup.postUpdate(OFF)

Then for my issue: thing is i can set my scene to on without any problems but not to off.
The google device says its turning it off when i ask but nothing happends.
Same thing with the switch i created in my Sitemap, same bahavior.
Am i doing something wrong?

i have 1 item:

Switch              Scene_Eten                "Etenstijd"    <dinner>      (Home, Scene) [ "Switchable" ]

and my rule:

rule "Etenstijd"
when
	Item Scene_Eten received command ON
then
	logInfo("Scene Etenstijd gestart", "bjorn en lili licht aan bij starten van de scene")
      Officebjornlicht.sendCommand(ON)
	Officelililicht.sendCommand(ON)	
	

end

Both, officebjornlight and officelililight also have the tag [ “Lighting” ] if this matters.
Any idea please?

I’m not a google user but looking at github readme https://github.com/openhab/openhab-google-assistant/blob/master/USAGE.md you can use the tag [ “Scene” ] see the examples in the link.

EDIT: I should have reviewed the link posted above before mentioning scene as a tag.:roll_eyes:

See this link for documentation about postUpdate: https://www.openhab.org/docs/configuration/rules-dsl.html#myitem-sendcommand-new-state-versus-sendcommand-myitem-new-state

Need to add Scene_Eten.postUpdate(OFF) to your rule like below.

rule "Etenstijd"
when
	Item Scene_Eten received command ON
then
	logInfo("Scene Etenstijd gestart", "bjorn en lili licht aan bij starten van de scene")
      Officebjornlicht.sendCommand(ON)
	Officelililicht.sendCommand(ON)	
	
      Scene_Eten.postUpdate(OFF)

end

Hey H102,

thx for ur reply!
i tried changing “switchable” to “scene” but then it doesnt work at all.

But either way i think i am doing something wrong and the above is not the issue.
let aside the google home, i am having this issue even when using my Basic UI button, it is the same issue.
I can turn my both lights on when i switch my switch.
But when i turn the switch back off, nothing happends.

this is what i see in my logs:

2018-11-25 17:46:50.236 [INFO ] [model.script.Scene Etenstijd gestart] - bjorn en lili licht aan bij starten van de scene


2018-11-25 17:46:50.252 [ome.event.ItemCommandEvent] - Item 'Officebjornlicht' received command ON

2018-11-25 17:46:50.268 [ome.event.ItemCommandEvent] - Item 'Officelililicht' received command ON

2018-11-25 17:46:50.278 [vent.ItemStateChangedEvent] - Officebjornlicht changed from OFF to ON

2018-11-25 17:46:50.287 [vent.ItemStateChangedEvent] - Officelililicht changed from OFF to ON

2018-11-25 17:46:53.877 [ome.event.ItemCommandEvent] - Item 'Scene_Eten' received command OFF

2018-11-25 17:46:53.893 [vent.ItemStateChangedEvent] - Scene_Eten changed from ON to OFF

Like it does not trigger a “off” to my items.

The rule is for turning the lights on. You will need to adjust or create another rule for turning the lights off.

Yeh i was kinda getting the same idea.

My idea was because it is a switch it would be able to do the reverse.
i get why the “postupdate” has to be there now :slight_smile:

How would you handle my issue?
Would you create a off rule or do u never use a Scene like “on” “off”?
Suppose i can make the same rule again but with the name “stop scene dinner”, but is this how you would advise?

I’m new to writing rules this way but you can test this to see if it works.

rule "Etenstijd"
when
	Item Scene_Eten received command ON
then
	logInfo("Scene Etenstijd gestart", "bjorn en lili licht aan bij starten van de scene")
      Officebjornlicht.sendCommand(if(Officebjornlicht.state == ON) ON else OFF)
	Officelililicht.sendCommand(if(Officelililicht.state == ON) ON else OFF)
	
      Scene_Eten.postUpdate(OFF)

end

The rule should change the light to it’s opposite state every time Scene_Eten receives command ON.:crossed_fingers:

EDIT: Now the rule has been tested and works, credit goes to @rlkoshak for showing me how to use edge cases.:sunglasses: Thanks Rich

1 Like

ok, ok, getting there.
had to change the code a little bit:

rule "Etenstijd"
when
	Item Scene_Eten received command ON
then
	logInfo("Scene Etenstijd gestart", "bjorn en lili licht aan bij starten van de scene")
      //Officebjornlicht.sendCommand(ON)
	//Officelililicht.sendCommand(ON)
      Officebjornlicht.sendCommand(if(Officebjornlicht.state == OFF) ON else OFF)
	Officelililicht.sendCommand(if(Officelililicht.state == OFF) ON else OFF)	
	
      Scene_Eten.postUpdate(OFF) 

end

but the button indeed works.
obviously i trigger 2x a “on” position, so with the postupdate back to “off” this works rly well in the basicUI.
Small thing when now trasferring this to my google… is that i have to say “dinner time ON” for turning it on and turning it off.
But this is minor… seems i can just say “dinner time” without on or off and it will choose the “on” option by default.
When google replies it obviously says “dinner time turned on”

But i can live with this :slight_smile:
Thx!

Try using only Item Scene_Eten received command with out the ON

1 Like

that actually works !
then i got my perfect example to start creating more rules :slight_smile:

Thx!

maybe a stupid question,
i use a custom png icon, this disappears when using the button, any idea?
my guess it that this reprents a off state as icon, not on, not sure tho
And i only have this issue with my 1-in-use custom icon

1 Like

Disappears from BasicUI or other control interface?

In the BasicUI , yes.

before i use the button:

after i have used the button:

it stays like this untill i switch between categories and come back to my “scene’s”

From the BasicUI screen what happens when you use the button (icon disappears) then press F5 (screen refreash) on keyboard?

Let me clear something up about the use of the Scene rules from my post that was linked above, specifically for method #2.

Each Scene rule is for a different set of light states, colors, etc… that you want to set when that “Scene” is selected (either via a BasicUI switch or via Google). The switch that selects the scene has nothing to do with the actual light states - think of it as a momentary pushbutton (you press the button, the lights go to their predefined states, you release the pushbutton). If you want a different set of states (a different “scene”), you need another “pushbutton” (i.e. another scene/rule).

All the postUpdate(OFF) does is set the Scene pushbutton OFF after you’ve pressed it ON (handling the “momentary” functionality of it).

As you’ve found out, keep the “Switchable” tag on these Scene switches - I haven’t played around with the “Scene” tag in Google Assistant yet, so I don’t know how it differs from a “Switchable” or how it affects my Scene rules in the referenced post.

1 Like

That works, as i would think tho, because its the same as changing between categories imo.
But dont worry to much about the icon tho !

Hey Bartus,

what an honor to have you reply to my post :slight_smile:
Thx for you reply.

All very clear of what you say.
And yes, another movie also said to only use 3 items and not the [“scene”] , switchable, lightening, something with temp, but was a good try :slight_smile:

Now as i have been testing.
H102 asked me to:

This seems to be working as well.
What are your thoughts?

EDIT: actually now i come to think of it, this part matters aswell for this to work:

Officebjornlicht.sendCommand(if(Officebjornlicht.state == OFF) ON else OFF)
Officelililicht.sendCommand(if(Officelililicht.state == OFF) ON else OFF)	

Curious why this happens thou.:thinking:

Have you tried using the icon by adding it to the sitemap file for the Scene_Eten item?

I dont think i get what u mean.
i have in my sitemap a category “scenes” and in this category i have my switch “dinner time”, it is about that icon i was talking about.

Tried this same icon on the category name, and this has no issue.
though i dont have buttons directly available in my homepag of my sitemap :slight_smile:

This seems like you’re wanting the lights to toggle when you press the “Scene” button, which is OK, but not the intended use I had in mind :slight_smile:

Sitemap example for adding an icon:

Switch item=Officebjornlicht icon="dinner"

Yeh, when i was writing starting thinking of some more scenarios where i would want to use it like you said.

But am i correct when i say that you can not turn of your scenes?
U need to turn them off one by one or change to a different scene to do this?
You did not create a “off” scene either then?

and i think i need to start adding a lot of lamps at the start of a scene to turn off in case they were on :stuck_out_tongue: