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


Recommended Posts

Posted
9 minutes ago, Neo Andersson said:

Okay, this is what i get from sepcialLed table

 

Please login or register to see this code.

 

evidently, dasyParts are replaced with some numbers

Okay, Jan

If i use the led table definition with ["morning"] key, then i get the proper special led table

Please login or register to see this code.

 

also the ledValues returns the proper table

Please login or register to see this code.

However, it doesn't find the specialLed[id].dayPart element

 
  • Topic Author
  • Posted (edited)

    if color is a table like [255,255,255,255]

    the call top setColor needs to unpack the table to separate arguments

    Please login or register to see this code.

    that is what. <ID>:color = {255,255,255,255}

    does...

    Edited by jgab
  • Topic Author
  • Posted
    22 minutes ago, Neo Andersson said:

    Okay, this is what i get from sepcialLed table

     

    Please login or register to see this code.

     

    evidently, dasyParts are replaced with some numbers

    Strange. I don't think it matters but change pair to pairs in

    Please login or register to see this code.

    Posted (edited)

    Jan, If I copy MY QA's all in one QA

    Please login or register to see this code.

    It saved with no problem and it is running parallel on my "Older" QA's

    The number of rules does't have a limit>>>hahahaa

     

    Edited by Sjakie
    Posted

    Why some rules reports twice and other just one time.

    Rules to be execute will run  twice if I proper remember

     

    Please login or register to see this attachment.

    Posted (edited)
    18 minutes ago, jgab said:

    Strange. I don't think it matters but change pair to pairs in

    Please login or register to see this code.

    Jan, it is not finidng the dayPart key

     

    It goes until ledValues needs to be defined in getProp function

     

    Please login or register to see this code.

    shouldn't it be set like 

    ledValues = ledValues.[dayPart] ?

    2 minutes ago, Neo Andersson said:

    Jan, it is not finidng the dayPart key

     

    It goes until ledValues needs to be defined in getProp function

     

    Please login or register to see this code.

    shouldn't it be set like 

    ledValues = ledValues.[dayPart] ?

    Okay changed it to ledValues = ledValues[dayPart], and now it doesn't complaint about No daypart morning for led 2778

    But led doesn't turn on with selected color and value

    Edited by Neo Andersson
    Posted
    4 minutes ago, Neo Andersson said:

    Jan, it is not finidng the dayPart key

     

    It goes until ledValues needs to be defined in getProp function

     

    Please login or register to see this code.

    shouldn't it be set like 

    ledValues = ledValues.[dayPart] ?

    Okay changed it to ledValues = ledValues[dayPart], and now it doesn't complaint about No daypart morning for led 2778

    But led doesn't turn on with selected color and value

    I use it like 

     

    Please login or register to see this code.

     

    is that the way to call it?
     
    Posted (edited)
    On 12/28/2023 at 8:29 AM, jgab said:

    Oops, this rule

    Please login or register to see this code.

    will set GasCounter to {} every time you restart ER... ;-)

    Well, just remove the rule...

     

    Hi Jan

     

    I still have issues with GasCounter - i got the first entry in global variable, but fails after that

     

    Please login or register to see this attachment.

     

    [01.01.2024] [14:13:56] [ERROR] [ER2136]: [Rule:5:1]>> [Rule:5:@14:13:55 => local gc = $GasCounter; local today = {date=osdate("%Y-%m-%d"), total=GAS_ID:value}; table.insert(gc,1,today); if size(gc) > 1 then today[1].daily = today.total - gc[2].total end; if si..] Runtime: table is 'nil' for array reference
         if size(gc) > 1 then today[1].daily = today.total - gc[2].total end;
                                      ^

     

    Please login or register to see this code.

     

    Edited by ChristianSogaard
    Typo
    Posted
    3 hours ago, jgab said:

    One could also patch the standard :on prop function, but then :on for a special led will always go through the table values.

    (same mapSpecialLed etc)

     

    Please login or register to see this code.

     

    @jgab

    Jan i trtied this, to patch, so i can use the regular:on for leds that are not in special group

    But throws an error

     

    Expr Runtime: ./include/engine.lua:37: attempt to index a number value (local 'id') prop
    White_led.id:on

    Posted
    31 minutes ago, Neo Andersson said:

    I use it like 

     

    Please login or register to see this code.

     

    is that the way to call it?
     

    Okay, all the problems was coming from missing table unpack for colors. / i was so used to that ER5 does this job for me

    Also, it seems that dayPart keys needs to be defined as ['morning'] = {color = etc...

    and not like morning = {color = etc..

    becuase calling them later in getProp function like ledValues.dayPart doesnt work..only when ledValues[dayPart] is used

    Posted (edited)
    22 minutes ago, Neo Andersson said:

    @jgab

    Jan i trtied this, to patch, so i can use the regular:on for leds that are not in special group

    But throws an error

     

    Expr Runtime: ./include/engine.lua:37: attempt to index a number value (local 'id') prop
    White_led.id:on

    OKay, i found the error in your function

    It should not use the same id for oldOn, we need to store the old, regular id of a device, that is not in a specialLed group..and use it when oldOn is called

     

    Please login or register to see this code.

     

    Edited by Neo Andersson
    Posted

    @jgab Jan, so far so good, but here is the essential problem..

    This works perfectly if i turn on the LED from a rule but if user turns on the LED manually, it doesnt follow the data apparently, because it is not linked to any event...

    I know, probably i can do

     

    rule("led.id:isOn => led:on") - (ofcourse with the patch , so ledOn is not needed )

     

    but this doesn't seem to make a sense..

     

    what is the workaround for this?

    Posted

    Happy Newyear great work jgab

    • Thanks 1
  • Topic Author
  • Posted
    2 hours ago, ChristianSogaard said:

     

    Hi Jan

     

    I still have issues with GasCounter - i got the first entry in global variable, but fails after that

     

    Please login or register to see this attachment.

     

    [01.01.2024] [14:13:56] [ERROR] [ER2136]: [Rule:5:1]>> [Rule:5:@14:13:55 => local gc = $GasCounter; local today = {date=osdate("%Y-%m-%d"), total=GAS_ID:value}; table.insert(gc,1,today); if size(gc) > 1 then today[1].daily = today.total - gc[2].total end; if si..] Runtime: table is 'nil' for array reference
         if size(gc) > 1 then today[1].daily = today.total - gc[2].total end;
                                      ^

     

    Please login or register to see this code.

     

    Should be

    Please login or register to see this code.

    • Like 1
    Posted

    @jgabJan, why is my AllHeltunButtons table nil, if i ceate it on the fly? 

    I want to populate my AllHeltunButtons table with all keys from BTD table.

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    2 hours ago, Neo Andersson said:

    @jgabJan, why is my AllHeltunButtons table nil, if i ceate it on the fly? 

    I want to populate my AllHeltunButtons table with all keys from BTD table.

     

    Please login or register to see this code.

     

    It's not nil when I try it. What does your keys and values look like in the table?

    4 hours ago, Neo Andersson said:

    @jgab Jan, so far so good, but here is the essential problem..

    This works perfectly if i turn on the LED from a rule but if user turns on the LED manually, it doesnt follow the data apparently, because it is not linked to any event...

    I know, probably i can do

     

    rule("led.id:isOn => led:on") - (ofcourse with the patch , so ledOn is not needed )

     

    but this doesn't seem to make a sense..

     

    what is the workaround for this?

     

    Is it a (physical) switch that directly turns on the leds?

    Then the only thing you can do is to adjust the color/value after it is turned on I guess...

    So, you need to trigger a rule when the leds comes on and then adjust the values.

    Be careful not to create a loop....

     

    Posted
    38 minutes ago, jgab said:

    Please login or register to see this code.

     

    Well i deleted the whole line, and rewrited again, now it works..probably somethin that i missed there. Just to be sure. Rule are run from topp to bottom right? So BTD table must be created before i use it in other rule right?

    40 minutes ago, jgab said:

    Is it a (physical) switch that directly turns on the leds?

    Then the only thing you can do is to adjust the color/value after it is turned on I guess...

    So, you need to trigger a rule when the leds comes on and then adjust the values.

    Be careful not to create a loop....

    Well ofcourse ther is a switch and they have the Yubii app too. So they can turn on LEDs from various sources.

    Tirggering a rule, and checking the value is the only solution i think..and not using your getProp function, becuase it is eventually calling the led turn on again.

    I think there is no risk to create a loop, at least i dont see where would I...

    Posted

    @jgab Jan i am having still some troubles withing for each loops in rules

     

    Please login or register to see this code.

     Expr Runtime: table is 'number' for array reference for k,v in pairs(RGBW_data) do k:color = k.$dayPart.color end ^

  • Topic Author
  • Posted (edited)
    1 hour ago, Neo Andersson said:

    Well i deleted the whole line, and rewrited again, now it works..probably somethin that i missed there. Just to be sure. Rule are run from topp to bottom right? So BTD table must be created before i use it in other rule right?

    Well ofcourse ther is a switch and they have the Yubii app too. So they can turn on LEDs from various sources.

    Tirggering a rule, and checking the value is the only solution i think..and not using your getProp function, becuase it is eventually calling the led turn on again.

    I think there is no risk to create a loop, at least i dont see where would I...

    Yes, rules are evaluated top to bottom.

     

    There is the :manual property that returns the number of seconds since the device was last changed from outside ER5.

    It can be used to tell the difference if a device is turned on by the 

    39 minutes ago, Neo Andersson said:

    @jgab Jan i am having still some troubles withing for each loops in rules

     

    Please login or register to see this code.

     Expr Runtime: table is 'number' for array reference for k,v in pairs(RGBW_data) do k:color = k.$dayPart.color end ^

    $dayPart is a key so you use index [$dayPart], and you need the value part 'v'

    Please login or register to see this code.

    Edited by jgab
    Posted
    47 minutes ago, jgab said:

    Yes, rules are evaluated top to bottom.

     

    There is the :manual property that returns the number of seconds since the device was last changed from outside ER5.

    It can be used to tell the difference if a device is turned on by the 

    $dayPart is a key so you use index [$dayPart], and you indeed the value part 'v'

    Please login or register to see this code.

    @jgab

    Jan, after several hours of hair tearing, i have found, why the brightness control doesnt work.

    I am showing here a simplified version of my rule, but the logic is the same

    This rule is intended to check after LED turn on, if its value is not by accident on 0, and if so, it should set some brightness to it.

    Please login or register to see this code.

     

    However, this will always run..because when led1 gets ON in the rule right side its value will be still 0, no matter what i do...I could add there a wait statement, jsut to give it some time, but it doesn't matter. led1 value is always 0 after its turned on. So this is impossible.

    I have checked in other QA with a simple hub.getValue(led1, "value") and it returned the correct non zero value.

     

    So this evetually crosses all my efforts to somehow check on the leds value when it gets turned on. 

     

    Join the conversation

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

    Guest
    Reply to this topic...

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