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

CentralSceneEvent / getSourceTrigger


JWoofer

Question

I had a scene for turning on the lights by using GetSourceTrigger (Pressed, Pressed2, Pressed3 etc.) on the FGS-223.  This is offcourse not working anymore in HC3. I'm not so good with using LUA so I can't figure out how this work in HC3 LUA. Is there anyone that can give me a help by reating one example for LUA HC3? I have added the LUA script from HC2 as how it used to work. 

Please login or register to see this attachment.

Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • 17 minutes ago, Momos said:

    My triiger is like this:

     

    Please login or register to see this code.

    Granted this is for a Remotec Remote.  Maybe try change operator to anyValue ?

    And what syntax you have on the actions side?

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • So I finally got it to work but one action per Scene

     

    Scene 1

     

    {
      conditions = { {
          id = 740,
          isTrigger = true,
          operator = "==",
          property = "centralSceneEvent",
          type = "device",
          value = {
            keyAttribute = "Pressed2",
            keyId = 1
          }
        } },
      operator = "all"
    }
     
    Action
     
    fibaro.call(385'turnOn')
     
    Scene 2
     
    {
      conditions = { {
          id = 740,
          isTrigger = true,
          operator = "==",
          property = "centralSceneEvent",
          type = "device",
          value = {
            keyAttribute = "Pressed2",
            keyId = 2
          }
        } },
      operator = "all"
    }
     
    Action
     
    fibaro.call(385'turnOff')

    So now I need to get these in two scenes in one scene. Anyone? To be continued..... 
    Link to comment
    Share on other sites

    • 0

    you can combine them in a single scene with no problem.

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Just now, Momos said:

    you can combine them in a single scene with no problem.

     

     

    Can you show me how? I've tried but till now no luck. 

    Link to comment
    Share on other sites

    • 0

    just use the trigger i posted above and the action.  comment out everything below the "print" line and post here the debug after pressing buttons 1 and 2

    Edited by Momos
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I will try tomorrow. Thanks for your help and I will let you know when I have succeeded. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • With trail and error you can learn a lot. :-) I'm almost there but I can't get the script to respond to the Attribute value. Debug tells me that the attribute is correct but the if statement doesn't respond to it. 

     

     
    local value = sourceTrigger.value
    local trigger = sourceTrigger
     
    print("ID: "..trigger.id, "; Key: "..trigger.value.keyId, "; Attribute: "..trigger.value.keyAttribute )
     
    if value.keyId == 1 then
        elseif value.keyAttribute == "Pressed" then 
        fibaro.call(385'turnOn')    
    elseif value.keyId == 2 then
        fibaro.call(385'turnOn')
    end
     
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Got it.
     

    local value = sourceTrigger.value
    local trigger = sourceTrigger
     
    print("ID: "..trigger.id, "; Key: "..trigger.value.keyId, "; Attribute: "..trigger.value.keyAttribute )
     
    if value.keyId == 1 then
        if value.keyAttribute == "Pressed" then 
        fibaro.call(385'turnOff')
        end    
    elseif value.keyId == 2 then
        if value.keyAttribute == "Pressed2" then 
        fibaro.call(385'turnOn')
        end
    end
    Link to comment
    Share on other sites

    • 0
    On 6/26/2020 at 8:40 AM, JWoofer said:

    Got it.
     

    local value = sourceTrigger.value
    local trigger = sourceTrigger
     
    print("ID: "..trigger.id, "; Key: "..trigger.value.keyId, "; Attribute: "..trigger.value.keyAttribute )
     
    if value.keyId == 1 then
        if value.keyAttribute == "Pressed" then 
        fibaro.call(385'turnOff')
        end    
    elseif value.keyId == 2 then
        if value.keyAttribute == "Pressed2" then 
        fibaro.call(385'turnOn')
        end
    end

    Hi @JWoofer, I'm having another go at getting this working and working through the example.

     

    My condition/trigger is:

     

    {
        operator = "any",
        conditions = {
            {
                id = 600,
                isTrigger = true,
                operator = "anyValue",
                property = "centralSceneEvent",
                type = "device"
            }
     
    My actions are:
     
    local value = sourceTrigger.value
    local trigger = sourceTrigger
     
    print("ID: "..trigger.id, "; Key: "..trigger.value.keyId, "; Attribute: "..trigger.value.keyAttribute )
     
    if value.keyId == 1 then
        if value.keyAttribute == "Pressed" then 
        fibaro.call(588'turnOff')
        end    
    elseif value.keyId == 2 then
        if value.keyAttribute == "Pressed2" then 
        fibaro.call(588'turnOn')
        end
    end
     
    I get an error running the scene of:  attempt to index a nil value (field 'value')
     
    I just cannot work out the issue - what did you use to get this working in the end?
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • This is the working situation:

     

    Declaration

     

    {
      conditions = { {
          id = 585,
          isTrigger = true,
          operator = "!=",
          property = "centralSceneEvent",
          type = "device",
          value = {}
        } },
      operator = "all"
    }

     

    Action

     

    local value = sourceTrigger.value
    local trigger = sourceTrigger
     
    print("ID: "..trigger.id, "; Key: "..trigger.value.keyId, "; Attribute: "..trigger.value.keyAttribute )
     
    if value.keyId == 1 then
        if value.keyAttribute == "Pressed" then 
        fibaro.debug("Pressed 1""LED")
        fibaro.call(238'turnOff')
        fibaro.call(757'turnOff')
        elseif value.keyAttribute == "Pressed2" then
        fibaro.debug("Pressed 2""Kast")
        fibaro.call(244'turnOff')
        elseif value.keyAttribute == "Pressed3" then
        fibaro.debug("Pressed 2""Staand")
        fibaro.call(231'turnOff')
        elseif value.keyAttribute == "HeldDown" then
        fibaro.debug("HeldDown""Alles Uit")
        fibaro.call(223'turnOff')
        fibaro.call(225'turnOff')
        fibaro.call(226'turnOff')
        fibaro.call(227'turnOff')
        fibaro.call(231'turnOff')
        fibaro.call(238'turnOff')
        fibaro.call(244'turnOff')
        fibaro.call(317'turnOff')  
        fibaro.call(757'turnOff')
        end    
    elseif value.keyId == 2 then
        if value.keyAttribute == "Pressed" then 
        fibaro.debug("Pressed 1""LED")
        fibaro.call(238'turnOn')
        fibaro.call(238'setColor''110''110''110''110')
        fibaro.call(757'turnOn')
        fibaro.call(757"setColor"'110''110''110''110')
        elseif value.keyAttribute == "Pressed2" then
        fibaro.debug("Pressed 2""Kast")
        fibaro.call(244'turnOn')
        elseif value.keyAttribute == "Pressed3" then
        fibaro.debug("Pressed 2""Staand")
        fibaro.call(231'turnOn')
        elseif value.keyAttribute == "HeldDown" then
        fibaro.debug("HeldDown""Alles Aan")
        fibaro.call(223'turnOn')
        fibaro.call(225'turnOn')
        fibaro.call(226'turnOn')
        fibaro.call(238'turnOn')
        fibaro.call(238'setColor''110''110''110''110')
        fibaro.call(757'turnOn')
        fibaro.call(757"setColor"'110''110''110''110')
        end  
    end

     

    The message of attempt to index a nil value I also get but this is not important. You have to make sure to give the right ID in the declaration:

     

    Please login or register to see this attachment.

     

    Link to comment
    Share on other sites

    • 0

    Hi @JWoofer

     

    I had another look this morning and simplified the code for a remote which only works for single presses.

     

    I used the actions you suggested:

     

    {
      conditions = { {
          id = 602,
          isTrigger = true,
          operator = "!=",
          property = "centralSceneEvent",
          type = "device",
          value = {}
        } },
      operator = "all"
    }
     
    Then I simplified your code for a remote so the actions were:
     
    local trigger = sourceTrigger
     
    print("ID: "..trigger.id, "; Key: "..trigger.value.keyId, "; Attribute: "..trigger.value.keyAttribute )
     
    if value.keyId == 1 then 
        fibaro.debug("Pressed 1""MAIN LIGHT")
        fibaro.call(509'toggle')
    elseif value.keyId == 2 then 
        fibaro.debug("Pressed 2""LAMP 1")
        fibaro.call(590'toggle')  
    elseif value.keyId == 3 then 
        fibaro.debug("Pressed 2""LAMP 2")
        fibaro.call(594'toggle')
    elseif value.keyId == 4 then 
        fibaro.debug("Pressed 2""FIRE")
        fibaro.call(476'toggle')   
    end
     
    I don't know why I didn't try to simplify like this before but with your help I now have this working!
     
    Thank you for your help :) 
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • With working together we get it fixed for everyone. Well done.? 

    Link to comment
    Share on other sites

    • 0

    Gentlemen, thank you for your posts. Was very helpfull.


    @DonCW: Please add the local 'value' to your code (similar to JWoofer).


    In the beginning I only adopted the first 3 lines. (local and print)

    And in the debug window I always saw 'Pressed2' as the keyAttribute.

    Later it turned out that parameter 20 was on the default 'toggle switch' (device changes status).

    I changed this to the correct 0-momentary switch I have. And now I do get the correct keyAttribute values.

    Maybe you have the same switch problem, DonCW. 

     

    (For others: Don't forget to set parameter 28 & 29).

     

    Thanks again guys.

    Link to comment
    Share on other sites

    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...