MikeK Posted August 16, 2023 Share Posted August 16, 2023 Greetings, I have a driver that has a string variable that I would like to attach some programming to, but I can't do a simple equality comparison. I need to see whether the string contains a particular string. Specifically, this is a lock, and I want to change behavior depending on how the lock is locked. The lock writes a message into this string variable that says how it was locked. The first part of the message is exactly what I want, but unfortunately the lock driver appends a date and time, which is not relevant and will prevent direct comparison. Here's an example: "Locked Manually - Wed Aug 16 10:50:35 2023" The part I care about is "Locked Manually". The basic conditional programming in Composer just has "is =" and "is !=". I'm wondering if there's a way to do more advanced string comparison. Perhaps somebody has written a little utility driver? Or maybe there's something obvious that I'm missing. I saw that ChowMain has a driver for doing variable manipulations, but unfortunately it doesn't seem that this sort of string comparison is supported in that one. Thanks! Quote Link to comment Share on other sites More sharing options...
cnicholson Posted August 16, 2023 Share Posted August 16, 2023 I'm also curious about string comparison / manipulation, but perhaps you can program off the underlying lock/unlock events and pop the results into a variable that you can use to drive your logic later (or real-time, depending on what you're trying to do)? See screen shot showing events available from August lock as an example. Quote Link to comment Share on other sites More sharing options...
MikeK Posted August 16, 2023 Author Share Posted August 16, 2023 25 minutes ago, cnicholson said: perhaps you can program off the underlying lock/unlock events Thanks for your reply! Unfortunately, there doesn't seem to be a way to use the events from the driver I'm using to get what I want. On this driver (which is for the Baldwin Zigbee lock that Control4 used to re-sell), there are two lock events: "Locked" and "Locked Manually". Locked fires whenever the lock is locked using the motor. So this means that it is triggered if you press the button on the exterior keypad, or if you send it a command by ZigBee. Locked Manually fires if you lock the lock with the knob or the key. I want to have programming run only when the lock is locked from the exterior keypad (because that means that I'm leaving the house and I want to have lights and TVs turn off, etc.) There's a newer version of the lock driver that has a "Locked Proxy" event like the one you've shown for the August. That means that it was locked by programming. Unfortunately, that driver treats the keypad locking and the knob/key locking equivalently. They're both called "Locked Manually". So, both versions of the driver combine "locked with the keypad" with one of the other methods, making it impossible to use the events to distinguish. What I discovered, though, is that the status message that the older driver puts into that variable is unique for proxy, keypad, and knob/key, so if I can just parse that string, I can fully distinguish. But since it tacks the stupid date/time on there, I can't use a string comparison. Quote Link to comment Share on other sites More sharing options...
MikeK Posted August 16, 2023 Author Share Posted August 16, 2023 Ah! I just discovered that the newer driver for this lock (the one with the Locked Proxy event) has a similar status variable, but it does not tack the date/time onto the end. It seems to provide distinct messages for all three lock events: Manually Locked Keypad Locked by Keypad Command Locked This may be good enough. I'm still interested to know if there's a way to compare against a substring, though, because it would save me a little work to not have to replace the drivers for each of these locks. Quote Link to comment Share on other sites More sharing options...
RAV Posted August 16, 2023 Share Posted August 16, 2023 Don’t know if this supports string manipulation/trunc https://drivercentral.io/platforms/control4-drivers/utility/variable-manipulator-control4-driver-chowmain/ Quote Link to comment Share on other sites More sharing options...
MikeK Posted August 16, 2023 Author Share Posted August 16, 2023 Yeah, thanks, that's the one I mentioned earlier. As far as I can tell from its documentation, it will let you assemble strings by formatting the contents of other variables, but it doesn't have an ability to truncate or compare a substring. Quote Link to comment Share on other sites More sharing options...
zaphod Posted August 16, 2023 Share Posted August 16, 2023 Is there any way in drivers to call underlying Lua code? Could you use substring functions from Lua in any way? Like how in Python you can do a shell command with the os.system() function. Quote Link to comment Share on other sites More sharing options...
alanchow Posted August 16, 2023 Share Posted August 16, 2023 11 minutes ago, MikeK said: Yeah, thanks, that's the one I mentioned earlier. As far as I can tell from its documentation, it will let you assemble strings by formatting the contents of other variables, but it doesn't have an ability to truncate or compare a substring. This is correct. It will not do what you want. Quote Link to comment Share on other sites More sharing options...
MikeK Posted August 16, 2023 Author Share Posted August 16, 2023 14 minutes ago, alanchow said: This is correct. It will not do what you want. Thanks, Alan. Would be a handy feature. Quote Link to comment Share on other sites More sharing options...
MikeK Posted August 16, 2023 Author Share Posted August 16, 2023 26 minutes ago, zaphod said: Is there any way in drivers to call underlying Lua code? Could you use substring functions from Lua in any way? Like how in Python you can do a shell command with the os.system() function. That would be excellent. I haven't found a way to do that but perhaps someone knows? Quote Link to comment Share on other sites More sharing options...
zaphod Posted August 16, 2023 Share Posted August 16, 2023 29 minutes ago, zaphod said: Is there any way in drivers to call underlying Lua code? Could you use substring functions from Lua in any way? Like how in Python you can do a shell command with the os.system() function. @alanchow Is there any way this could be done? Or could you add string function capability to your variable manipulator driver? Quote Link to comment Share on other sites More sharing options...
South Africa C4 user Posted August 17, 2023 Share Posted August 17, 2023 (edited) I’m pretty sure that the Yatun variable manipulator driver (edit: called their calculator driver) allows for some basic string manipulation. However, I am not quite sure where one can get this driver now that Yatun have stoped supporting their C4 drivers. It may still be available on their website. I understand that HopSoft took over support of some of their drivers so they may also have this (although I don’t recall seeing such a driver by HopSoft). Edited August 17, 2023 by South Africa C4 user Quote Link to comment Share on other sites More sharing options...
South Africa C4 user Posted August 17, 2023 Share Posted August 17, 2023 (edited) 17 minutes ago, South Africa C4 user said: I’m pretty sure that the Yatun variable manipulator driver allows for some basic string manipulation. However, I am not quite sure where one can get this driver now that Yatun have stoped supporting their C4 drivers. It may still be available on their website. I understand that HopSoft took over support of some of their drivers so they may also have this (although I don’t recall seeing such a driver by HopSoft). https://www.yatundev.eu:44300/drivers/ Try this… it claims to support all standard Lua string commands. I have used it quite a lot in programming (but not for strings in the last few years so I am a bit hazy on what all it can do). I am 99% sure that I used it for exactly what you are trying to do (essentially a left string function). Edited August 17, 2023 by South Africa C4 user Quote Link to comment Share on other sites More sharing options...
MikeK Posted August 17, 2023 Author Share Posted August 17, 2023 Ah! Thanks, I had seen mention of that, but Yatun has a message on their site saying that they no longer support drivers, and that they had sold off the popular ones. I wasn't able to find that one before. Seems to require a login to download it. I will see if I can get it, though! Quote Link to comment Share on other sites More sharing options...
South Africa C4 user Posted August 17, 2023 Share Posted August 17, 2023 11 hours ago, MikeK said: Ah! Thanks, I had seen mention of that, but Yatun has a message on their site saying that they no longer support drivers, and that they had sold off the popular ones. I wasn't able to find that one before. Seems to require a login to download it. I will see if I can get it, though! It’s a free driver. If you struggle, I can probably get a copy to you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.