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

Jan, okay reads much better!

Thanks,

//Sjakie

Posted
7 hours ago, jgab said:

 

Pushed 0.5,"fix5"

Sorry, log was broken and didn't return the string it printed, so :msg got nil as value. 

Restart should update the QA.

_HC3IPADDRESS is not needed and set automatically now.

 

The Rules: ON I have to look at later.

 

Thank you.

I also have &nbsp in the space of the message.

Thank you for your hard work.

  • Topic Author
  • Posted

    Ok, new version 0.5fix6

     

    log should work now. The string that log returns doesn't contain html ( ) but it is inserted in what is written to the HC3 console if self._HTML is true (default).

     

    All QuickApp functions are available inside rules using the pre-defined variable 'QA'.

    So rule("@sunset => QA:debug('Morning!')") works.

    It means that QA:error, QA:warning, QA:trace, QA:debug can be used to get different types of log messages. There is also a QA:tracef, QA:debugf etc that takes a formatting string. 'log' is the same as 'QA:tracef'

     

    There is also a new function for rules. print(tag, color, fmt, ....)

    It will do a self:tracef using the tag and color.

    Please login or register to see this code.

    This will print (if the QA id is 1359)

    Please login or register to see this code.

    But the text is yellow. This means that we can create logs for important messages that we can filter in the console better.

    Note, print needs at least 3 arguments, but tag and color can be nil and then uses default.

     

     

     

    Posted (edited)
    47 minutes ago, jgab said:

    Ok, new version 0.5fix6

     

    log should work now. The string that log returns doesn't contain html ( ) but it is inserted in what is written to the HC3 console if self._HTML is true (default).

     

    All QuickApp functions are available inside rules using the pre-defined variable 'QA'.

    So rule("@sunset => QA:debug('Morning!')") works.

    It means that QA:error, QA:warning, QA:trace, QA:debug can be used to get different types of log messages. There is also a QA:tracef, QA:debugf etc that takes a formatting string. 'log' is the same as 'QA:tracef'

     

    There is also a new function for rules. print(tag, color, fmt, ....)

    It will do a self:tracef using the tag and color.

    Please login or register to see this code.

    This will print (if the QA id is 1359)

    Please login or register to see this code.

    But the text is yellow. This means that we can create logs for important messages that we can filter in the console better.

    Note, print needs at least 3 arguments, but tag and color can be nil and then uses default.

     

     

     

     

    I applied it right away.(version 0.5fix6)
    The message is fine, but the message comes 3 times in a row.

     

    rule("kb.KidsBalconyLamp:isOn => 179:msg=log('kids Balcony Lamp On')")

    [2020-08-31] [15:08:47] [TRACE] [QUICKAPP447]: kids Balcony Lamp On
    [2020-08-31] [15:08:47] [DEBUG] [QUICKAPP447]: fibaro.call(179,"sendGlobalPushNotifications","kids Balcony Lamp On","false") => nil

    [2020-08-31] [15:08:48] [TRACE] [QUICKAPP447]: kids Balcony Lamp On
    [2020-08-31] [15:08:48] [DEBUG] [QUICKAPP447]: fibaro.call(179,"sendGlobalPushNotifications","kids Balcony Lamp On","false") => nil

    [2020-08-31] [15:08:51] [TRACE] [QUICKAPP447]: kids Balcony Lamp On
    [2020-08-31] [15:08:51] [DEBUG] [QUICKAPP447]: fibaro.call(179,"sendGlobalPushNotifications","kids Balcony Lamp On","false") => nil

     

     

    The rule below does not work.

     

    [2020-08-31] [15:00:06] [DEBUG] [QUICKAPP447]: [true]>>'Rule:32[kb.KidsBalconyLamp:isOn => QA:trace('kids balcony open')]'
    [2020-08-31] [15:00:06] [ERROR] [QUICKAPP447]: in Rule:32[kb.KidsBalconyLamp:isOn => QA:trace('kids balcony open')]: {"ERR":true,"src":"Rule:32[kb.KidsBalconyLamp:isOn => QA:trace('kids balcony open')]","msg":"Error executing instruction:'[\"%aref\",1,\"trace\"]'","err":".\/include\/EventRunner.lua:1601: attempting to index non table with key:'trace'"}

     


    Also, the print command does not work.
     

    rule("kb.KidsBalconyLamp:isOn => print("INFO"..self.id, "yellow", "This is a note")")

     

    [2020-08-31] [15:02:59] [DEBUG] [QUICKAPP447]: Setup: ER Nodered (0.5)
    [2020-08-31] [15:02:59] [ERROR] [QUICKAPP447]: QuickApp crashed
    [2020-08-31] [15:02:59] [ERROR] [QUICKAPP447]: main.lua:124: ')' expected near 'INFO'
    [2020-08-31] [15:03:00] [ERROR] [QUICKAPP447]: QuickApp crashed
    [2020-08-31] [15:03:00] [ERROR] [QUICKAPP447]: main.lua:124: ')' expected near 'INFO'

    Edited by Earybeongbeong7
  • Topic Author
  • Posted (edited)

    Pushed fix8. QA should work.

    The print example was wrong, It should look like

    Please login or register to see this code.

    There is no '..' string concatenation. Must use fmt('%s%s','abc','bcd').

    Then you need to use ' as string definition inside ".

    Of course you could create the tag with Lua outside the rule too

    Please login or register to see this code.

     

    Edited by jgab
    Posted
    24 minutes ago, jgab said:

    Pushed fix8. QA should work.

    The print example was wrong, It should look like

    Please login or register to see this code.

    There is no '..' string concatenation. Must use fmt('%s%s','abc','bcd').

    Then you need to use ' as string definition inside ".

     

    The others work, but the automation below does nothing.

     

    rule("kb.KidsBalconyLamp:isOn => print(fmt('INFO%s',QA.id), 'yellow', 'This is a note')")

    [2020-08-31] [16:22:42] [DEBUG] [QUICKAPP447]: Rule:32[kb.KidsBalconyLamp:isOn => print(fmt('INFO%s',QA.id), 'yellow', 'This is a note'...] = OK

     

    rule("print(fmt('INFO%s',QA.id), 'yellow', 'This is a note')")

    [2020-08-31] [16:27:11] [DEBUG] [QUICKAPP447]: print(fmt('INFO%s',QA.id), 'yellow', 'This is a note') = nil

  • Topic Author
  • Posted
    1 minute ago, Earybeongbeong7 said:

     

    The others work, but the automation below does nothing.

     

    rule("kb.KidsBalconyLamp:isOn => print(fmt('INFO%s',QA.id), 'yellow', 'This is a note')")

    [2020-08-31] [16:22:42] [DEBUG] [QUICKAPP447]: Rule:32[kb.KidsBalconyLamp:isOn => print(fmt('INFO%s',QA.id), 'yellow', 'This is a note'...] = OK

     

    rule("print(fmt('INFO%s',QA.id), 'yellow', 'This is a note')")

    [2020-08-31] [16:27:11] [DEBUG] [QUICKAPP447]: print(fmt('INFO%s',QA.id), 'yellow', 'This is a note') = nil

     

    It will log the message under the tag "INFO<QAid>". You may need to change the console tag pattern to see it. It usually only show "QUICKAPP<QAid>"

    Posted
    5 minutes ago, jgab said:

     

    It will log the message under the tag "INFO<QAid>". You may need to change the console tag pattern to see it. It usually only show "QUICKAPP<QAid>"

     


    Understand. Logging into another TAG.

     

    Thank you. :)

    Posted

    Jan, sorry this I dont understand where to do.

     

    It will log the message under the tag "INFO<QAid>". You may need to change the console tag pattern to see it. It usually only show "QUICKAPP<QAid>"

     

    //Sjakie

    Posted
    6 minutes ago, Sjakie said:

    Jan, sorry this I dont understand where to do.

     

    It will log the message under the tag "INFO<QAid>". You may need to change the console tag pattern to see it. It usually only show "QUICKAPP<QAid>"

     

    //Sjakie

     

     

    Please login or register to see this attachment.

    • Thanks 1
    Posted

    Thanks!

    Now I see yellow color too!!

    //Sjakie

    Posted

    Can you tell the difference between these two rules?

     

    rule("06:00..11:00-1 => post(#TOD{value='Morning'})").start()

     

    rule("06:00..11:00-1 => post(#TOD{value='Morning'})")

    Posted

    .start() will be checked when scene start if I proper understand

    and executed

     

    if scene is saved after 06:00

  • Topic Author
  • Posted
    2 minutes ago, Earybeongbeong7 said:

    Can you tell the difference between these two rules?

     

    rule("06:00..11:00-1 => post(#TOD{value='Morning'})").start()

     

    rule("06:00..11:00-1 => post(#TOD{value='Morning'})")

     

    I would not recommend to use X..Y as a rule trigger. 

    An X..Y rule is usually used as an extra condition but will also cause a trigger at time X and at time Y+1 to check the condition.

    A morning rule is usually triggered by an event, like someone entering the kitchen, or a decided time like sunrise.

    In your example it will always trigger at 06:00 and post the TOD.

    One exception. The rule command returns the "rule object" that has a couple of commands available. 

    .enable() that enables a rule (default)

    .disable() that disables a rule.

    .start() that runs the rule when it is defined.

    So in your case, the first rule will run when you restart the QA and if it's between 6-11 it will post the TOD.

    To be more clear I would write the rule like, to show that we have to do with a time rule.

    rule("@06:00 & 06:00..11:00-1 => post(#TOD{value='Morning'})").start()

    ...but it's a matter of taste.

    Posted
    17 minutes ago, jgab said:

     

    I would not recommend to use X..Y as a rule trigger. 

    An X..Y rule is usually used as an extra condition but will also cause a trigger at time X and at time Y+1 to check the condition.

    A morning rule is usually triggered by an event, like someone entering the kitchen, or a decided time like sunrise.

    In your example it will always trigger at 06:00 and post the TOD.

    One exception. The rule command returns the "rule object" that has a couple of commands available. 

    .enable() that enables a rule (default)

    .disable() that disables a rule.

    .start() that runs the rule when it is defined.

    So in your case, the first rule will run when you restart the QA and if it's between 6-11 it will post the TOD.

    To be more clear I would write the rule like, to show that we have to do with a time rule.

    rule("@06:00 & 06:00..11:00-1 => post(#TOD{value='Morning'})").start()

    ...but it's a matter of taste.

     

    Thank you. :)

  • Topic Author
  • Posted

    I'm not using the HC3 for alarms currently, but this could be one way to use it.

    Set up alarm zones (partitions) with the UI.

    Please login or register to see this code.

    The 'alarmPartitionsSafe' functions looks through the devices and post an 'ok' event if all devices are safe, otherwise post an 'not ok' event

    The 'partitions' argument can either be nil meaning all partitions or a table of the partitions that should be checked.

     

    The switch:on rule calls the alarmPartitionsSafe function and it will generate events of type #alarmCheck that we have rules for.

    The first says that everything is ok and we go ahead and arm the house.

    The second rule triggers if any device was unsafe and sends a message to close the device in question.

    The code could of course be improved and adapted to specific circumstances.

     

    The 'tag' argument is so that we can have many switches or rules for arming different parts of the house. The 'tag' allow us to tell the #alarmCheck rules apart.

    Posted
    1 hour ago, jgab said:

     

    I would not recommend to use X..Y as a rule trigger. 

    An X..Y rule is usually used as an extra condition but will also cause a trigger at time X and at time Y+1 to check the condition.

    A morning rule is usually triggered by an event, like someone entering the kitchen, or a decided time like sunrise.

    In your example it will always trigger at 06:00 and post the TOD.

    One exception. The rule command returns the "rule object" that has a couple of commands available. 

    .enable() that enables a rule (default)

    .disable() that disables a rule.

    .start() that runs the rule when it is defined.

    So in your case, the first rule will run when you restart the QA and if it's between 6-11 it will post the TOD.

    To be more clear I would write the rule like, to show that we have to do with a time rule.

    rule("@06:00 & 06:00..11:00-1 => post(#TOD{value='Morning'})").start()

    ...but it's a matter of taste.

     

    rule("@06:00 & 06:00..11:00-1 => post(#TOD{value='Morning'})").start()

     


    What does this mean here?

     

    11:00-1

     

     

  • Topic Author
  • Posted
    2 minutes ago, Earybeongbeong7 said:

    rule("@06:00 & 06:00..11:00-1 => post(#TOD{value='Morning'})").start()
    What does this mean here?

    11:00-1

    It means 10:59:59. (11:00 minus 1s)

    Probably because you have another rule that wants to catch the interval 11:00..

    Ex.

    Please login or register to see this code.

    It makes the rules mutually exclusive.

    If 11:00 been both the end interval of the first and the start interval of the second rule, then if the sensor is breached exactly 11:00 both rules would trigger.

    The rules are executed in the order they are defined and every rule that match.

    There is a way to break that...

    Please login or register to see this code.

    will log 'A' and then 'B' because both rules matches.

    However if we do

    Please login or register to see this code.

    It will only log 'A'. The second rule will not run even though it matches.

    By returning the magic constant QA.EM.BREAK it will stop matching rules that follow. Sometimes that can be useful...

     

     

    Posted
    13 minutes ago, jgab said:

    It means 10:59:59. (11:00 minus 1s)

    Probably because you have another rule that wants to catch the interval 11:00..

    Ex.

    Please login or register to see this code.

    It makes the rules mutually exclusive.

    If 11:00 been both the end interval of the first and the start interval of the second rule, then if the sensor is breached exactly 11:00 both rules would trigger.

    The rules are executed in the order they are defined and every rule that match.

    There is a way to break that...

    Please login or register to see this code.

    will log 'A' and then 'B' because both rules matches.

    However if we do

    Please login or register to see this code.

    It will only log 'A'. The second rule will not run even though it matches.

    By returning the magic constant QA.EM.BREAK it will stop matching rules that follow. Sometimes that can be useful...

     

     

     

    Thank you. :)

     

    Posted

    Jan ,

    I am lost in HUE land and I know its not your priority but I hope you can push me in the right direction. If I canrt solve this I am obliged to stay on HC2.

    Toilet scene works with Hue light triggered by 

    openVanBuitenDeurToilet==true => toilet.spotToilet:on; 
    but sometimes it skip!

    Please login or register to see this attachment.

     
    Debug shows light on but wife calls No light!
    In my app I see light goes on/off if its true
    HUE bridge rebooted
    HC2 I never noticed this behaviour
    Please advice?
    //Sjakie

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