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 good news is that this version performs better than the old one - even with 1 mailbox. The reason is of course that the consumer is more aggressive than the old one that only read 4 events/s. This one will read as fast as possible when events come in and then back off to poll 4 times/s when idle (to keep the reaction speed to incoming events).

    With only 3 mailboxes it seems to be able to sustain a throughput of 100 events at 10 events/s - which also seems reasonable.

    Some more performance tests (cpu load) before I include it.

    The general rule of thumb seems to be that the heavier work the consumer is doing (lots of cpu heavy rules), the more advantage it is to add more mailboxes. For the average user however, 1 mailbox seems to be enough.

    Edited by jgab
    Link to comment
    Share on other sites

    @jgab

     

    Thanks for your detail analysis :-) Any improvements are welcome!

     

    Could you send me your latest version of experimental code?

    I will do my own test - different result will be probably thanks to my load of consumer...

    Today evening I will send you my scene via PM.

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, petrkl12 said:

    @jgab

     

    Thanks for your detail analysis :-) Any improvements are welcome!

     

    Could you send me your latest version of experimental code?

    I will do my own test - different result will be probably thanks to my load of consumer...

    Today evening I will send you my scene via PM.

    Here it is

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • Here is the latest experimental version with the best throughput so far.

    Please login or register to see this attachment.

     

    So, normally the ER framework can sustain 9 simultaneous trigger (arriving on the same millisecond). We always have one reserved instance for the main loop otherwise it would be 10 like any normal scene. However, an ER scene instance started by an incoming trigger tries to quickly send the trigger to the main loop, via a "mailbox" and then terminate, giving an opportunity for a new trigger to start a new instance. We can think of this as having a buffer of size 9 for incoming triggers. Or the "bandwidth" being 9...

     

    The main loop then polled the mailbox at the speed of 4 events/triggers per second. That meant we could have a throughput of 4 events/s and take burst of 9 simultaneous triggers. Longer periods of triggers arriving faster than every 250ms would build up a backlog and eventually exceed the max 10 instances allowed.

     

    This worked out well for most normal users... including myself.

     

    @petrkl12 have a lot of devices giving off a lot of events and he hit the dreaded max 10 instances limit in his scenes. His suggestion was to use multiple mailboxes so that incoming triggers have a better chance to be off-loaded from instances so they can terminate quicker. The other optimisation was to let the mainloop poll more often than 4/s when events arrives and then back off to 250ms when no events have been seen for a while.

    All this, together with some discussions back and forth, have improved the throughput significantly in the experimental code included.

    It can still only take 9 exact simultaneous triggers ,that's what the HC2 limits us to. However, the throughput is much better with sustainable trigger streams of 1 trigger every ~45ms when using 30 mailboxes. Burst of 10-20 triggers at speed of 15-20ms/trigger is also handled, which probably will have more practical importance.

     

    Already at 3 mailboxes a much better performance is seen.

    This improvement (thanks to @petrkl12)  will be included in the next release and the default will be 3 (autogenerated) mailboxes. In the past the mailbox names was "MAILBOX"..__fibaroSceneId, but now it will be  "MAILBOX"..__fibaroSceneId.."_"..boxID, ex "MAILBOX14_1"

     

    I'm surprised how powerful the HC2 really is :-) 

    • Thanks 1
    Link to comment
    Share on other sites

    Thanks!

    Your framework is really best one and my recommendation is that other HC2 user should use it!

     

    • Like 1
    Link to comment
    Share on other sites

    @jgab not everyday i have this error, can you see what is causing it?

     

    Please login or register to see this code.

    rule

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 24 minutes ago, jompa68 said:

    @jgab not everyday i have this error, can you see what is causing it?

     

    Please login or register to see this code.

    rule

    Please login or register to see this code.

     

    Nothing obviously strange with that rule. Could you PM me with the src lines around 1308 and 1235 in your scene?

    Link to comment
    Share on other sites

  • Topic Author
  • New version v.1.15. Update EventRunner.lua and EventRunnerDebug.lua.

    New trigger handler as discussed in previous posts. If you experience that the scene exceeds 10 instances you may increase the variable _NUMBEROFBOXES in the beginning of the scene to possibly improve the performance. Default is 1 mailbox and it will behave more or less as before. At 3 you get a bit better performance for shorter trigger bursts, and we have tested it up to 30 mailboxes that gives quite good throughput.

    The trade-off is that more mailboxes will require a bit more cpu load when "idle", because there are more mailboxes to look through. At 30 mailboxes I get around 10% cpu at idle. At 1 mailbox it behaves as before with very low idle cpu.

    The other behaviour that is different is that when triggers are coming in the cpu will spike a bit more as the new algorithm is more aggressive reading triggers - however it will throttle back when no triggers are available. This is just to better avoid hitting the "max 10 instances" for the scene and is in general a sensible trade-off.

    So, rule of thumb. Keep _NUMBEROFBOXES at1 and if you experience more than 10 "max instances"... increase it in steps of 3.

     

    The other way is also to not have too many triggers per scene, but instead distribute them over many scenes - like scenes per room etc.

     

     

     

     

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • Tried node-red and the Telegram Bot functionality. It uses the

    Please login or register to see this link.

    node.

    The total flow I use is shown below, the new nodes are the telegram receiver and the telegram sender.

    Please login or register to see this image.

    /monthly_2019_02/nr-15.png.90906d9c08ce0856a05688f0ed3d975d.png" style="width:700px;height:auto;" />

    You need setup the bot and get a token according to the instructions that come with the node. You also need to get the chatID that is created when you connect to the bot.

    The Telegram receiver will send the message to the HC2/ZBS wit the format

    Please login or register to see this code.

    the 'msg' field is the telegram message as received.

    To send a message back to Telegram use

    Please login or register to see this code.

    Easiest to define some helper functions that copy the chatId and type and messageId from the incoming message

    Please login or register to see this code.

    Everything in the 'msg' field is copied over to the payload for the Telegram message, so options like buttons, pictures or whatever Telegram support can be included.

     

    So, now it is really easy to chat with your home :-)

     

    Flow.

    Please login or register to see this spoiler.

     

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • On 2/15/2019 at 10:47 AM, jgab said:

    Tried node-red and the Telegram Bot functionality. It uses the

    Please login or register to see this link.

    node.

    So, now it is really easy to chat with your home :-)

     

    Flow.

    Please login or register to see this spoiler.

     

    So, a simple chat bot with Telegram that allows you to turn on and off devices in the HomeTable structure could look like this

    Please login or register to see this code.

    If we have a HomeTable like {dev={kitchen={lamp=88}, bedroom={lamp=99},back={garden=89}}}

    It returns the first match from the "bottom" of the HomeTable. Could add more checks if it is a device that can be turned on...

    Anyway, we can do commands like

    Please login or register to see this code.

    ...and it's easy to extend with other commands.

    Edited by jgab
    Link to comment
    Share on other sites

    @jgab  I have this alarmescene which worked ok. But when I tried to use two keyfobs instead of only one it goes wrong. I thougth also about integrating the keypad with sceneactivation but have postponed this until the problem with the use of two keyfobs is resolved. May be I haven't understood the Rule.eval. Hope you could spread some light.

    /Frank

     

    Here ist the scene:

    -[[

    %% properties
    34 value
    84 value
    92 value
    230 value
    370 value
    386 value
    %% events
    399 CentralSceneEvent
    401 CentralSceneEvent
    %% globals
    %% autostart
    --]]
    -- Don't forget to declare triggers from devices in the header!!!
    _version,_fix = "1.15",""  -- Feb 13, 2019 

    --[[
    -- EventRunner. Event based scheduler/device trigger handler
    -- Copyright 2018 Jan Gabrielsson. All Rights Reserved.
    -- Email: [email protected]
    --]]
    if not _SCENERUNNER then 

    __sceneName     = "AlarmEventRunner"      -- Set to scene/script name
      _deviceTable   = "devicemap"  -- Name of your HomeTable variable
      _ruleLogLength = 80          -- Log message cut-off, defaults to 40
      _HueHubs       = {}          -- Hue bridges, Ex. {{name='Hue',user=_HueUserName,ip=_HueIP}}
      _GUI = false                 -- Offline only, Open WX GUI for event triggers, Requires Lua 5.1 in ZBS
      _REMOTE=false
      _NUMBEROFBOXES = 1           -- Number of mailboxes, increase if exceeding 10 instances...
      _SPEEDTIME     = 24*2       -- Offline only, Speed through X hours, set to false will run in real-time
      _EVENTSERVER   = true        -- Starts port on 6872 listening for incoming events (Node-red, HC2 etc)
      _VALIDATECHARS = true        -- Check rules for invalid characters (cut&paste)
      _myNodeRed = "http://192.168.1.200:1880/eventrunner"  -- Ex. used for Event.postRemote(_myNodeRed,{type='test})

    -- debug flags for various subsystems...
      _debugFlags = { 
        post=false,invoke=false,eventserver=true,triggers=false,dailys=true,timers=false,rule=false,ruleTrue=false,
        fibaro=true,fibaroStart=false,fibaroGet=false,fibaroSet=false,sysTimers=false,hue=false,scene=true
      }

    end
    -- If running offline we need our own setTimeout and net.HTTPClient() and other fibaro funs...
    if dofile then dofile("EventRunnerDebug.lua") require('mobdebug').coro() end

    _GLOBALS={AlarmStatus='unarmed', PresentState='Home'} 
    --------------- Here you place rules and user code, called once --------------------
    function main()
      local devs = json.decode(fibaro:getGlobalValue(_deviceTable))
      Util.defvars(devs)
      Util.reverseMapDef(devs)

    -- TEST ALARM SETUP
     lights = {60, 76, 82, 207, 50, 212, 122, 173, 392}
    dwSensors = {34,84,92,230,370,386} 
    sirens = {}
    keyfob = 399
    keyfob2 = 401
    phones={89} --  {89,182}
    reddiod = 257
    greendiod = 258  
    rule = Rule.eval

    function FROM(state) return alarmmode==state end
    function TO(state) alarmmode=state end
    alarmmode='disarmed' -- staring state

    -------------- EVENTS -----------------

    rule("keyfob:central.keyId == '3' & $AlarmStatus == 'unarmed'=> log('armed från keyfob 399'); post(#arm,+/00:00:40)")
    rule("keyfob:central.keyId == '4' & $AlarmStatus == 'armed'=> log('unarmed från keyfob 399'); post(#disarm)")
    rule("keyfob2:central.keyId == '3' & $AlarmStatus == 'unarmed'=> log('armed från keyfob 401'); post(#arm,+/00:00:40)")
    rule("keyfob2:central.keyId == '4' & $AlarmStatus == 'armed'=> log('unarmed från keyfob 401'); post(#disarm)")

     

    rule("@08:00 => post(#event{event=#CentralSceneEvent{data={deviceId=399, keyId=3, keyAttribute='Pressed'}}})") --test system
    rule("@08:14 => post(#event{event=#CentralSceneEvent{data={deviceId=401, keyId=4, keyAttribute='Pressed'}}})") --test system

     

    -- If safe for 20min during night, consider quietAtNight
    rule("for(00:20,dwSensors:safe & pirSensors:safe & 22:30..05:00 ) => post(#quietAtNight); repeat()")
    -- If safe for 10min, consider quiet, used for turning off running alarm
    rule("for(00:20,dwSensors:safe & pirSensors:safe & 22:30..05:30 ) => post(#quiet)")
    -- door/window sensors breached
    rule("dwSensors:breached => post(#dwBreached)")

    rule("@06:00 => post(#disarm)")

    -------------- STATE MACHINE -----------------
    rule([[#quietAtNight => 
      || FROM('disarmed') >> TO('armed');  log('Quiet at night and disarmed, arm')
      ]])
    rule([[#quiet => 
      || FROM('running') >> TO('disarmed'); post(#stopAlarm);  log('Quiet and alarm running, stop alarm')
      ]])
    rule([[#dwBreached => 
      || FROM('armed') >> TO('running'); post(#runAlarm); log('Breached and fully armed, run alarm')
      ]])
    rule([[#arm => 
      || FROM('disarmed') & dwSensors:safe >> TO('armed'); greendiod:off; reddiod:on; $PresentState ='Away'; $AlarmStatus ='armed'; log('Now armed') 
      || FROM('disarmed') >> TO('armed');  phones:msg=log('Arm and disarmed and d/w open, cant arm') 
      ]])
    rule([[#disarm =>
      || FROM('armed') >> TO('disarmed'); greendiod:on; reddiod:off; $PresentState ='Home'; $AlarmStatus ='unarmed'
      || FROM('running') >> TO('disarmed'); post(#stopAlarm)
      ]])

    -------------- HELP ROUTINES -----------------
    rule([[#runAlarm =>
        lightStates=lights:value;
        lights:on; sirens:on; 
        phones:msg=log('Alarm started at %s',osdate('%c'))]])

    rule([[#stopAlarm =>
      lights:value=lightStates;
      sirens:off; greendiod:on; reddiod:off; $PresentState ='Home'; $AlarmStatus ='unarmed'; 
      phones:msg=log('Alarm cancelled at %s',osdate('%c'))]])
      
    rule("wait(n/08:02); 84:on")   --test
    rule("wait(n/08:13); 84:off")  --test
    end -- main()
    -------------------------

    Logging:

     

    15:30:19:[35mSun Feb 17: Scene running[0m
    22:50:00:Sun Feb 17: Quiet at night and disarmed, arm[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 08:00:00[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 08:14:00[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 05:00:01[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 22:30:00[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 05:30:01[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 22:30:00[0m
    00:00:00:[34mMon Feb 18: Scheduling daily  at 02/18/19 06:00:00[0m
    06:00:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    06:00:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:00:00:Mon Feb 18: armed från keyfob 399[0m <------------------------------------------Ok
    08:00:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:00:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:00:40:Mon Feb 18: Now armed[0m  <---------------------------------------------------------Ok
    08:02:00:[34mMon Feb 18: fibaro:call(vardagsrum.altandorr,"turnOn")[0m
    08:02:00:Mon Feb 18: Breached and fully armed, run alarm[0m <------------------------------------------Ok
    08:02:00:[34mMon Feb 18: fibaro:call(hall.takbelysning,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(kitchen.windowspots,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(tvattrum.windowspott,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(toa_dusch.takdimmer,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(tvrum.occiolampor,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(dusch_toa.dimmer,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(sovrum.bedlamp_frank,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(sovrum.bedlamp_margaretha,"turnOn")[0m
    08:02:00:[34mMon Feb 18: fibaro:call(tvrum.nexabytare,"turnOn")[0m
    08:02:00:Mon Feb 18: Alarm started at 02/18/19 08:02:00[0m<------------------------------------------Ok
    08:02:00:[34mMon Feb 18: fibaro:call(iOS.iPhone10,6,"sendPush","Alarm started at 02\/18\/19 08:02:00")[0m
    08:13:00:[34mMon Feb 18: fibaro:call(vardagsrum.altandorr,"turnOff")[0m<------------------------------------------Ok
    08:14:00:Mon Feb 18: unarmed från keyfob 401[0m<------------------------------------------Ok
    08:14:00:[34mMon Feb 18: fibaro:call(hall.takbelysning,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(kitchen.windowspots,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(tvattrum.windowspott,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(toa_dusch.takdimmer,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(tvrum.occiolampor,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(dusch_toa.dimmer,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(sovrum.bedlamp_frank,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(sovrum.bedlamp_margaretha,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(tvrum.nexabytare,"setValue","0")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:14:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:14:00:Mon Feb 18: Alarm cancelled at 02/18/19 08:14:00[0m
    08:14:00:[34mMon Feb 18: fibaro:call(iOS.iPhone10,6,"sendPush","Alarm cancelled at 02\/18\/19 08:14:00")[0m
    08:14:00:Mon Feb 18: armed från keyfob 399[0m<------------------------------------------???????
    08:14:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:14:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:14:40:Mon Feb 18: Now armed[0m
    08:14:40:Mon Feb 18: unarmed från keyfob 401[0m<------------------------------------------???????
    08:14:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:14:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:14:40:Mon Feb 18: armed från keyfob 399[0m<------------------------------------------???????
    08:15:20:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:15:20:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:15:20:Mon Feb 18: Now armed[0m
    08:15:20:Mon Feb 18: unarmed från keyfob 401[0m<------------------------------------------???????
    08:15:20:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:15:20:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:15:20:Mon Feb 18: armed från keyfob 399[0m<------------------------------------------???????
    08:16:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:16:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:16:00:Mon Feb 18: Now armed[0m
    08:16:00:Mon Feb 18: unarmed från keyfob 401[0m<------------------------------------------???????
    08:16:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:16:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:16:00:Mon Feb 18: armed från keyfob 399[0m
    08:16:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:16:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:16:40:Mon Feb 18: Now armed[0m
    08:16:40:Mon Feb 18: unarmed från keyfob 401[0m
    08:16:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:16:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:16:40:Mon Feb 18: armed från keyfob 399[0m
    08:17:20:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:17:20:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:17:20:Mon Feb 18: Now armed[0m
    08:17:20:Mon Feb 18: unarmed från keyfob 401[0m
    08:17:20:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:17:20:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:17:20:Mon Feb 18: armed från keyfob 399[0m
    08:18:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:18:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:18:00:Mon Feb 18: Now armed[0m
    08:18:00:Mon Feb 18: unarmed från keyfob 401[0m
    08:18:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:18:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:18:00:Mon Feb 18: armed från keyfob 399[0m
    08:18:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:18:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:18:40:Mon Feb 18: Now armed[0m
    08:18:40:Mon Feb 18: unarmed från keyfob 401[0m
    08:18:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:18:40:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:18:40:Mon Feb 18: armed från keyfob 399[0m
    08:19:20:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:19:20:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:19:20:Mon Feb 18: Now armed[0m
    08:19:20:Mon Feb 18: unarmed från keyfob 401[0m
    08:19:20:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:19:20:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:19:20:Mon Feb 18: armed från keyfob 399[0m
    08:20:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:20:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOn")[0m
    08:20:00:Mon Feb 18: Now armed[0m
    08:20:00:Mon Feb 18: unarmed från keyfob 401[0m
    08:20:00:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOn")[0m
    08:20:00:[34mMon Feb 18: fibaro:call(tvattrum.red_lysdiod,"turnOff")[0m
    08:20:00:Mon Feb 18: armed från keyfob 399[0m
    08:20:40:[34mMon Feb 18: fibaro:call(tvattrum.green_lysdiod,"turnOff")[0m
    08:20:40:[34mMon Feb 18: fibaro:call(tvattrum.red_

    Link to comment
    Share on other sites

  • Topic Author
  • Yes, a slight issue with the rules. The right way is to write it like this

    Please login or register to see this code.

    e.g. to move the $AlarmStatus test to the right-hand side of the rule.

    The way these rules work are that every time the keyfob trigger or the $AlarmStatus global changes value the rule is called. keyfob:central.keyId will always return the last keyId even if it is the change of the $AlarmStatus that triggers the rule. So, when you later changed the value of $AlarmStatus the rule got called and it looked like you pressed a button. The solution is to move the tests that should not trigger the rule to the right-hand side of the "=>".

    The " || <test1> >> <cmd1>; <cmd2>; ...." is the syntax for if-then. You could also write the right-hand side as a chained "and" expression like this:

    Please login or register to see this code.

    as it will stop if the $AlarmStatus test is false. 'log' always return a value ~= false.

     

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • Just now, FrankT said:

    @jgab  Thank you very much!!. I have tried for 2 days and you helped me to get it working in no time.

    Ask quicker, I’m happy to help :-) 

    Link to comment
    Share on other sites

    Need some help

     

    Please login or register to see this image.

    /monthly_2019_02/image.png.fa75539bcadd4ef60f73b592fe7ca926.png" alt="image.png.fa75539bcadd4ef60f73b592fe7ca926.png" />

     

    code

    Please login or register to see this code.

    Think i need you to explain how this fix it. I am lost....a bit

    Link to comment
    Share on other sites

  • Topic Author
  • 19 minutes ago, jompa68 said:

    Need some help

     

    Please login or register to see this link.

     

    code

    Please login or register to see this code.

    Think i need you to explain how this fix it. I am lost....a bit

    Something like this

    Please login or register to see this code.

    now it takes the rest after "set <var> to " as the value. Maybe a need to check if the global exists too...

    Edited by jgab
    Link to comment
    Share on other sites

    Works almost, only thing is that now it does not trigger in ZBS

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • If you set a breakpoint in function setVar what is var and val?

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