Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

How to trigger a scene in double switch 2 by held down in lua? FGS-223


Question

Posted

Hello

 

Please help me.

I want to make a scene:

If i hold down S1 then S2 activaiting and then when i click once S1 then S1 and S2 turns off.

parameter 28 key hold down and key released is activated.

I have momentary switch.

S1 id is 312 and S2 id is 313

 

That lua not working:

 

--[[
%% properties
199 sceneActivation
%% weather
%% events
%% globals
--]]

local pressSource = fibaro:getSourceTrigger();
if 
 (tostring(pressSource["keyAttribute"]) == "HeldDown")
then
    fibaro:call(313, "turnOn");
if
   fibaro:call(313 , "TurnOff")
end

 

 

15 answers to this question

Recommended Posts

  • 0
Posted

First of all is the scene activated? and you probably get an error right?

You need to fix the code... you have two IF but one END.

Since S1 is 312 and S2 is 313... what device is 199?

 

  • 0
Posted

FGS-223 doesn't do "sceneActivation" but instead uses the newer Central Scene Event. Z-Wave has 3 types of "scene" control ("scene controller", "scene activation", "central scene")...

 

See if you can make this work. Please edit the header, use first slave for "CentralSceneEvent" ID (not master, not switch itself.) - this was important  1 year ago, I am not sure if this is necessary on recent HC firmware versions. I cannot test right now.

 

Please login or register to see this code.

 

  • Like 1
  • Thanks 1
  • 0
  • Inquirer
  • Posted

    Like  this i get debug:

    unexpected symbol near 313

    What im missing?

     

     

     

     

     

     

    --[[
    %% properties
    %% events
    312 CentralSceneEvent
    %% globals
    --]]

    local trigger = fibaro:getSourceTrigger()
    if (trigger.type == "other") then
      fibaro:debug("Scene started by clicking 'start' button")
    else
      local pressSource = fibaro:getSourceTrigger().event.data
      fibaro:debug("CentralSceneEvent received from key: "..pressSource.keyId)
      if pressSource.keyAttribute == "HeldDown" then
        fibaro:debug("HeldDown") 313
      else
        fibaro:debug("Unknown CentralSceneEvent:"..pressSource.keyAttribute)
      end
    end

    • 0
    Posted

    Exactly what it says: That: "313" does not belong there, in the middle of your scene... What are you trying to do?

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted

    I want to make like this:

    If i hold down S1 then S2 activaiting and after one click S1 and S2 turns both off.

    Parameter 28 key hold down and key released is activated.

    I have momentary switch.

    S1-id:312 and S2-id:313

     

    I have there singel switch which is connected only S1-lamp and S2 source is lamp. What i want to activate second lamp while holding switch (S1)

     

     

    Error for now is:[DEBUG] 13:21:15: 2018-12-13 13:21:15.459790 [ fatal] Unknown exception: /opt/fibaro/scenes/47.lua:15: unexpected symbol near '313'

     

     

    Thank you for the answer!

    • 0
    Posted

    I am sorry, I cannot write that scene right now, because I am on holiday...

    • 0
    Posted

    @Jarts495,

     

    I see line

    Please login or register to see this code.

    That 313 does not belong to that line, so please, delete that 313.

     

    Should be like this:

    Please login or register to see this code.

     

    Regards,

    Jakub

    • 0
  • Inquirer
  • Posted

    @Jarts495 @Jarts495 @Jarts495

    3 hours ago, Jarts495 said:

    ok.

    Now i deleted 313. Scene starts but lights do not light up.

     

    DEBUG] 16:53:20: Scene started by clicking 'start' button

    • 0
    Posted

    Please try this:

     

    Please login or register to see this code.

     

    • 0
    Posted

    I've tried the code and my Double Switch 2 only works when I press once (but it recognises it as pressed twice) or held down (but it recognises it as pressed once)...

    Any one has had similar situation?

    • 0
    Posted

    I am trying to implement your script, @petergebruers , to use S2 on the double switch to control one channel on the RGBW dimmer. Where you write "replace with scene/.."etc, I have no problem with these commands:

    For "pressed" I use

    Please login or register to see this code.

    or

    Please login or register to see this code.

    depending on the state of the device. For "2 times" I use

    Please login or register to see this code.

    I simply ignore "3 times". But what about "held down"? The only relevant action parameter for the RGBW dimmer seems to be setValue. Does that mean that on "held down" I should start a separate scene, which uses setValue to increase the output incrementally in a continuous loop until max, and then decreases it (with a small time delay for each step)? For "released", in this case, I would just kill the "held down" scene. Or it there a smarter way? The dimmer, after all, has its own built-in dimming response in the firmware. It seems strange to have to mimic it in a separate scene.

     

     

    • 0
    Posted

    I haven't used this myself but I'd give it a try: "startlevelincrease" works on dimmer-like-devices

     

     

    • Thanks 1
    • 0
    Posted

    Yes, I just found these two functions (startLevelIncrease and startLevelDecrease) by using 192.168.x.xx/api/devices?id=## and looking for actions on the RGBW dimmer unit. These failed to appear when I used the "HC2 Toolkit" program, right-clicking on the device and asking for actions. Here, only setValue, turnOn and turnOn appeared. Confusing! Thanks for clearing that up,@petergebruers . I will now start implementing these in my LUA scene, deciding first how to determine the dimmer direction (increase vs decrease). Initial thought: If the value is currently low (or off/0), I will increase; if it is high, I will decrease. 

    • 0
    Posted

    Having tested extensively, I have now succeeded in controlling the RGBW dimmer as planned. The startLevelIncrease does not work with these dimmers, it seems, as reported previously a few years ago:

    In stead, I adapted a code suggested by @ReneNL in this thread:

    For my LED strips I chose a dim time of 2 seconds in 10 % intervals, which works well with a single channel on an RGBW dimmer controlled by the Double Switch S2. 

    I attach my version of the scene, as it stands today (I may remove most fibaro:debug statements later):

     

     

     

     

    Please login or register to see this attachment.

    • 0
    Posted
    On 5/8/2019 at 6:30 PM, ogs said:

    I've tried the code and my Double Switch 2 only works when I press once (but it recognises it as pressed twice) or held down (but it recognises it as pressed once)...

    Any one has had similar situation?

    Set Parameter 20 on 0 (zero) = Momentary switch.

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...