Auto Bypass Zone when Arming

So with all this extra time I have I want to see this logic up. So what im picturing my logic is to work something like this:

Zones can be bypassed with this Lua code:
luup.call_action("urn:micasaverde-com:serviceId:DSCAlarmPanel1", "SendCommand", {Command = "071", Data="1#*124#"}, 169)

Where the ‘24’ is the zone number. I am thinking of setting an expression variable in the zone number spot, from a list of zones that id want automatically bypassed. If there are multiple zones open id want the RS to keep repeating the code albeit with the next expression variable of the next zone that is open. So if zone 24 and 25 are open it sends the code with zone 24 in the zone number, and after some period the state goes true again for zone 25. Finally Id send a push notif to all users what zones were bypassed based on their names so that we are all aware. Since I have limited knowledge with expressions that’s where I am basically stuck, how would I create an expression variable to get the open zone numbers to input into the code, and their respective names as well.

Okay so ive made some progress with the expressions… the issue im running into is the altid says ‘Zone-24’ and I need just the number is that possible? Also realized the format for single zone numbers in the code they need to be formatted with a 0 infront of the number ie Zone 4 = 04, can an expression variable also add a 0 infront of a single digit number?

Screen Shot 2020-05-05 at 8.19.49 PM

I think you want the sub() function, as described at https://www.toggledbits.com/luaxp/functions

ah I swear ive checked all the reactor docs but everyday im finding new ones, let me give the sub() function a try

1 Like

Heres what the result im getting, currently Zone-24 is open so I am expecting a result of 24

The sub() needs to go inside the iterate() (enclosing the getattribute()) because you want it to apply to each altid. I would also use only the first and second arguments to sub(), and drop the third. That way, you’ll correctly catch any three-digit or longer numbers (may not happen, but good habits prevent future accidents).

2 Likes

Side note: I’ve never seen/used the syntax shown in the 2nd Expression, above, where

VAR := OTHER_VAR = STUFF

Would that be equivalent to this (easier for me to read/understand)?

OTHER_VAR = STUFF

Heh… I didn’t notice THAT until you pointed it out… as it turns out, it will likely work, as assignments are valid in expressions as a by-product of the underlying parser implementation. That means that entry is creating two variables… one called tripped_sensors and one called iterate. In many languages (like Lua), that latter point would be an instant problem for the remaining expressions that try to use the iterate() function, but in this expression parser, it knows the difference and won’t confuse them. This should be corrected, though. No guarantees that would continue to work in future.

Edit: I should add that in this structure/syntax, Reactor itself has no idea that tripped_sensors exists… it exists as a local variable entirely within the expression parser’s context. That has side effects, but I don’t think any that are relevant here. This is just an additional informational comment.

1 Like

*Note all these expression that I got are from a different form post I made to get help with announcing zone openings :slight_smile:

1 Like

Okay so now that expression worked, to get a 0 put infront of a single digit number I was thinking of using an if statement, checking to see the if the result is <10, if true add a 0 infront of the number, if false do nothing. How would I go about using composing the true statement to do just that?

if( tripped_numbers<10, truexp[, tripped_numbers )

Since tripped_numbers is an array, you need to iterate to catch all of the array elements…

So I am unaware if I am supposed to use the tostring(_) ) but I tried with and without and im receiving an undefined result

iterate( tripped_numbers, if( _ < 10, "0", "" ) .. tostring(_) )

1 Like

@Pabla, consider this simpler alternative method for adding leading zeros your single-digit zones:

  1. Instead of an If-Then, merely concatenate “0” & zone_num,
  2. Then, use sub() to extract just the right-most two characters from the resulting string.

You’d have “24” → “24”, as expected, but also get “3” → “03”.

EDIT: I also like your approach, and see no reason why it would not suffice. Just tossing out an alternative that I often use in Google Sheets. :wink:

1 Like

OK. Post a logic summary, please. We need to see everything all in one place.

Logic summary coming right up:

