Generating LUUP code?

Is there a way to use the scene GUI/Advanced tab to set various settings, and then have that exported to Luup code?

I have several scenes that are exactly the same except for one setting.

It would be easier to manage these if I just had to copy/paste several lines of common code.

Using Luup to call a scene from within another scene messes up timing and I’ve had some failures.

I couldn’t figure out how to do this with the variable container or multiswitch.

What I want to do is:
Common tasks:
group all sonos devices, set a master, set volume levels, turn on stereos, set zone settings, set input and volume settings

unique code:
play a specific station

So, no to harp on Lua, but you can execute a scene with a simple one liner:

luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum=[SceneNumber]}, 0)

So, if you develop the common scene, add this to your luup panel (remember to Save Luup on the bottom).

It seems that perhaps your Sonos is still responding to the first instructions, so to make it more reliable, you can place a delay like this:

function DeferredScene()
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum=9}, 0)
end
luup.call_delay(“DeferredScene”, 15)

This will wait 15seconds before executing the eluup.call_action. Try tweaking the delay to minimize the time and still make sure you get both instructions through as quickly as tolerable to your patience.

there are other ways if you are not happy with this.

A technique I use with MultiSwitch is to have a single scene with multiple triggers - one for each button. Each trigger sets a global variable using code in Luup event. The main code in the LUUP tab uses the variable as required and then sets it to nil. For example:

Trigger 1 Luup event:

sayText = "Button one clicked." return true

Trigger 2 Luup event:

sayText = "Button two clicked." return true

Main scene LUUP:

if (sayText == nil) then sayText = "No button pressed." end luup.call_action("urn:micasaverde-com:serviceId:Sonos1","Say",{Text=sayText, Language="en", Volume=50},105) sayText = nil

I created a scene for closing my sunscreen caused by the windsensor
It works great

Only now it also want’s to close even when it is not out.
So i want to conditional activate the scene

The condition should be that the sunscreen is out

I think that you dan do this with a luup code
But how do i find right code ?

You should be able to find what you need in Conditional Scene Execution.