Fibaro dimmer and S2 button as scene controller

@DragonVera which device property are you using in PLEG? sl_SceneActivated?

Yes

Name Device Name Device Variable Last Change Value
SceneActivated Upstairs Hallway Lights sl_SceneActivated 2013-11-09 18:07:26.689 0
LastSceneID Upstairs Hallway Lights LastSceneID 2013-11-09 18:07:26.731 26
LastSceneTime Upstairs Hallway Lights LastSceneTime 2013-11-09 18:07:26.774 1383980846

Strangely though, I’ve just tried to do exactly the same setup with another fibaro dimmer (with same firmware Version 3,3,52,2,2 ), and on this dimmer I can’t seem to find the device variables sl_SceneActivated, LastSceneID or LastSceneTime when I look for them in the PLEG. ???

Strangely though, I've just tried to do exactly the same setup with another fibaro dimmer (with same firmware Version 3,3,52,2,2 ), and on this dimmer I can't seem to find the device variables sl_SceneActivated, LastSceneID or LastSceneTime when I look for them in the PLEG. ???
I think the scene variables only get created after you have set variable 41 to 1 and restarted Vera.
And what is the significance of scenes 24 and 26?
These are explained in the instruction sheet for FGD211 - under Parameter 41. They indicate which switch and action initiated the scene:

14 = S1 double-click
15 = S1 triple-click
16 = S1 single click
24 = S2 double-click
25 = S2 triple-click
26 = S2 single click

I think the scene variables only get created after you have set variable 41 to 1 and restarted Vera.

In my case the variables got created after I set Parameter 41 to 1, then did a double click on the switch, and then reloaded the UI in the browser.

nice ! got it working with fibaro universal sensor thnx to filifjonkan instructions for PLEG … 2 scene buttons now ^^

Is it possible to use either button, on a dimmer with 2.2 firmware, as a scene controller, without PLEG?

Yes, it is, thanks to @RexBeckett http://forum.micasaverde.com/index.php/topic,18679.msg217315.html#msg217315

Here’s how an example of how to run a scene when a button (s1) is double-clicked, on 2 different Fibaro modules.

Note parameter 15 (the one that when double-clicked gives you 100% brightness) has to be set to the default of “1”, or the double click variable doesn’t seem to show up.

Startup Lua:

[code]-- Set up variable-watch for device 306 (Kitchen Downlights)
luup.variable_watch(“doChange306”,“urn:micasaverde-com:serviceId:SceneController1”, “LastSceneID”,306)

– Set up variable-watch for device 308 (Middle Deck Light)
luup.variable_watch(“doChange308”,“urn:micasaverde-com:serviceId:SceneController1”, “LastSceneID”,308)

– Process variable-watch callback for device 306. Run scene 161
function doChange306()
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = 161}, 0)
end
– Process variable-watch callback for device 308. Run scene 160
function doChange308()
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = 160}, 0)
end[/code]

Scene (160) Luup:

[code]local DoubleClick = luup.variable_get(“urn:micasaverde-com:serviceId:SceneController1”, “LastSceneID”, 308)

if (DoubleClick== “14”)
then return true
else return false

end[/code]

I’ve decided to use the sl_SceneActivated variable, instead of the LastSceneID, because if the same button sequence is pressed twice in a row, then the variable doesn’t change and the scene won’t run.

sl_SceneActivated seems to be changed briefly after every button press, which is what I want as a trigger.

I’m also trying to get the condition for the scene running, (double-clicking), included into the start-up Lua, because if I want to run scene manually from my phone, it will fail to do, so unless the last button press was a double click.

I’ve inserted a delay of one second because the scene was running sometimes when it shouldn’t have been, so I can only assume LastSceneID wasn’t being updated quick enough.

I hope this helps somebody, and if anyone can give me tips on a better way to achieve this, or something I’m doing wrong etc. please don’t hesitate, because I’m a complete novice just messing around.

[code]-- Set up variable-watch for device 308 (Any button press on Middle Deck Light)
luup.variable_watch(“ButtonPressed308delay”,“urn:micasaverde-com:serviceId:SceneController1”, “sl_SceneActivated”,308)

– Process variable-watch callback for device 308. Run function after 1 second to give LastSceneID a chance to update.
function ButtonPressed308delay()
luup.call_delay(“ButtonPressed308”, 1)
end

– Process variable-watch callback for device 308. Run scene 160, if button double-clicked (ID:14)
function ButtonPressed308()
if (luup.variable_get(“urn:micasaverde-com:serviceId:SceneController1”, “LastSceneID”, 308) == “14”) then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = 160}, 0)
end
end[/code]

And here’s how to incorporate more than 1 module and look out for triple clicks on S1:

[code]-- Set up variable-watch for device 306 (Any button press on Kitchen Downlights)
luup.variable_watch(“ButtonPressed306delay”,“urn:micasaverde-com:serviceId:SceneController1”, “sl_SceneActivated”,306)

– Set up variable-watch for device 308 (Any button press on Middle Deck Light)
luup.variable_watch(“ButtonPressed308delay”,“urn:micasaverde-com:serviceId:SceneController1”, “sl_SceneActivated”,308)

– Process variable-watch callback for device 306. Run function after 1 second to give LastSceneID a chance to update.
function ButtonPressed306delay()
luup.call_delay(“ButtonPressed306”, 1)
end

– Process variable-watch callback for device 306. Run scene 161, if button double-clicked (ID:14), or if triple clicked (ID:15), run scene 178
function ButtonPressed306()
if (luup.variable_get(“urn:micasaverde-com:serviceId:SceneController1”, “LastSceneID”, 306) == “14”) then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = 161}, 0)

elseif (luup.variable_get("urn:micasaverde-com:serviceId:SceneController1", "LastSceneID", 306) == "15") then
	luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = 178}, 0)
	end
end

– Process variable-watch callback for device 308. Run function after 1 second to give LastSceneID a chance to update.
function ButtonPressed308delay()
luup.call_delay(“ButtonPressed308”, 1)
end

– Process variable-watch callback for device 308. Run scene 160, if button double-clicked (ID:14)
function ButtonPressed308()
if (luup.variable_get(“urn:micasaverde-com:serviceId:SceneController1”, “LastSceneID”, 308) == “14”) then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, {SceneNum = 160}, 0)
end
end[/code]