*************************************************** REACTOR LOGIC SUMMARY REPORT ***************************************************
   Version: 3.5hotfix-20070 config 20017 cdata 20045 ui 20045 pluginDevice 323 LuaXP 1.0.1
    System: Vera version 1.7.4970 (7.31) on Sercomm G450 ID 36 (Vera Plus); loadtime 1588782175; systemReady 1588782205; ALTUI v2.49; Lua 5.1; JSON dkjson 1.2; UnsafeLua=1
Local time: 2020-05-06T14:54:01-0700; DST=1; Surrey, British Columbia Canada; formats %Y-%m-%d %H:%M:%S
House mode: plugin 1; system 1; tracking on
  Sun data: { "source": "int", "civdawn": 1588766644, "nautdawn": 1588763805, "sunset": 1588822491, "nautdusk": 1588827537, "stamp": 2020127, "latitude": 49.1063, "astrodusk": 1588830995, "longitude": -122.825, "civdusk": 1588824698, "astrodawn": 1588760347, "sunrise": 1588768851 }
  Geofence: not running
************************************************************************************************************************************
Home Reactor  (#619) TROUBLE
    Version 19082.204 05/06/20 14:48:58
    Message/status: Not tripped
    Variable/expressions
       0: sensors                  list(176,181,175,164,186,173,188,179,180,172,163,185,184,187,171,174) [last [ 176, 181, 175, 164, 186, 173, 188, 179, 180, 172, 163, 185, 184, 187, 171, 174 ](table)]
       1: iterate                  tripped_sensors = iterate( sensors, if( getstate( _, "urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped") == "1", _, null ) ) [last [ 185, 184 ](table)]
       2: tripped_numbers          iterate( tripped_sensors, sub( getattribute( _, "altid" ), 6, 7) ) [last [ "25", "24" ](table)] (exported)
       3: proper_number            iterate( tripped_numbers, if( _ < 10, "0", "" ) .. tostring(_) ) [last null(luaxp.null)]
          *** Error: Failed
    Condition group "Home Reactor" (NUL)  false as of n/a <root>
      Z-F-group "Mudroom Motion" (AND)  false as of 10:06:00 <grpmz0fa2w>
      |     &-F-service Mudroom Motion Sensor (618) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 => 0 at 14:17:16; F/F as of 14:17:16/14:17:16] <condmz0fgnr>
      |     &-F-sun nob sunrise+0,sunset-30 [1588801684 => 1588801739 at 14:48:59; F/F as of 10:06:00/10:06:00] <condmz0fwqv>
      Z-F-group "West Hallway Motion" (AND)  false as of 14:22:21 <grpmz0hxa3>
      |     &-T-service West Light Sensor (641) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel < 50 [27.87 => 0.87 at 14:24:02; T/T as of 10:06:00/10:06:00] <condmz0i83r>
      |     &-F-group "West Hallway LUX" (OR)  false as of 14:22:21 <grpn1qhijt>
      |     |     |-F-service West Hallway Motion1 (639) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 => 0 at 14:21:50; F/F as of 14:21:50/14:21:50] <condn1qho0o>
      |     |     |-F-service West Hallway Motion2 (653) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 => 0 at 14:22:21; F/F as of 14:22:21/14:22:21] <condn3d14xi>
      Z-X-group "Doorbell" (AND)  false as of n/a DISABLED <grpnbqw0pl>
      |     &-?-service Ring Doorbell (627) urn:upnp-org:serviceId:SwitchPower1/Status = 1 [nil at n/a; F/F as of n/a/n/a] <condnbqw2sf>
      Z-F-group "Exit Delay Lock" (AND)  false as of 10:06:00 <grpo7p22xi>
      |     &-F-service Home (169) urn:micasaverde-com:serviceId:AlarmPartition2/DetailedArmMode = ExitDelay [notready at 10:06:00; F/F as of 10:06:00/10:06:00] <condo7p2718>
      Z-F-group "Outdoor Motion" (AND)  false as of 10:06:00 <grpo7p748q>
      |     &-F-sun nob sunrise+0,sunset+0 [1588801684 => 1588801739 at 14:48:59; F/F as of 10:06:00/10:06:00] <condo7p7cp1>
      |     &-F-service Front Out Motion Sensor (274) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped = 1 [1 => 0 at 14:39:36; F/F as of 14:39:36/14:39:36] <condo7p7m54>
      Z-F-group "Random Lights" (AND)  false as of 10:06:00 <grpo7p9n3f>
      |     &-F-service Home (169) urn:micasaverde-com:serviceId:AlarmPartition2/ArmMode = Armed [disarmed at 10:06:00; F/F as of 10:06:00/10:06:00] <condo7p9sfg>
      |     &-F-service Arman's Home (609) urn:upnp-org:serviceId:SwitchPower1/Status = 0 [1 at 10:06:00; F/F as of 10:06:00/10:06:00] <condo7paekf>
      |     &-T-service Jasbir's Home (660) urn:upnp-org:serviceId:SwitchPower1/Status = 0 [1 => 0 at 14:20:32; T/T as of 14:20:32/14:20:32] <condo7pasrm>
      |     &-T-service Jaswinder's Home (611) urn:upnp-org:serviceId:SwitchPower1/Status = 0 [1 => 0 at 14:37:32; T/T as of 14:37:32/14:37:32] <condo7pb7to>
      Z-F-group "Night Mode" (AND)  false as of 10:06:00 <grpo7pkht9>
      |     &-F-service Home (169) urn:micasaverde-com:serviceId:AlarmPartition2/ArmMode = Armed [disarmed at 10:06:00; F/F as of 10:06:00/10:06:00] <condo7pknar>
      |     &-T-service Bar (170) urn:micasaverde-com:serviceId:AlarmPartition2/ArmMode = Armed [armed at 10:06:00; T/T as of 10:06:00/10:06:00] <condo7pl382>
      |     &-F-sun bet sunset+0,sunrise+0 [1588801684 => 1588801739 at 14:48:59; F/F as of 10:06:00/10:06:00] <condo7plq6u>
      Z-X-group "Rec Room" (AND)  false as of n/a DISABLED <grpoix3keg>
      |     &-?-group "Outside Music" (XOR)  false as of n/a <grppblwvwo>
      |     |     ^-?-service Rec Room Harmony (100) urn:rboer-com:serviceId:Harmony1/CurrentActivityID = 25842886 [nil at n/a; F/F as of n/a/n/a] <condpblx3r6>
      Z-F-group "Address Sign" (AND)  false as of 10:06:00 <grppe8je3v>
      |     &-F-sun nob sunrise+20,sunset-20 [1588801684 => 1588801739 at 14:48:59; F/F as of 10:06:00/10:06:00] <condpe8jks6>
      Z-F-group "Variable Polling" (AND)  false as of 10:06:00 <grpqldnna5>
      |     &-F-sun bet sunset-60,sunrise+60 [1588801684 => 1588801739 at 14:48:59; F/F as of 10:06:00/10:06:00] <condqldnv79>
      Z-?-group "Alarm On NFC Tags" (AND)  false as of n/a <grprbr065g>
    Activity grppe8je3v.false
        Device Address Sign Light (272) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
    Activity grpmz0fa2w.true
        Device Mudroom Light (616) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
    Activity grpo7p748q.false
        Device Outside Front Light (113) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
    Activity grpo7p748q.true
        Device Outside Front Light (113) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
    Activity grpo7p9n3f.true
        Device DeusExMachinaII (333) action urn:toggledbits-com:serviceId:DeusExMachinaII1/SetEnabled( NewEnabledValue="1" )
        Delay 3 inline
        Device DeusExMachinaII (333) action urn:toggledbits-com:serviceId:DeusExMachinaII1/Activate(  )
        Change house mode to 2
    Activity grpmz0hxa3.false
        Delay 75 inline
        Device West Hallway Light 1 (651) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
        Device West Hallway Light 2 (648) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
    Activity grpo7p9n3f.false
        Device DeusExMachinaII (333) action urn:toggledbits-com:serviceId:DeusExMachinaII1/SetEnabled( NewEnabledValue="0" )
        Delay 3 inline
        Device Stair Light (198) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
        Device Island Lights (133) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
    Activity grpo7pkht9.true
        Change house mode to 3
    Activity grpo7pkht9.false
        Change house mode to 1
    Activity grpqldnna5.false
        Device Island Lights (133) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="600" )
        Device Island Lights (133) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Chandelier (132) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="600" )
        Device Chandelier (132) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Kitchen Pots (277) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="600" )
        Device Kitchen Pots (277) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Family Room Light (109) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="600" )
        Device Family Room Light (109) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Arman's Room Light (152) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="1800" )
        Device Arman's Room Light (152) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
    Activity grprbr065g.true
        Run Lua:
             1: luup.call_action("urn:micasaverde-com:serviceId:DSCAlarmPanel1", "SendCommand", {Command = "071", Data="1#*1{tripped_numbers}#"}, 169)
    Activity grpmz0fa2w.false
        Delay 75 inline
        Device Mudroom Light (616) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="0" )
    Activity grpqldnna5.true
        Device Island Lights (133) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="180" )
        Device Island Lights (133) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Chandelier (132) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="180" )
        Device Chandelier (132) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Kitchen Pots (277) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="180" )
        Device Kitchen Pots (277) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Family Room Light (109) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="60" )
        Device Family Room Light (109) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
        Device Arman's Room Light (152) action urn:micasaverde-com:serviceId:HaDevice1/SetPollFrequency( PollingEnabled="1", PollMinDelay="900" )
        Device Arman's Room Light (152) action urn:micasaverde-com:serviceId:HaDevice1/Reconfigure(  )
    Activity grpmz0hxa3.true
        Device West Hallway Light 1 (651) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
        Device West Hallway Light 2 (648) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
    Activity grpnbqw0pl.true
        Run Lua:
             1: luup.call_action("urn:micasaverde-com:serviceId:Sonos1", "Alert", {URI="SF:New Recording 2", Duration=20, GroupZones="ALL", Volume=0, SameVolumeForAll="1"}, 724)
    Activity grppe8je3v.true
        Device Address Sign Light (272) action urn:upnp-org:serviceId:SwitchPower1/SetTarget( newTargetValue="1" )
    Activity grpo7p22xi.true
        Delay 120 inline
        Device Hotub Room Door (204) action urn:micasaverde-com:serviceId:DoorLock1/SetTarget( newTargetValue="1" )
        Device Family Deck Door (227) action urn:micasaverde-com:serviceId:DoorLock1/SetTarget( newTargetValue="1" )
        Device West Side Door (626) action urn:micasaverde-com:serviceId:DoorLock1/SetTarget( newTargetValue="1" )
        Device East Side Door (265) action urn:micasaverde-com:serviceId:DoorLock1/SetTarget( newTargetValue="1" )
        Device Shed Door (662) action urn:micasaverde-com:serviceId:DoorLock1/SetTarget( newTargetValue="1" )
    Events
        2020-05-06 14:21:29: Variable tripped_numbers value changed from table: 0x301fa50 to table: 0x4147980
        2020-05-06 14:21:37: Device West Hallway Motion1 (#639) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "1"
        2020-05-06 14:21:37: Condition condn1qho0o test state changed from false to true
        2020-05-06 14:21:37: Condition condn1qho0o evaluation state changed from false to true
        2020-05-06 14:21:37: Group West Hallway LUX test state changed from false to true
        2020-05-06 14:21:37: Group West Hallway LUX evaluation state changed from false to true
        2020-05-06 14:21:37: Group West Hallway Motion test state changed from false to true
        2020-05-06 14:21:37: Group West Hallway Motion evaluation state changed from false to true
        2020-05-06 14:21:37: Launching West Hallway Motion.true activity
        2020-05-06 14:21:37: Launching scene/activity grpmz0hxa3.true
        2020-05-06 14:21:37: Starting "grpmz0hxa3.true" group 1
        2020-05-06 14:21:37: Activity "grpmz0hxa3.true" finished
        2020-05-06 14:21:43: Device West Hallway Motion2 (#653) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "1"
        2020-05-06 14:21:43: Condition condn3d14xi test state changed from false to true
        2020-05-06 14:21:43: Condition condn3d14xi evaluation state changed from false to true
        2020-05-06 14:21:50: Device West Hallway Motion1 (#639) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "1" to "0"
        2020-05-06 14:21:50: Condition condn1qho0o test state changed from true to false
        2020-05-06 14:21:50: Condition condn1qho0o evaluation state changed from true to false
        2020-05-06 14:21:56: Device Front Out Motion Sensor (#274) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "0"
        2020-05-06 14:22:21: Device West Hallway Motion2 (#653) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "1" to "0"
        2020-05-06 14:22:21: Condition condn3d14xi test state changed from true to false
        2020-05-06 14:22:21: Condition condn3d14xi evaluation state changed from true to false
        2020-05-06 14:22:21: Group West Hallway LUX test state changed from true to false
        2020-05-06 14:22:21: Group West Hallway LUX evaluation state changed from true to false
        2020-05-06 14:22:21: Group West Hallway Motion test state changed from true to false
        2020-05-06 14:22:21: Group West Hallway Motion evaluation state changed from true to false
        2020-05-06 14:22:21: Launching West Hallway Motion.false activity
        2020-05-06 14:22:21: Launching scene/activity grpmz0hxa3.false
        2020-05-06 14:22:21: Delaying scene grpmz0hxa3.false group 1 actions until 14:23:36
        2020-05-06 14:23:36: Starting "grpmz0hxa3.false" group 1
        2020-05-06 14:23:36: Activity "grpmz0hxa3.false" finished
        2020-05-06 14:24:02: Device West Light Sensor (#641) urn:micasaverde-com:serviceId:LightSensor1/CurrentLevel changed from "27.87" to "0.87"
        2020-05-06 14:24:48: Device West Hallway Motion2 (#653) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "0"
        2020-05-06 14:24:56: Device West Hallway Motion1 (#639) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "0"
        2020-05-06 14:26:37: Device West Hallway Motion1 (#639) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "0"
        2020-05-06 14:26:44: Device West Hallway Motion2 (#653) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "0"
        2020-05-06 14:27:21: Device Main Entry (#163) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "1"
        2020-05-06 14:27:21: Variable iterate value changed from table: 0x39b0f20 to table: 0x2d062a0
        2020-05-06 14:27:21: Variable tripped_numbers value changed from table: 0x4147980 to table: 0x3145e38
        2020-05-06 14:27:24: Device Main Entry (#163) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "1" to "0"
        2020-05-06 14:27:24: Variable iterate value changed from table: 0x2d062a0 to table: 0x2ce2518
        2020-05-06 14:27:24: Variable tripped_numbers value changed from table: 0x3145e38 to table: 0x3ae39b8
        2020-05-06 14:27:28: Device Main Entry (#163) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "1"
        2020-05-06 14:27:28: Variable iterate value changed from table: 0x2ce2518 to table: 0x3b17850
        2020-05-06 14:27:28: Variable tripped_numbers value changed from table: 0x3ae39b8 to table: 0x44a4538
        2020-05-06 14:27:31: Device Main Entry (#163) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "1" to "0"
        2020-05-06 14:27:31: Variable iterate value changed from table: 0x3b17850 to table: 0x30208a0
        2020-05-06 14:27:31: Variable tripped_numbers value changed from table: 0x44a4538 to table: 0x25353a0
        2020-05-06 14:35:41: Device Jaswinder's Home (#611) urn:upnp-org:serviceId:SwitchPower1/Status changed from "0" to "1"
        2020-05-06 14:35:41: Condition condo7pb7to test state changed from true to false
        2020-05-06 14:35:41: Condition condo7pb7to evaluation state changed from true to false
        2020-05-06 14:35:52: Device Front Out Motion Sensor (#274) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "1"
        2020-05-06 14:35:52: Condition condo7p7m54 test state changed from false to true
        2020-05-06 14:35:52: Condition condo7p7m54 evaluation state changed from false to true
        2020-05-06 14:36:44: Device Main Entry (#163) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "1"
        2020-05-06 14:36:44: Variable iterate value changed from table: 0x30208a0 to table: 0x1b24230
        2020-05-06 14:36:44: Variable tripped_numbers value changed from table: 0x25353a0 to table: 0x3bf2bc0
        2020-05-06 14:37:00: Device Main Entry (#163) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "1" to "0"
        2020-05-06 14:37:00: Variable iterate value changed from table: 0x1b24230 to table: 0x39ed2b8
        2020-05-06 14:37:00: Variable tripped_numbers value changed from table: 0x3bf2bc0 to table: 0x3bbdc88
        2020-05-06 14:37:32: Device Jaswinder's Home (#611) urn:upnp-org:serviceId:SwitchPower1/Status changed from "1" to "0"
        2020-05-06 14:37:32: Condition condo7pb7to test state changed from false to true
        2020-05-06 14:37:32: Condition condo7pb7to evaluation state changed from false to true
        2020-05-06 14:38:05: Configuration changed!
        2020-05-06 14:38:06: TROUBLE: Evaluation error in variable nil: Undefined variable: tripped_number at 15
        2020-05-06 14:38:06: Variable proper_number value set to (luaxp.NULL)
        2020-05-06 14:38:16: Configuration changed!
        2020-05-06 14:38:16: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:39:23: Configuration changed!
        2020-05-06 14:39:23: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:39:36: Device Front Out Motion Sensor (#274) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "1" to "0"
        2020-05-06 14:39:36: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:39:36: Condition condo7p7m54 test state changed from true to false
        2020-05-06 14:39:36: Condition condo7p7m54 evaluation state changed from true to false
        2020-05-06 14:40:06: Configuration changed!
        2020-05-06 14:40:06: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:40:38: Configuration changed!
        2020-05-06 14:40:38: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:40:49: Configuration changed!
        2020-05-06 14:40:49: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:40:52: Device Front Out Motion Sensor (#274) urn:micasaverde-com:serviceId:SecuritySensor1/Tripped changed from "0" to "0"
        2020-05-06 14:40:52: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:42:17: Configuration changed!
        2020-05-06 14:42:18: TROUBLE: Evaluation error in variable nil: Unexpected end of argument list at 48
        2020-05-06 14:42:27: Configuration changed!
        2020-05-06 14:42:27: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:43:27: Configuration changed!
        2020-05-06 14:43:27: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:43:36: Configuration changed!
        2020-05-06 14:43:36: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:43:42: Configuration changed!
        2020-05-06 14:43:42: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:43:50: Configuration changed!
        2020-05-06 14:43:50: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:44:39: Configuration changed!
        2020-05-06 14:44:39: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:48:04: Configuration changed!
        2020-05-06 14:48:04: TROUBLE: Evaluation error in variable nil: Failed
        2020-05-06 14:48:58: Configuration changed!
        2020-05-06 14:48:59: TROUBLE: Evaluation error in variable nil: Failed
    Devices
        DSC Alarm Panel (162) urn:schemas-micasaverde-com:device:DSCAlarmPanel:1 (22/0); parent 0; plugin 114; mfg  model ; dev D_DSCAlarmPanel1.xml impl I_DSCAlarmPanel1.xml
        West Hallway Motion2 (653) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg zooZ model ZSE18; dev D_MotionSensor1.xml impl 
        West Hallway Light 1 (651) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 1; plugin -; mfg  model ; dev D_BinaryLight1.xml impl 
        DeusExMachinaII (333) urn:schemas-toggledbits-com:device:DeusExMachinaII:1 (1/-1); parent 0; plugin 8702; mfg  model ; dev D_DeusExMachinaII1.xml impl I_DeusExMachinaII1.xml
        East Side Door (265) urn:schemas-micasaverde-com:device:DoorLock:1 (7/0); parent 1; plugin -; mfg Schlage model BE469NX; dev D_DoorLock1.xml impl 
        Ring Doorbell (627) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 578; plugin -; mfg rigpapa model Switchboard Virtual Binary Switch; dev D_BinaryLight1.xml impl 
        Address Sign Light (272) urn:schemas-upnp-org:device:BinaryLight:1 (3/1); parent 1; plugin -; mfg Leviton model DZPA1; dev D_BinaryLight1.xml impl 
        Outside Front Light (113) urn:schemas-upnp-org:device:BinaryLight:1 (3/3); parent 1; plugin -; mfg Linear model WS15Z-1; dev D_BinaryLight1.xml impl 
        West Side Door (626) urn:schemas-micasaverde-com:device:DoorLock:1 (7/0); parent 1; plugin -; mfg Schlage model ; dev D_DoorLock1.xml impl 
        Jasbir's Home (660) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 578; plugin -; mfg rigpapa model Switchboard Virtual Binary Switch; dev D_BinaryLight1.xml impl 
        Family Deck Door (227) urn:schemas-micasaverde-com:device:DoorLock:1 (7/0); parent 1; plugin -; mfg Schlage model BE469NX; dev D_DoorLock1.xml impl 
        Hotub Room Door (204) urn:schemas-micasaverde-com:device:DoorLock:1 (7/0); parent 1; plugin -; mfg Schlage model BE469NX; dev D_DoorLock1.xml impl 
        Chandelier (132) urn:schemas-upnp-org:device:DimmableLight:1 (2/3); parent 1; plugin -; mfg  model ; dev D_DimmableLight1.xml impl 
        Mudroom Motion Sensor (618) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg zooZ model ZSE18; dev D_MotionSensor1.xml impl 
        Arman's Room Light (152) urn:schemas-upnp-org:device:DimmableLight:1 (2/3); parent 1; plugin -; mfg  model ; dev D_DimmableLight1.xml impl 
        Family Room Light (109) urn:schemas-upnp-org:device:DimmableLight:1 (2/3); parent 1; plugin -; mfg  model ; dev D_DimmableLight1.xml impl 
        Jaswinder's Home (611) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 578; plugin -; mfg rigpapa model Switchboard Virtual Binary Switch; dev D_BinaryLight1.xml impl 
        Kitchen Pots (277) urn:schemas-upnp-org:device:DimmableLight:1 (2/3); parent 1; plugin -; mfg  model ; dev D_DimmableLight1.xml impl 
        West Light Sensor (641) urn:schemas-micasaverde-com:device:LightSensor:1 (18/0); parent 639; plugin -; mfg  model ; dev D_LightSensor1.xml impl 
        Bar (170) urn:schemas-micasaverde-com:device:AlarmPartition:2 (23/0); parent 162; plugin -; mfg  model ; dev D_DSCAlarmPartition2.xml impl 
        Home (169) urn:schemas-micasaverde-com:device:AlarmPartition:2 (23/0); parent 162; plugin -; mfg  model ; dev D_DSCAlarmPartition2.xml impl 
        West Hallway Motion1 (639) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg zooZ model ZSE40; dev D_MotionSensor1.xml impl 
        Island Lights (133) urn:schemas-upnp-org:device:DimmableLight:1 (2/3); parent 1; plugin -; mfg  model ; dev D_DimmableLight1.xml impl 
        Front Out Motion Sensor (274) urn:schemas-micasaverde-com:device:MotionSensor:1 (4/3); parent 1; plugin -; mfg Linear model WAPIRZ-1; dev D_MotionSensor1.xml impl 
        Switchboard Plugin (578) urn:schemas-toggledbits-com:device:Switchboard:1 (1/-1); parent 0; plugin 9194; mfg  model ; dev D_Switchboard1.xml impl I_Switchboard1.xml
        ZWave (1) urn:schemas-micasaverde-com:device:ZWaveNetwork:1 (19/0); parent 0; plugin -; mfg  model ; dev D_ZWaveNetwork.xml impl 
        Arman's Home (609) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 578; plugin -; mfg rigpapa model Switchboard Virtual Binary Switch; dev D_BinaryLight1.xml impl 
        Shed Door (662) urn:schemas-micasaverde-com:device:DoorLock:1 (7/0); parent 1; plugin -; mfg Schlage model BE469NX; dev D_DoorLock1.xml impl 
        Mudroom Light (616) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 1; plugin -; mfg  model ; dev D_BinaryLight1.xml impl 
        Rec Room Harmony (100) urn:schemas-rboer-com:device:Harmony100:1 (3/-1); parent 0; plugin 8066; mfg  model ; dev D_Harmony100.xml impl I_Harmony.xml
        Stair Light (198) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 1; plugin -; mfg  model ; dev D_BinaryLight1.xml impl 
        West Hallway Light 2 (648) urn:schemas-upnp-org:device:BinaryLight:1 (3/0); parent 1; plugin -; mfg  model ; dev D_BinaryLight1.xml impl 
    Watches
        Device #186 Family Room Deck Door service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #175 Bi-Fold Wreck Doors service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #274 Front Out Motion Sensor service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #173 Family Room/Kitchen/Laundry service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #172 Living/Dining/Bi-Fold service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #171 West Garage Doors service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #180 Gym/Sauna Windows service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #179 Gym Door service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #188 Front Bedroom Wnds service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #169 Home service urn:micasaverde-com:serviceId:AlarmPartition2 variable ArmMode
        Device #660 Jasbir's Home service urn:upnp-org:serviceId:SwitchPower1 variable Status
        Device #609 Arman's Home service urn:upnp-org:serviceId:SwitchPower1 variable Status
        Device #170 Bar service urn:micasaverde-com:serviceId:AlarmPartition2 variable ArmMode
        Device #619 Home Reactor  service urn:toggledbits-com:serviceId:ReactorSensor variable TestHouseMode
        Device #174 Wreck/Office/Deck Door service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #176 Babay/Papa Windows service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #185 Shed Doors service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #184 Shed Windows service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #653 West Hallway Motion2 service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #611 Jaswinder's Home service urn:upnp-org:serviceId:SwitchPower1 variable Status
        Device #181 Bar Doors service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #187 Top Floor Deck Door service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #163 Main Entry service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #639 West Hallway Motion1 service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #618 Mudroom Motion Sensor service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #164 East Garage Doors service urn:micasaverde-com:serviceId:SecuritySensor1 variable Tripped
        Device #619 Home Reactor  service urn:toggledbits-com:serviceId:ReactorSensor variable TestTime
        Device #169 Home service urn:micasaverde-com:serviceId:AlarmPartition2 variable DetailedArmMode
        Device #641 West Light Sensor service urn:micasaverde-com:serviceId:LightSensor1 variable CurrentLevel
        Device #619 Home Reactor  service urn:toggledbits-com:serviceId:ReactorSensor variable cdata
    Special Configuration
        UseReactorScenes = 1
        Retrigger = 0
        FailOnTrouble = 0
        ContinuousTimer = 0
1 Like

So what you have are strings that look like numbers, not numbers, so the “< 10” comparison won’t work without first converting the string to a number. So you could change _ < 10 to tonumber(_) < 10, but I like @LibraSun’s suggestion even better:

1 Like

This is honestly the first time where I am trying to figure out proper functions and im open to any suggestions! Would you mind expanding on your suggestion :slight_smile:

Only after Patrick states his intentions and suggestions, lol, WHICH I SEE HE HAS JUST DONE, ABOVE. (He’s vastly more adept than I!)

forgot to refresh my page to see his post ahah, let me give it a go!

1 Like

ah ha! That did the trick, so now the very last thing I am thinking of doing is grabbing the number of the first zone in the list to later input that in the Lua code. I dont quite think I understand how the sub function works, if I use this iterate( proper_number, sub( _, 1, 2) ) shouldn’t I get the first to second character of the list? I am just getting the same zone number as the expression above