Skip to content

Commit

Permalink
Fix bug with bad regex strings
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingDiver committed Jun 14, 2021
1 parent 2a8e55a commit ce7b525
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion BetterEmail.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>7.2.10</string>
<string>7.2.11</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
28 changes: 16 additions & 12 deletions BetterEmail.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,22 @@ def triggerCheck(self, device):
if (trigger.pluginProps["serverID"] == str(device.id)) or (trigger.pluginProps["serverID"] == "-1"):

if trigger.pluginTypeId == "regexMatch":
field = trigger.pluginProps["fieldPopUp"]
pattern = trigger.pluginProps["regexPattern"]
self.logger.debug("\t\tChecking Device State {} for Pattern: {}".format(field, pattern))
cPattern = re.compile(pattern)
match = cPattern.search(device.states[field])
if match:
regexMatch = match.group()
self.logger.debug("\t\tExecuting Trigger {} ({}), match: {}".format(trigger.name, trigger.id, regexMatch))
device.updateStateOnServer(key="regexMatch", value=regexMatch)
indigo.trigger.execute(trigger)
else:
self.logger.debug("\t\tNo Match for Trigger {} ({})".format(trigger.name, trigger.id))
try:
field = trigger.pluginProps["fieldPopUp"]
pattern = trigger.pluginProps["regexPattern"]
self.logger.debug("\t\tChecking Device State {} for Pattern: {}".format(field, pattern))
cPattern = re.compile(pattern)
match = cPattern.search(device.states[field])
if match:
regexMatch = match.group()
self.logger.debug("\t\tExecuting Trigger {} ({}), match: {}".format(trigger.name, trigger.id, regexMatch))
device.updateStateOnServer(key="regexMatch", value=regexMatch)
indigo.trigger.execute(trigger)
else:
self.logger.debug("\t\tNo Match for Trigger {} ({})".format(trigger.name, trigger.id))
except Exception as err:
self.logger.warning(u"{}: RegEx processing error for '{}': {}".format(trigger.name, pattern, err))


elif trigger.pluginTypeId == "stringMatch":
field = trigger.pluginProps["fieldPopUp"]
Expand Down

0 comments on commit ce7b525

Please sign in to comment.