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

[SOLVED]How to trigger a scene with 3 devices?


Question

Posted

Hello all,

My question is, how can i trigger a lua scene with 3 diferent values but the sum of 3 is the trigger value i need?

 

As i understand, the scenes are triggered when a device match a value we have in lua code, but how i can use 3 different values? The reason for this is beacuse i have 3 devices testing the Kw, i want to turn off a fourth device if the sum of the 3 testing devices match 3.000kw.

 

Thanks

11 answers to this question

Recommended Posts

  • 0
Posted (edited)

First of all the scene triggered when device reports on change (like ON/Off, breached/safe, power consumption changed and etc.) it does not triggered according to the value in Lua code!!!

In your case the scene should be triggered by all four devices. In lua code you should query the value of three devices and if the sum is 3KW then disconnect the fourth device.

I could provide initial template of the code, if you interested please share device ids and what exactly the syntax of thow to get device desired property, this is an important part to use correct trigger

For example:

fibaro:getValue(dID,"value")

fibaro:getValue(dID,"power")

fibaro:getValue(dID,"energy")

or any other property.

In addition it will be very helpful if you can provide device description.. like wall plug, relay switch...

 

 

Edited by cag014
  • 0
  • Inquirer
  • Posted

    First, thanks for answering,

     

    The 3 devices are 3 Heavy duty switches from Aeotec, the fourth will activate a fibaro single switch.

     

    Devices get the the value from power, so i supose where i have to work is the power value.

    Please login or register to see this code.

    As you can see, i dont have any trigger yet because i dont know how to trigger that scene.

     

    My apologies if im asking something stupid, im really new in lua code.

     

    Thanks again for your time.

    • 0
    Posted (edited)
    1 hour ago, Ultimattum said:

     

    Please login or register to see this code.

    Have added the devices under %% property.

    Please make sure to set as follow:

    Max running instances  to 8

    "Run scene:"  to Automatic.

    Please login or register to see this image.

    /monthly_2018_06/Capture.PNG.d645311857fbb06d15c6352c1b37101b.PNG" width="233" />

    May I suggest to use tonumber() function to make sure to get the power as a number. sometimes it could be represented as a string.

    In addition you have syntax error on first variable consumofase1. No such variable defined, please changed to powerconsum1

    You don't need to have extra variables, you could use fibaro:getValue() function directly... see below

    Please login or register to see this code.

    Let me know if it works for you...

    Edited by cag014
    • 0
  • Inquirer
  • Posted

    Amazing sir,

    Let me test and share the results with you.

     

    Thanks again for your time.

    • 0
  • Inquirer
  • Posted

    Hello @cag014 !

    Yesterday i could try the code you gave me and its working perfectly,

    Now i can control the fourth switch testing the poewer on the three power testers. I added a pop-up on the last test asking me if i want to Turn off the fourth switch, im really happy with the results.

     

    Thank you so much and sorry for answering so late.     

    • 0
    Posted

    You're welcome..

     

    • 0
    Posted (edited)
    On 6/17/2018 at 6:20 PM, Ultimattum said:

    Hello all,

    My question is, how can i trigger a lua scene with 3 diferent values but the sum of 3 is the trigger value i need?

     

    As i understand, the scenes are triggered when a device match a value we have in lua code, but how i can use 3 different values? The reason for this is beacuse i have 3 devices testing the Kw, i want to turn off a fourth device if the sum of the 3 testing devices match 3.000kw.

     

    Thanks

     

    Hi

     

    Many people create stuff without thinking of the eventual consequences.

     

     As a scene will trigger on a value change, it does sound like it could trigger scene very often if trigger scene on all three devices when power consumption changes. Depending on the power usage of your devices and its fluctuation, the scene could trigger very fast. Also... as you do not want to turn on a light bulb instantly I would probably skip a scene and go for a VD.

     

    I would *probably*, from what I have read from you,  instead use a VD with a controlled loop reading those three power values for example every 5, 10, 30 or 60s. And if sum of those exceeds 3kw I would exec what I need.  This will probably take a lot less resources from your HC2. A controlled "always on" scene loop would also work if it does not trigger on devices. Then it behaves like a VD.

     

    IF a scene triggering on all three devices works ok (like the initial though), it could at any time if power fluctuation is changing fast, eventually starts to eat resources so you will see HC2 problems.

     

    Or did I misunderstand something?

     

    Regards

    /Peo

    Edited by pos
    • 0
    Posted

    @pos

    First of all the entire purpose of HC2 is to respond to triggers, so I don't think it's "eating" your resources.

    In addition you can setup the device to send report when power consumption changes are over certain value or percentage, so not every small change will trigger the scene.

    Off course you can do it as you suggested, by loop in VD, but that defiantly will drive HC2 resources. 

    I don't know why  @Ultimattum  needs to turn off the fourth device, but lets assume that you measure entire house power consumption. In this case when it over maximum consumption the breaker could shutoff your home, so you need immediate  reaction to turn off some appliance to prevent power outage. When you run in loops it will be too late... so as you can see it necessary to use scene.

     

    • 0
  • Inquirer
  • Posted

    Hello @pos and @cag014 !

     

    The reason to turn off one of those 3 devices is to cut the power consumption of one, two or in the worst case the three phases.

     

    Recently my energy provider has installed me a new meter device which it stops himself when the power consumption exceeds 10kw, this device is located outside home, i have an AC which consumes at max power 3,3kw in one phase, a 5000kw induction plaque in other phase, and the rest of my devices are (including the HC2) on the third phase.

    My first objective was to know triggering this scene when i was overconsuming 3kw, then 6kw and finally 9kw where the hc2 will only advice me. Right now i connected every phase with a heavy duty meter (3, one for each phase) where the scene turns off each phase in order, one by one if the power consumption sum is >= 9000. When the scene has cut the power of the first two phases and the consumption still exceeding the 9kw the scene ask me if i want to cut the last heavy duty meter (the one which is conected the fibaro HC2).

     

    Here is the lua code for this purpose:

     

    Please login or register to see this code.

    Excuse me for the sentences in spanish the code is writted for my wife and me, and she doesnt understand english hehe. Feel free to correct or comment me the code.

     

    Thanks all for your replies.

     

    • 0
    Posted
    3 hours ago, cag014 said:

    @pos

    First of all the entire purpose of HC2 is to respond to triggers, so I don't think it's "eating" your resources.

     

    @cag014

    Well... When responding to triggers , start the scene and read devices or global variables etc each time, it will for sure eat resources. If you do it faster it will cost more. Trigger on a motion sensor that has a restore time of 30s cannot trigger more than once every 30s (breach, wait 30s, restore). That is not to often, well controlled and cannot go insane. Just a std TV+soundbar *constantly* change power consumption. My TV+soundbar constantly changes +-100W. A lot of devices do have power fluctuations (tv, soundbar,dimmers etc etc). And when you add several devices, its total will vary even more. So to undertand eventual consequences, you must know how much power needs to change for the trigger start scene. Also note this is x 3.  So when trigger on triple devices with power consumption is not easy to control the amount of triggers, i.e scene starts. And for every scene start you read several devices...

     

    Quote

    In addition you can setup the device to send report when power consumption changes are over certain value or percentage, so not every small change will trigger the scene.

     

    As you want to know the total of three, you don't have that good control when delaying reports per device. And as you said it yourself, (see what you write below) "it could be to late" if you do not trigger often enough...  But I agree on that is good setup thinking to think and use these reporting parameters correctly! That is important.

     

     

    Quote

    Off course you can do it as you suggested, by loop in VD, but that defiantly will drive HC2 resources. 

     

    It will not as you mostly wait and check stuff  not to often and in a controlled way. When I built the 

    Please login or register to see this link.

     I spent a lot of time handling resource issues. So I now have a resonable good understanding of what wont eat to much resources  and what is fast or slow to do.

     

     

    Quote

    I don't know why  @Ultimattum  needs to turn off the fourth device, but lets assume that you measure entire house power consumption. In this case when it over maximum consumption the breaker could shutoff your home, so you need immediate  reaction to turn off some appliance to prevent power outage. When you run in loops it will be too late... so as you can see it necessary to use scene.

     

     

    A loop could of course be quicker (i.e less sleeping). It is easy to make a VD loop like this to react quicker than using a scene as there is nothing to start/fork in the underlying OS. But check to often, it will eat unnecessary resources. Everything is a tradeoff... Then it is probably better to cut power a little bit earlier. But really... If it is really CRITICAL to cut power within a second or else...., I would NOT use a HC2 for the job. that is a bad idea to use such a consumer product for that.

     

     

    But anyway.. Now @Ultimattum has our different views of it. And if @Ultimattum ses no drawbacks with a scene and have low resource usage, it is stable over time. Well... Then all is good.  And as someone said in the forum: "If it's working it is not stupid" :)

     

     

    /Peo

     

     

    • 0
    Posted

    Absolutely agree with you

    2 hours ago, Ultimattum said:

    Hello @pos and @cag014 !

     

    Excuse me for the sentences in spanish the code is writted for my wife and me, and she doesnt understand english hehe. Feel free to correct or comment me the code.

     

    Thanks all for your replies.

     

    You can optimize your code by for .. do loop,  but it looks good and correct

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