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

Jan,

its my stupidity but no error message and no execution!

Rule.eval([[@17:20 => post(#lichtAan,+/00:00:05); post(#lichtUit,+/00:00:10)
    log('post licht - aan - uit')]])

I forgot a semi colon behind the 2nd post

 

//Sjakie

Link to comment
Share on other sites

2 godziny temu, jgab napisał:

This is fun

Please login or register to see this code.

When the first rule triggers is turns on swiatlokuchnia1

Then when the second rule is tried, swiatlokuchnia1 is on...

 

2 ways around this

Please login or register to see this code.

because || >> is. like if-then-elseif-then-... it will only run the rule that matches

 

Other approach is to add a break at the end of the first rule. A break menas that it will not try any other rules that matches

Please login or register to see this code.

 

Once again, thank You very much ... as always, You are right and Your help is invaluable?

Link to comment
Share on other sites

  • Topic Author
  • Ok, I think this will work...

    Here is a shortcut that I have done on my iPhone.

    Please login or register to see this link.

     

    If you in settings->shortcuts has checked allow untrusted shortcuts it should be possible to click on the link from your iPhone and import the shortcut.

     

    When the shortcut is imported open it and edit it.

    First the URL, It should be:

    http://<Your HC3IP>/api/devices/<ER4 QA ID>/action/RECIEVE_EVENT

    Then open "Show more" and change the Authorization header to your own credentials. (base64 encoded)

     

    Then go down to Request body and open the 'args' items

    Open the next level, and then the next again (the 'ev' key)

    The last level says

    'type'     'test'

     

    When I click on the shortcut it sends an event to my ER4 QA that I can pick up easily

     

    rule("#test => lights:off")

     

    It only works when my iPhone is on the local network, but its is convenient way to talk to ER4 without needing to go through other services or QAs...

     

     

     

    Link to comment
    Share on other sites

    Jan,

    I dont see it but is there a way to see in the new app wich devices are armed?

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, Sjakie said:

    Jan,

    I dont see it but is there a way to see in the new app wich devices are armed?

    //Sjakie

    HC3 it's only zones that can be armed.

    Link to comment
    Share on other sites

    Jan,

    I only need to move arming into HC3 but before I think its smart to fix the telegram first to have a more relaiable data.

    Telegram I am able to send message from IPhone to HC3

    HC3 shows in debug "sorry I dont understand text msg"

    error says:

    [08.01.2021] [16:18:14] [ERROR] [QUICKAPP382]: Telegram error: 403, Forbidden: bot can't send messages to bots

     

    Whats the syntax to use in other QA?

     

    Thanks in advance,

     

    //Sjakie

     

    Link to comment
    Share on other sites

    Good morning Jan,

    I have 

    [13.01.2021] [08:40:07] [ERROR] [QUICKAPP798]: main() error:./include/EventRunner.lua:2198: Main() ERROR:./include/main.lua:703: attempt to index a nil value (global 'Event')

    in:

    function watchProperty(deviceIDs,property,threshold,interval)
        local values={}
        Event.schedule(interval,function()
            for _,id in ipairs(deviceIDs) do
              if id==nil then log(log.ERROR,"Nil in deviceID list"); break;  end
              local val = values[id] or 100000
              local newVal = tonumber(fibaro:getValue(id,property))
              if newVal==nil then log(log.ERROR,"deviceID %s don't have property %s",id,property) end
              if newVal and math.abs(newVal-val) >= threshold then
                values[id]=newVal
                Event.post({type='property', deviceID=id, propertyName=property, value=newVal})
              end
            end
          end)
      end
     
    Please advice,
    //Sjakie
    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, Sjakie said:

    Good morning Jan,

    I have 

    [13.01.2021] [08:40:07] [ERROR] [QUICKAPP798]: main() error:./include/EventRunner.lua:2198: Main() ERROR:./include/main.lua:703: attempt to index a nil value (global 'Event')

    in:

    function watchProperty(deviceIDs,property,threshold,interval)
        local values={}
        Event.schedule(interval,function()
            for _,id in ipairs(deviceIDs) do
              if id==nil then log(log.ERROR,"Nil in deviceID list"); break;  end
              local val = values[id] or 100000
              local newVal = tonumber(fibaro:getValue(id,property))
              if newVal==nil then log(log.ERROR,"deviceID %s don't have property %s",id,property) end
              if newVal and math.abs(newVal-val) >= threshold then
                values[id]=newVal
                Event.post({type='property', deviceID=id, propertyName=property, value=newVal})
              end
            end
          end)
      end
     
    Please advice,
    //Sjakie

    You can just remove it as it is not necessary in ER4

    On 1/8/2021 at 4:22 PM, Sjakie said:

    Jan,

    I only need to move arming into HC3 but before I think its smart to fix the telegram first to have a more relaiable data.

    Telegram I am able to send message from IPhone to HC3

    HC3 shows in debug "sorry I dont understand text msg"

    error says:

    [08.01.2021] [16:18:14] [ERROR] [QUICKAPP382]: Telegram error: 403, Forbidden: bot can't send messages to bots

     

    Whats the syntax to use in other QA?

     

    Thanks in advance,

     

    //Sjakie

     

    Sorry, I haven't worked with the telegram QA for 6+month... it's on my todo list to have a look at it but Im pretty busy at the moment

    Link to comment
    Share on other sites

    Jan,

    Thanks, no problem will wait till you have time.

    Thought so that you are busy the last days.

    I hope it goes well with you?

    Link to comment
    Share on other sites

    On 9/21/2020 at 5:49 AM, jgab said:

     

    Any value. This works:

    Please login or register to see this code.

     

    Hi @jgab

     

    I was looking for an EV4 example.

    My goal is to use Keyfob/matrix - where a tripple click select next Color in a list in Children of Hue activated Bulp.

    so eg. 

    list={red, yellow, blue, green} or a list of HUE, Saturation and Brightness for each Bulp.

    I learned to to the Keyfob/matrix trigger part already, so I dont need that. - 

    So a function for Pressed3 = {HUEID:color={255,0,0,138}} - but were is taking the next in the list ?

    Would you have time to support me again again ???

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    @jgab

    why this generate error in ZBS:

     rule("@{catch,03:15} => Util.checkForUpdates()")
     

    [16.01.2021] [23:12:36] [[31;1mERROR[0m]: Error in '@{catch,03:15} => Util.checkForUpdates()': EventRunner4Engine.lua:308: attempt to concatenate a nil value
    [16.01.2021] [23:12:36] [[31;1mERROR[0m]: main() error:EventRunner4Engine.lua:2198: Main() ERROR:EventRunner4Engine.lua:2056: EventRunner4Engine.lua:308: attempt to concatenate a nil value

     

    It looks that I have problems with rules with @ in ZBS ie.

    rule("@01:00 & @sunrise & month('nov-jan') => log('test')

     

    but in HC3 it works correctly.

    Edited by petrkl12
    Link to comment
    Share on other sites

  • Topic Author
  • 9 hours ago, petrkl12 said:

    @jgab

    why this generate error in ZBS:

     rule("@{catch,03:15} => Util.checkForUpdates()")
     

    [16.01.2021] [23:12:36] [[31;1mERROR[0m]: Error in '@{catch,03:15} => Util.checkForUpdates()': EventRunner4Engine.lua:308: attempt to concatenate a nil value
    [16.01.2021] [23:12:36] [[31;1mERROR[0m]: main() error:EventRunner4Engine.lua:2198: Main() ERROR:EventRunner4Engine.lua:2056: EventRunner4Engine.lua:308: attempt to concatenate a nil value

     

    It looks that I have problems with rules with @ in ZBS ie.

    rule("@01:00 & @sunrise & month('nov-jan') => log('test')

     

    but in HC3 it works correctly.

     

    What is printed if you do

    print(tostring({}))

    in ZBS? Plain editor buffer without fibaroapiHC3.lua.

     

    The problem is that I rely on tostring({}) returning something of the format

    ".... 0x......"

    which is true for all Lua's I have seen so far....

     

    What version of ZBS, what Lua interpreter, and what OS are you running on? and what version of fibaroapiHC3.lua?

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • 20 hours ago, ChristianSogaard said:

    Hi @jgab

     

    I was looking for an EV4 example.

    My goal is to use Keyfob/matrix - where a tripple click select next Color in a list in Children of Hue activated Bulp.

    so eg. 

    list={red, yellow, blue, green} or a list of HUE, Saturation and Brightness for each Bulp.

    I learned to to the Keyfob/matrix trigger part already, so I dont need that. - 

    So a function for Pressed3 = {HUEID:color={255,0,0,138}} - but were is taking the next in the list ?

    Would you have time to support me again again ???

    Please login or register to see this code.

     

     

    You need to keep a state of what is 'next' in your list

    You could make a list 'object' with this function

    Please login or register to see this code.

     

    every

    Please login or register to see this code.

    will return the next value in the list and wrap around

     

    • Like 1
    Link to comment
    Share on other sites

    1 hour ago, jgab said:

     

    What is printed if you do

    print(tostring({}))

    in ZBS? Plain editor buffer without fibaroapiHC3.lua.

     

    The problem is that I rely on tostring({}) returning something of the format

    ".... 0x......"

    which is true for all Lua's I have seen so far....

     

    What version of ZBS, what Lua interpreter, and what OS are you running on? and what version of fibaroapiHC3.lua?

    print(tostring({}))

    it returned:

    table: 007a9dd0

     

    ZBS: ZeroBrane Studio (1.90; MobDebug 0.706)

    Lua interpreter: Lua 5.3

    OS: Windows 10 Pro 20H2

    local FIBAROAPIHC3_VERSION = "0.152"
     

    Edited by petrkl12
    Link to comment
    Share on other sites

    In case of switching to lua interpreter:

    table: 0x001a9780

    In case of switching to lua 5.2 interpreter:

    table: 009904F0

    In case of switching to lua 5.3 interpreter:

    table: 00803e88

     

    It seems that it will work only in Lua interpreter ...

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, petrkl12 said:

    print(tostring({}))

    it returned:

    table: 007a9dd0

     

    ZBS: ZeroBrane Studio (1.90; MobDebug 0.706)

    Lua interpreter: Lua 5.3

    OS: Windows 10 Pro 20H2

    local FIBAROAPIHC3_VERSION = "0.152"
     

     

    Thanks. I have updated my "gensym" algorithm to work with that format too...

     

    I have pushed a new version of EventRunner4 (fix 0.43) that should work better.

    Also updated fibaroapiHC3.lua

    2 minutes ago, petrkl12 said:

    In case of switching to lua interpreter:

    table: 0x001a9780

    In case of switching to lua 5.2 interpreter:

    table: 009904F0

    In case of switching to lua 5.3 interpreter:

    table: 00803e88

     

    It seems that it will work only in Lua interpreter ...

    Yes, it seems to be a thing for Lua 5.2/3 in ZBS on Windows

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, petrkl12 said:

    Thanks. btw. what version of Lua is in HC3?

     

    5.3 in QAs and 5.2 in Scenes.

    • Thanks 1
    Link to comment
    Share on other sites

    @jgab

    I have error in HC3 in this rule:

      rule("#dimPrac{attr='Released',dim='$d'} => log('Dalkovy ovladac 8tl. v pracovne - konec - dlouhy stisk klavesy %s',d.keyID); d.ref=cancel(d.ref)")
     

    [17.01.2021] [10:17:38] [ERROR] [QUICKAPP515]: in Rule:14[#dimPrac{attr='Released',dim='$d'} => log('Dalkovy ovladac 8tl. v pracovne - kon...]: {"ERR":true,"err":".\/include\/Toolbox_events.lua:103: Bad timer reference:nil","msg":"Error executing instruction:'[\"cancel\",1]'","src":"Rule:14[#dimPrac{attr='Released',dim='$d'} => log('Dalkovy ovladac 8tl. v pracovne - kon...]"}[17.01.2021] [10:17:38] [DEBUG] [QUICKAPP515]: Incoming trigger:{"id":29,"old":35,"value":40,"type":"device","property":"value"}

    Link to comment
    Share on other sites

    7 minutes ago, petrkl12 said:

    @jgab

    I have error in HC3 in this rule:

      rule("#dimPrac{attr='Released',dim='$d'} => log('Dalkovy ovladac 8tl. v pracovne - konec - dlouhy stisk klavesy %s',d.keyID); d.ref=cancel(d.ref)")
     

    [17.01.2021] [10:17:38] [ERROR] [QUICKAPP515]: in Rule:14[#dimPrac{attr='Released',dim='$d'} => log('Dalkovy ovladac 8tl. v pracovne - kon...]: {"ERR":true,"err":".\/include\/Toolbox_events.lua:103: Bad timer reference:nil","msg":"Error executing instruction:'[\"cancel\",1]'","src":"Rule:14[#dimPrac{attr='Released',dim='$d'} => log('Dalkovy ovladac 8tl. v pracovne - kon...]"}[17.01.2021] [10:17:38] [DEBUG] [QUICKAPP515]: Incoming trigger:{"id":29,"old":35,"value":40,"type":"device","property":"value"}

     

    all rules that are connected:

    Please login or register to see this code.

     

    Edited by petrkl12
    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...