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

  • Topic Author
  • Posted (edited)

    I have pushed v1.14 (skipped 1.13 ;-) ). EventRunner.lua and EventRunnerDebug.lua

     

    No new features but hopefully it will improve the stability:

     

    - @jompa68 and myself have had problems with strange characters entering the code when cutting & pasting code from the forum to our scenes. Now, Rule.eval and when events are sent to ZBS (from node-red etc), the text will be checked for invalid characters and an error will be thrown. This is a partial solution because it will only work with the text in rules, not the Lua code in general (I guess one could run it over the whole scene code but it's kind of expensive - maybe a tool or or a task for the supervisor?). The test can be turned off by setting _VALIDATECHARS=false

     

    -A new logic that tries to prevent an EventRunner scene to accidentally be started twice manually.

     

    -Handling crashed scenes more gracefully. Instead of just piling up incoming triggers (instances of the scene waiting to post the trigger to the main instance), incoming triggers will try for 5 seconds and then give up and give an error message in the log. This will give less load on the HC2 if the scene crashes (problem to have 10 instances looping forever not being able to post their triggers....)

     

    I have tested it on my scenes and it seems to work. Let me know if you have any problems.

    Edited by jgab
    Posted

    @jgab

    still struggling with the error line, can you see why? When i add stuff after mynodered it fails. 

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    3 minutes ago, jompa68 said:

    @jgab

    still struggling with the error line, can you see why? When i add stuff after mynodered it fails. 

     

    Please login or register to see this code.

     

    Can you give me the original rule?

    Posted

    Please login or register to see this code.

     

  • Topic Author
  • Posted

    Ok, I took out your _myNodeRed token, and it contains that little "red dot" between the last "e" and "d". I couldn't find an example of that when I wrote my validateChars test, but now I have one :-) 

    Please login or register to see this code.

    You expect this to print the letters in the name but we get:

    Please login or register to see this code.

    239,187,191 isn't even a valid multibyte character what I understand (maybe some strange charset...)

    Anyway, rewrite that variable and I guess it should work (what happened was that my script compiler read it as two separate tokens "_myNodeRe" and "d")

    I also have a "faulty" string to test my validateChars routine against - thanks!

  • Topic Author
  • Posted
    9 minutes ago, jgab said:

    I also have a "faulty" string to test my validateChars routine against - thanks!

     

    v1.14, fix1 gives an error for strange multi-byte char. Do you use any other editor than ZBS? or is it the editor in the forum that insert these chars?

  • Topic Author
  • Posted (edited)
    30 minutes ago, jgab said:

     

    v1.14, fix1 gives an error for strange multi-byte char. Do you use any other editor than ZBS? or is it the editor in the forum that insert these chars?

    So, I learn something every day. xEF,xBB,xBF is also know as a "BOM", byte-order mark. It's used mainly on Windows platforms in the beginning of files to signal stuff like multi-byte encoding...

    Please login or register to see this link.

    So, I guess you run on PC? How does it end up in the middle of your text?

     

    v14,fix2 also gives the character position of the "invisible" BOM character in a rule. In ZBS it isn't visible which gives a lot of problem. If I paste it back into a code section in a forum post, I get a "red dot" at the position of the BOM. If it ends in the Lua code it's even worse because you get compilation errors but it's impossible to see where the offending character is.

    Edited by jgab
    Posted
    1 hour ago, jgab said:

    v1.14, fix1 gives an error for strange multi-byte char. Do you use any other editor than ZBS? or is it the editor in the forum that insert these chars?

    No, only ZBS. But two versions, Mac and PC

    Posted
    1 hour ago, jgab said:

    239,187,191 isn't even a valid multibyte character what I understand (maybe some strange charset...)

     

    It is probably old "Mac OS Roman". It matches 239,187,191. I've received files from other users in this encoding. I'm not sure when you get this encoding on a MAC because the default has been UTF-8 for a while now.

     

    Please login or register to see this link.

     

    I have noticed this when I got files containing French words, encoding é as byte 0x8E

     

    In Go there is a decoder

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    41 minutes ago, petergebruers said:

     

    It is probably old "Mac OS Roman". It matches 239,187,191. I've received files from other users in this encoding. I'm not sure when you get this encoding on a MAC because the default has been UTF-8 for a while now.

     

    Please login or register to see this link.

     

    I have noticed this when I got files containing French words, encoding é as byte 0x8E

     

    In Go there is a decoder

     

    Please login or register to see this code.

     

    Either that or a BOM marker. It's a nuisance anyway. I throw an error if I detect it now. Silently ignoring it risks propagating it into more places...

    Posted
    2 minutes ago, jgab said:

    I throw an error if I detect it now.

    I understand. You can flag it as "non-UTF-8" and ask the user to fix the root cause of the problem...

    6 minutes ago, jgab said:

    Silently ignoring it risks propagating it into more places..

    Files in that old encoding will be ambiguous in many places anyway, for instance windows users receiving a file from a MAC user in that encoding. In my program I've made this an explicit configuration option, because I expect some day to get a file in yet another encoding (eg old windows codepage). But no auto detect, I guess that is impossible with those old 8 bit code pages :)

     

    Posted

    @jgab

    during day I have a few following errors with HUE:

    [DEBUG] 19:04:25: 2019-02-01 19:04:25.822648 [ fatal] LUA error: /opt/fibaro/scenes/217.lua:1900: Hue connection:"Bad file descriptor"

     

    it's in this part of ER:

    Please login or register to see this code.

    I had similiar problem in my code and it was (maybe) thanks to huge paralel calling and somehow mixed variables that are in header of function (i don't know lua in so detail)...

  • Topic Author
  • Posted (edited)

    If you are shooting a lot of requests to the bridge it may barf once in a while. There could be network hiccups or whatever...

    Maybe just silently ignore the errors? Comment out the line throwing the error?

     

    On my todo list is to have a requests to poll the whole state of the bridge - maybe that's more effective if you have a lot of devices you are polling.

    Edited by jgab
    Posted

    Yes, I do shooting :) as I want to have fresh info about pressing buttons from hue

    Hundreds of calling is OK but sometimes error with scene stoping

    I will try to comment error line.

    Thanks

  • Topic Author
  • Posted (edited)

    Pushed v1.14 fix4.

    added email support. Somehow this was never implemented and no one seems to have needed it. Guess that email is a bit old school...

    Please login or register to see this code.

    The email is a string with header and body separated with a ":". id is the user id.

    Edited by jgab
    Posted

    I have error in 1.14 fix4:

    EventRunnerDebug.lua:175: bad argument #2 to 'format' (no value)

     in row:

      message = string.format(message,table.unpack(args))
     

     

     

  • Topic Author
  • Posted (edited)
    14 minutes ago, petrkl12 said:

    I have error in 1.14 fix4:

    EventRunnerDebug.lua:175: bad argument #2 to 'format' (no value)

     in row:

      message = string.format(message,table.unpack(args))

     

    That means that somewhere a Log() or Debug() call has too few arguments. Do you have any idea what rule cause it? Do you have more of the error message? Is it reproducible offline?

    Edited by jgab
    Posted

    It's only in ZBS, in HC2 it's OK

     

    problem is in checkValidCharsInFile

     

    I'm going to send my file via pm

     

     

  • Topic Author
  • Posted (edited)
    On 2/2/2019 at 9:01 PM, petrkl12 said:

    It's only in ZBS, in HC2 it's OK

     

    problem is in checkValidCharsInFile

     

    I'm going to send my file via pm

     

    Ok, here is the deal.

     

    There is a new check when running offline (ZBS) that the file doesn't contain strange characters - especially BOM (\xEF\xBB\xBF), that have a tendency to sneak into the code when you copy and paste from the forum. It's really annoying characters as they are not visible in ZBS but both the Lua interpreter and my compiler get into trouble (and also on the HC2).

    When we start up on ZBS I check the file for BOM characters and log an error message if it is found (I don't break the execution, just log it). 

    That log message was faulty because if the offending line contained '%' characters they were interpreted as formatting directives and gave an error. 

    In your file you have a couple of invisible BOM characters - fortunately they are on commented out lines,

    Please login or register to see this code.

    (here it's just after the 100%)

     

    When I tried to print them out I caused an error. I have fixed that in the EventRunnerDebug.lua I just pushed.

    You will still get error warnings for the file. You can ignore it but I recommend trying to fix it - they have a tendency to get copied around. In some editors the BOM character is visible. In code blocks in forum posts they will show up as small red dots.

     

    Edited by jgab
    Posted

    Thanks. Corrected!

     

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