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
  • The --FILE: directive has to start at the beginning of the line

    It seems like

     --FILE:EventRunner4Engine.lua,EventRunner;

    is  one space indented...? Because if so it is not included and you will not have any _debugFlags

    Link to comment
    Share on other sites

    9 minutes ago, jgab said:

    The --FILE: directive has to start at the beginning of the line

    It seems like

     --FILE:EventRunner4Engine.lua,EventRunner;

    is  one space indented...? Because if so it is not included and you will not have any _debugFlags

    if dofile and not hc3_emulator then
      hc3_emulator = {
        credentials = { ip = "12.10.79.127", user = "minsad79",  pwd = "12345" },
        name="ER4_simulator",
        type="com.fibaro.genericDevice",
        --startTime="10:00:00 5/12/2020",
        --speed = 48,
        id=1563,
        --deploy=true,
        --proxy=true,
        --offline=true,
        debug = {trigger=false},
        UI = {
          {label='ERname',text="..."},
          {button='debugTriggers', text='Triggers:ON'},
          {button='debugPost', text='Post:ON'},
          {button='debugRules', text='Rules:ON'},
          {{button='Update', text='Update'},{button='restart', text='restart'}}
        }
      }
      
        --dofile("fibaroapiHC3_classic.lua")

      dofile("fibaroapiHC3.lua")
       
       
    --FILE:EventRunner4Engine.lua,EventRunner;
    --FILE:Toolbox/Toolbox_basic.lua,Toolbox;
    --FILE:Toolbox/Toolbox_events.lua,Toolbox_events;
    --FILE:Toolbox/Toolbox_child.lua,Toolbox_child;
    --FILE:Toolbox/Toolbox_triggers.lua,Toolbox_triggers;
    --FILE:Toolbox/Toolbox_files.lua,Toolbox_files;
    --FILE:Toolbox/Toolbox_rpc.lua,Toolbox_rpc;
    --FILE:Toolbox/Toolbox_pubsub.lua,Toolbox_pubsub;
    --FILE:EventRunnerDoc.lua,EventRunnerDoc;
    --FILE:Toolbox/Toolbox_profiler.lua,Toolbox_profiler;
         
     end
     
     
    --[[
    hc3_emulator.backup{
      type="*",
      dir="E:/DS_Drive/EventRunner/HC3/Backup(HC3)",
      namer = function(struct,name)
       local type = hc3_emulator.file.isType(struct) -- Returns "QA" for QAs and "Scene" for Scenes
        name = name..os.date(" %c",struct.modified or struct.updated)
        name = ""..struct.id.."_"..name:gsub("[^%w]","_")
        return type,name
      end,
    }
    --]]

    ----------- Code -----------------------------------------------------------

    _debugFlags.trigger = false -- log incoming triggers
    _debugFlags.fcall=false     -- log fibaro.call
    _debugFlags.post = false    -- log internal posts
    _debugFlags.rule=false      -- log rules being invoked (true or false)
    _debugFlags.ruleTrue=true  -- log only rules that are true
    _debugFlags.pubsub=true    -- log only rules that are true
    ------------- Put your rules inside QuickApp:main() -------------------

    function QuickApp:main()    -- EventScript version
      local rule = function(...) return self:evalScript(...) end          -- old rule function
      self._UNHANDLED_EVENTS = true
      self:enableTriggerType({"device","global-variable","custom-event","profile","alarm","location"}) -- types of events we want
      --DOWNLOADSOURCE()
    HT = fibaro.getGlobalVariable("HT")
    HT = json.decode(HT) 
     

    Edited by minsad79
    Link to comment
    Share on other sites

    8 minutes ago, jgab said:

     

    jgab

    Question again

    er4, er-test

    I use two er, but

    The emulator startup syntax is the same

    Only the name is different

    er4 works normally

    er-test is an error

    is

    What is the problem?

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, minsad79 said:

    jgab

    Question again

    er4, er-test

    I use two er, but

    The emulator startup syntax is the same

    Only the name is different

    er4 works normally

    er-test is an error

    is

    What is the problem?

    QA name, or file name?

    What is the error?

    I load

    Please login or register to see this code.

    without problem

    Edited by jgab
    Link to comment
    Share on other sites

    4 minutes ago, jgab said:

    QA name, or file name?

    What is the error?

     name="ER4_TEST"

     

     name="EventRunner4"

     

    QA name

    The rest is the same

    EventRunner4 => No error

    ER4_TEST => error

    Below error

     

     

     

     

     

    [01.04.2021] [00:03:25] |[35mSYS  [0m|: HC3 SDK v0.200
    [01.04.2021] [00:03:25] |[35mSYS  [0m|: Created Event server at 79.10.79.3:6872
    [01.04.2021] [00:03:25] |[35mSYS  [0m|: Created Terminal server at 79.10.79.3:6972
    [01.04.2021] [00:03:25] |[34mLOG  [0m|: Polling HC3 for triggers every 1000ms
    fibaroapiHC3.lua:4252: [string "if dofile and not hc3_emulator then
    ..."]:58: attempt to index a nil value (global '_debugFlags') (coroutine: thread: 0x7f8764596678, socket: tcp{client}: 0x7f8764847428)
    stack traceback:
        [C]: in function 'error'
        fibaroapiHC3.lua:4252: in field 'loadQA'
        fibaroapiHC3.lua:8588: in upvalue 'startEmulator'
        fibaroapiHC3.lua:8612: in upvalue 'f'
        fibaroapiHC3.lua:3439: in method 'callback'
        fibaroapiHC3.lua:2570: in function <fibaroapiHC3.lua:2566>
        (...tail calls...)

    Edited by minsad79
    Link to comment
    Share on other sites

  • Topic Author
  • Add debug.files=true

    Please login or register to see this code.

     

    and make sure that it load Toolbox. That's where _debugFlags are defined.

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Another thing.

    The emulator needs to parse the header of the file and find if there is a 

    Please login or register to see this code.

    This means that the "if dofile ..." needs to start the line with no space before.

    ...and the 'end' needs to be on a single line with no space before. If you have any 'end' inside the header it needs to be indented at least one space.

    The regex I use to find the header is "if%s+dofile.-[\n\r]end"

    It looks like it misses the 'end' in the header and finds an 'end' later in the file - after the body (ex. _debugFlags)

    I will see if I can make the header matching better at reporting "errors".

    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • Btw what line is 4252 in your emulator file?

    Is it

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    20 minutes ago, jgab said:

    Another thing.

    The emulator needs to parse the header of the file and find if there is a 

    Please login or register to see this code.

    This means that the "if dofile ..." needs to start the line with no space before.

    ...and the 'end' needs to be on a single line with no space before. If you have any 'end' inside the header it needs to be indented at least one space.

    The regex I use to find the header is "if%s+dofile.-[\n\r]end"

    It looks like it misses the 'end' in the header and finds an 'end' later in the file - after the body (ex. _debugFlags)

    I will see if I can make the header matching better at reporting "errors".

     

     

     

     

    I think I found the error part with this advice.

    Multi er finally started working

    Always your advice is best

    Link to comment
    Share on other sites

  • Topic Author
  • Just now, minsad79 said:

     

     

     

     

    I think I found the error part with this advice.

    Multi er finally started working

    Always your advice is best

    So, requiring the 'end' to start the line may not be good and it's easy to make a mistake and not see it.

    I'm thinking of requiring  the last 'end' to be on the format


     

    Please login or register to see this code.

    I.e. requiring a '--hc3_emulator' after 'end' to signal that it's the correct end.

    • Like 1
    Link to comment
    Share on other sites

    • 2 weeks later...

    there is a temperature sensor in the implant. And sometimes it happens that the implant gets used tightly and does not send any data, although as if in z-wave it is ...
    I came up with an idea: make a rule -> if the data (temperature in this case) has not changed for 12 hours, then send a message such as ATTENTION ATTENTION

    jgab wrote me the following code:

    Util.defTriggerVar ("tempWatch")
    rule ("temp: value => tempWatch = false; tempWatch = true"). start ()
    rule ("trueFor (12:00, tempWatch) => log ('ALERT')")

    But this rule does not work ... I just received messages that the temperature has not changed for 12 hours ... I went to
     internal graph for this thermometer and I see that the data actually changed.

     

    my rules:

    temp_R1 = 1102 - temperature in the refrigerator-1
    temp_R2 = 1103 - temperature in the refrigerator-2

    --6.2) Sweep the temperature and the implant for the refrigerator-1 does not freeze
    Util.defTriggerVar ("tempWatch_R1")
    rule ("temp_R1: value => tempWatch_R1 = false; tempWatch_R1 = true"). start ()
    rule ("trueFor (12:00, tempWatch_R1) => teleg_x2: email = log ('CONTROL: the temperature in refrigerator-1 has not changed for 12 years, the implant' hangs melodiously")

    --6.3) Sweep the temperature and the implant for the refrigerator-2 does not freeze
    Util.defTriggerVar ("tempWatch_R2")
    rule ("temp_R2: value => tempWatch_R2 = false; tempWatch_R2 = true"). start ()
    rule ("trueFor (12:00, tempWatch_R2) => teleg_x2: email = log ('CONTROL: the temperature in refrigerator-2 has not changed for 12 years, the implant' hangs melodiously"
    )

     

    what am I doing wrong?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • 4 hours ago, fastvd said:

    there is a temperature sensor in the implant. And sometimes it happens that the implant gets used tightly and does not send any data, although as if in z-wave it is ...
    I came up with an idea: make a rule -> if the data (temperature in this case) has not changed for 12 hours, then send a message such as ATTENTION ATTENTION

    jgab wrote me the following code:

    Util.defTriggerVar ("tempWatch")
    rule ("temp: value => tempWatch = false; tempWatch = true"). start ()
    rule ("trueFor (12:00, tempWatch) => log ('ALERT')")

    But this rule does not work ... I just received messages that the temperature has not changed for 12 hours ... I went to
     internal graph for this thermometer and I see that the data actually changed.

     

    my rules:

    temp_R1 = 1102 - temperature in the refrigerator-1
    temp_R2 = 1103 - temperature in the refrigerator-2

    --6.2) Sweep the temperature and the implant for the refrigerator-1 does not freeze
    Util.defTriggerVar ("tempWatch_R1")
    rule ("temp_R1: value => tempWatch_R1 = false; tempWatch_R1 = true"). start ()
    rule ("trueFor (12:00, tempWatch_R1) => teleg_x2: email = log ('CONTROL: the temperature in refrigerator-1 has not changed for 12 years, the implant' hangs melodiously")

    --6.3) Sweep the temperature and the implant for the refrigerator-2 does not freeze
    Util.defTriggerVar ("tempWatch_R2")
    rule ("temp_R2: value => tempWatch_R2 = false; tempWatch_R2 = true"). start ()
    rule ("trueFor (12:00, tempWatch_R2) => teleg_x2: email = log ('CONTROL: the temperature in refrigerator-2 has not changed for 12 years, the implant' hangs melodiously"
    )

     

    what am I doing wrong?

     

     

    Change the rule to

    rule ("temp_R1: value => log('Temp_R1 changed value to %s',temp_R1: value); tempWatch_R1 = false; tempWatch_R1 = true"). start ()

    If you get  log that "Temp_R1 changed value to ..." and the rest of the rules haven't triggered then we get some clues.

    If you don't get a log then there is an issue with the trigger.

    If you do can there be an issue with the send email?

    Link to comment
    Share on other sites

    There are definitely no problems with mail, as it monitors many other processes in the ER through mail, or rather a telegram bot that works through mail.

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, fastvd said:

    There are definitely no problems with mail, as it monitors many other processes in the ER through mail, or rather a telegram bot that works through mail.

    Email from the HC3 or email from Telegram? The former is a bit on and off...

    Anyway, to debug the logic you should add the log statement to the rule as described in the previous post.

    If the ER rule logs that the value changes, and then it doesn't notify you after 12 hours there is a problem with the ER rule and lets discuss it.

    If not, the HC3 doesn't react on the changed value in the correct way.

     

    Another thought,. 12 hours is a long time. If you restart the QA in-between  the 12 hour period will be reset. The QA needs to run continuously for the 12 hour period to trigger.

    To get around that the rule that react on the change can store the value in a quickVar or fibaro global so it survives a restart.

    Link to comment
    Share on other sites

    On 4/15/2021 at 10:48 PM, jgab said:

    Email from the HC3 or email from Telegram? The former is a bit on and off...

    Anyway, to debug the logic you should add the log statement to the rule as described in the previous post.

    If the ER rule logs that the value changes, and then it doesn't notify you after 12 hours there is a problem with the ER rule and lets discuss it.

    If not, the HC3 doesn't react on the changed value in the correct way.

     

    Another thought,. 12 hours is a long time. If you restart the QA in-between  the 12 hour period will be reset. The QA needs to run continuously for the 12 hour period to trigger.

    To get around that the rule that react on the change can store the value in a quickVar or fibaro global so it survives a restart.

    you didn't understand me..it's not that the data didn't really change, but the rule didn't tell us ... just the opposite: the data changed, it's visible on the graph, but why did the rule say that the temperature didn't change ...
    I use telegram through a bot which is described in this link ... but once again: here a problem not in mail and the telegram .... I see logging.

    Please login or register to see this link.

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, fastvd said:

    you didn't understand me..it's not that the data didn't really change, but the rule didn't tell us ... just the opposite: the data changed, it's visible on the graph, but why did the rule say that the temperature didn't change ...
    I use telegram through a bot which is described in this link ... but once again: here a problem not in mail and the telegram .... I see logging.

    Please login or register to see this link.

    Ok, so if you have modified the rule to

    Please login or register to see this code.

    You would get a log "Temp_R1 changed"... when the value changes. If the other rule doesn't fire after 12hours it a problem with that rule. If it fires and logs "'CONTROL: the temperature ... " we know there is a problem with the email.

    Please login or register to see this code.

    Looking at this rule again, there are some problem with it - it is not terminated correctly (you are mixing up single and double quotes)

    It should look like

    Please login or register to see this code.

    ...that could explain your issues.

    Link to comment
    Share on other sites

    Jan,

    What is the correct notation for:

    Please login or register to see this code.

    Thanks in advance,

    //Sjakie

    Link to comment
    Share on other sites

    On 17.04.2021 at 17:51, jgab said:

    Итак, если вы изменили правило на

    Please login or register to see this code.

    Вы получите журнал «Temp_R1 changed» ... когда значение изменится. Если другое правило не срабатывает через 12 часов, проблема с этим правилом. Если он срабатывает и регистрирует «КОНТРОЛЬ: температура ...», мы знаем, что возникла проблема с электронной почтой.

    Please login or register to see this code.

    Еще раз посмотрев на это правило, вы обнаружите некоторую проблему - оно не завершается правильно (вы смешиваете одинарные и двойные кавычки)

    Это должно выглядеть так

    Please login or register to see this code.

    ... это могло бы объяснить ваши проблемы.

    did not understand where I confuse quotes?

    Link to comment
    Share on other sites

  • Topic Author
  • On 4/14/2021 at 5:25 PM, fastvd said:

    rule ("trueFor (12:00, tempWatch_R1) => teleg_x2: email = log ('CONTROL: the temperature in refrigerator-1 has not changed for 12 years, the implant' hangs melodiously")

    If you look at this rule you gave, it ends in a double quote.

    Please login or register to see this code.

    But its part of a 

    Please login or register to see this code.

    so it should end in

    Please login or register to see this code.

    and remove the single quote in

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Jan,

    This combination of rules doest work properly. Curtain closes immeadiatly after start to open

    I need to add 30 seconds for open the curtain. Is this correct?

    How to adapt month in dates  ('04/14-10/31') or (04/10-10/31)

    Please login or register to see this code.

    What is the correct notation for:

    Please login or register to see this code.

     

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