diff --git a/README.md b/README.md index bb14ca2..717ad6a 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,11 @@ calendars and sensors to go with them related to managing rental properties. another generator fails to produce a code) - A random 4 digit (or greater) code based on the event description - The last 4 digits of the phone number. This only works properly if the - event description contains 'Last 4 Digits' followed quickly by a 4 digit - number. This is the most stable, but only works if the event - descriptions have the needed data. The previous two methods can have the - codes change if the event makes changes to length or to the description. + event description contains '(Last 4 Digits): ' or 'Last 4 Digits: ' + followed quickly by a 4 digit number. This is the most stable, but only + works if the event descriptions have the needed data. The previous two + methods can have the codes change if the event makes changes to length + or to the description. - All events will get a code associated with it. In the case that the criteria to create the code are not fulfilled, then the check-in/out date based method will be used as a fallback diff --git a/custom_components/rental_control/sensors/calsensor.py b/custom_components/rental_control/sensors/calsensor.py index fb05adc..9c8b405 100644 --- a/custom_components/rental_control/sensors/calsensor.py +++ b/custom_components/rental_control/sensors/calsensor.py @@ -78,7 +78,7 @@ def _extract_last_four(self) -> str | None: """Extract the last 4 digits from a description.""" if self._event_attributes["description"] is None: return None - p = re.compile(r"""\(Last 4 Digits\):\s+(\d{4})""") + p = re.compile(r"""\(?Last 4 Digits\)?:\s+(\d{4})""") ret = p.findall(self._event_attributes["description"]) if ret: return str(ret[0]) diff --git a/info.md b/info.md index 8614b81..919ccb6 100644 --- a/info.md +++ b/info.md @@ -39,10 +39,11 @@ calendars and sensors to go with them related to managing rental properties. another generator fails to produce a code) - A random 4 digit (or greater) code based on the event description - The last 4 digits of the phone number. This only works properly if the - event description contains 'Last 4 Digits' followed quickly by a 4 digit - number. This is the most stable, but only works if the event - descriptions have the needed data. The previous two methods can have the - codes change if the event makes changes to length or to the description. + event description contains '(Last 4 Digits): ' or 'Last 4 Digits: ' + followed quickly by a 4 digit number. This is the most stable, but only + works if the event descriptions have the needed data. The previous two + methods can have the codes change if the event makes changes to length + or to the description. - All events will get a code associated with it. In the case that the criteria to create the code are not fulfilled, then the check-in/out date based method will be used as a fallback