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

automatic motion detection scenario = switch on light bulb


kalypso44

Question

Good morning,

 

Sorry for my English, I use google translate.

 

I'm trying to create an automatic scenario, but I can't manage it?

 

The idea:

Detecting a movement with the FGMS-001 which causes the FGS-214 bulb in my scullery to light up.

I manage to program this scenario:


When the FGMS-001 detects movement, the bulb lights up. But I would like the bulb to stay on for a while and then turn off. Or it turns off when the detector no longer detects movement. And then I'm stuck!?

 

So I converted the script to LUA, but since I don't know anything about this type of language, I ask ChatGPT to help me...

 

But you ? How would you do?
Can you help me ?
What would you need?

 

Thanks,

 

/////////// code LUA ///////////////

 

DÉCLARATIONS (Conditions/Déclencheurs)

{
  état = { {
      identifiant =  70 ,
      estDéclencheur =  vrai ,
      opérateur =  "==" ,
      propriété =  "valeur" ,
      noté =  "périphérique" ,
      valeur =  vrai
    } },
  opérateur =  "tout"
}
 
ACTIONS
hub.call( 64 'turnOn' )
 

 

 

Edited by kalypso44
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • What ChatGPT offers me

     

    {
      conditions = {
        {
          id = 70,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = true
        }
      },
      operator = "all",
      actions = {
        {
          action = "lua",
          code = [[
            local motionSensorId = 70  -- ID du détecteur de mouvement
            local lightId = 71  -- ID de l'ampoule

            if (fibaro:getValue(motionSensorId, "value") == "1") then
                fibaro:call(lightId, "turnOn")
            else
                fibaro:call(lightId, "turnOff")
            end
          ]]
        }
      }
    }
     

    the bulb lights up when the detector detects movement, but it does not turn off when it no longer detects movement?

    Edited by kalypso44
    Link to comment
    Share on other sites

    • 0

     

    You need two scenes.
    One for Turning on the light, and the other to turn it off after a certain time has elapsed without motion, or turn it off directly after some time, regardless of motion.


    It is very easy by block scenes..
     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    This question has been asked a few times, I suggest searching the forum for some answers.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  •  

    Eureka ;-)
     

    I've found !
    So for those who are facing the problem, here is a solution:

     

    The idea:
    That the bulb lights up when there is a presence at night, and that it goes out when there is no movement.

    Creation of two scenarios:

     

    vn8l.jpg

     

    gobn.jpg

     

    98g0.jpg

     

    Now it's 2 scenarios that run continuously.
    I tell myself that 2 scenario is RAM taken. Perhaps we could consider merging the two scenarios into one.

    I am neither a coder nor an LUA analyzer, but I will try my luck with ChatGPT 3.5 just to see...

    Edited by kalypso44
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Here below is the LUA code that ChatGPT3.5 offers me for merging the 2 scenarios above, but without the luminosity condition.

    In order to verify that the scenario works in broad daylight.

     

    But does not work: the light does not turn on!

     

    DÉCLARATIONS (Conditions/Déclencheurs)

    --[[
        Scénario : Détection mouvement cellier cuisine
        Description : Allume l'ampoule lorsque le détecteur de mouvement capte un mouvement, l'éteint lorsque le mouvement cesse.
    --]]

    --[[ DECLARATIONS (Conditions/Triggers) ]]--
    {
      conditions = {
        {
          id = 70,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = true
        }
      },
      operator = "all",
      customProperties = {
        scriptLabel = {
          value = "Détection mouvement cellier cuisine"
        }
      }
    },

    {
      conditions = {
        {
          id = 70,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = false
        }
      },
      operator = "all",
      customProperties = {
        scriptLabel = {
          value = "Détection mouvement cellier cuisine"
        }
      }
    }


    ACTIONS

    --[[ ACTIONS ]]--
    {
      timestamp = os.time(),
      type = "com.fibaro.scenario.actions.callAction",
      properties = {
        action = "turnOn",
        deviceID = 64 -- ID de l'ampoule
      }
    },

    {
      timestamp = os.time(),
      type = "com.fibaro.scenario.actions.callAction",
      properties = {
        action = "turnOff",
        deviceID = 64 -- ID de l'ampoule
      }
    }

    Link to comment
    Share on other sites

    • 0

    If you are looking for some Lua code, you could also search this forum, in stead of trying to get ChatGPT code working. There are a lot of examples on the forum, I don’t understand why hassle with ChatGPT and asking others to get it working. 

    • Like 1
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thank you, The forum could have been better structured since then, with examples of LUA code placed by theme...

    There, I arrive in a room, there's plenty of cardboard, I have my answer on a sheet in a cardboard box....But which one?

    Suddenly I seek, and do not find, so I ask the question...To hear say seek...But I expected it!

     

     

    Edited by kalypso44
    Link to comment
    Share on other sites

    • 0

    The motion question in homeautomation is like the oil or tire question on a motor forum 🍿
     

    The block scenes like Neo suggested work fine. If you want to integrate it in one lua scene, there are working scenes on the forum, see for example this post:

     

     

     

    Link to comment
    Share on other sites

    • 0

    I hope there will soon be a mmwave sensor that works on the HC3. I don't think that is the case yet, but since I have 2 here in the living room that controls my lighting (with HA), any other solution with the current motion sensors feels like "just not functioning properly".

    Edited by ppeterr
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 12 hours ago, SmartHomeEddy said:

    La question du mouvement en domotique c'est comme la question de l'huile ou du pneu sur un forum automobile  🍿
     

    Les scènes de blocs comme Neo ont suggéré de bien fonctionner. Si vous souhaitez l'intégrer dans une scène lua, il y a des scènes de travail sur le forum, voir par exemple ce post :

     

     

     

    Thank you, that's a big help...Straight to the point I'll build on that!

    Edited by kalypso44
    Link to comment
    Share on other sites

    • 0

    Why not use direct association (device settings, tab associations), faster, and works when the controller (HC3) is down. Then you can use parameter 6 (Fibaro Motion Sensor) to turn off the light automatically after x minutes of no motion detected. With parameter 9 you set with which lux level the lights need to turn on.

    • Thanks 1
    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...