Auto Bypass Zone when Arming

The first element of any array can be referenced as either tripped_numbers[1] or first( tripped_numbers )

The sub() function operates on strings, not arrays/lists. The only reason it works in your other expressions is because you are using it inside iterate(), which picks on one element (string) in the list at a time. Here’s the reference: https://www.toggledbits.com/luaxp/functions

that makes much more sense, I was looking a the first function but was unsure if it was just going to pick the first character or not. So if I wanted to insert the variable into a reactor activity which runs this lua code luup.call_action("urn:micasaverde-com:serviceId:DSCAlarmPanel1", "SendCommand", {Command = "071", Data="1#*1{first_zone_bypass}#"}, 169) is that the correct way? Do I also have to export it to a state variable?

You don’t need Run Lua for this, just do a regular Device Action, select the panel, and the SendCommand action. If there’s a problem with the parameters for that device, that’s something I can fix PDQ while we’re chatting here, but I think it will be acceptable “out of the box.” I don’t have that device, so I can’t try it here first.

For the Data parameter on that action (not in Run Lua), you’ll want to do:

{ "1#*1" .. first_zone_bypass .. "#" }

Basically, you put an entire expression between the { and } rather than just a variable name. It’s a secret/shortcut.

Oh, and no export needed.

1 Like

Yea my original idea was NOT to use Lua and use a device action but unfortunately Reactor doesn’t fully support it :frowning: . Should I submit a device data request?

*Submitted the device data anyways :wink:

Before we go down that road, two questions: are you sure the action works as Lua? Because based on this list, the action isn’t even declared, and Luup should not be handling it, at least not on device #169… it should give you an error.

Other question, is this the stock DSC plugin from the app store, or is this a subsequent modification and upload?

1 Like

I found this code on the DSC forum, and I have tested that it works using Test LUA haven’t tested through reactor yet but shouldn’t be problematic. Also this is the stock DSC plugin no modifications

Is that device #169 a child device of another?

Yes its a child device to 162, which I just checked has the ‘Send Command’ option but no fields show up

OK. That’s where you want to be. Sit tight a moment.

OK. Go to the Tools tab and update your device info database. Then go back to Activities and try to do the parameters for SendCommand action on device 162.

okay perfect the fields all show up, tried the command no by pass from the zone odd… ill have a look at the logs, to make sure its not a plugin problem

Can you do the “running man” for that action, and screen shot the alert that shows the final action code?

Wait no, that doesn’t work. On the fly it can’t do the expression. That’s a limitation.

Are you able to test-run the entire activity?

1 Like

Boom here ya go

OK, I was editing myself as you posted this. You’re quick, man!

The running-man icon won’t work where there are expressions like that… it’s a limitation.

Are you able to run the entire activity and see if it works or not? If you hit the “Run Activity Now” button in the activity header, it actually runs a different way from the “try” button. It runs it “for real”, which should correctly do the sub, and hopefully work as you want it to…

That did the trick!! Thank you so much for your help Patrick and @LibraSun! Now to figure out the reactor part, which I should be able to do :wink:

2 Likes

By the way, according to some docs I found, you should be able to bypass all the zones at once: *1aabbccddeeff# – a string of those two-digit zone numbers. You can create that from what you have by doing join( proper_number, "" ) instead of first_zone_bypass in that Data field.

is that still command ‘071’? Its not working with all the zones listed at once

Doc is here: HOW TO BYPASS A ZONE on a DSC Alarm - How friendly is YOUR security?

Based on what you’re doing, and what that doc says, it would still be Command 071 (just because we don’t know otherwise), and the full expression for Data would likely be:

{ "1#*1" .. join( proper_number, "" ) .. "#" }

weird I just can’t get that to work according to the docs it should work the exact same as bypassing a single zone

Getting a command error back from the plugin… maybe doing multiple zones at once isn’t support by the plugin?

Yeaup so realized all this work may have become useless, when a zone Is bypassed it still shows open in the UI obviously, so i cannot set a reactor activity to bypass multiple zones by repeating the code until the panel is in a ready mode. Is there any expression to get the second, third zone names from the list?