-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: rstrip / replace bugs in BETA. #63
Comments
Thanks very much for the feedback.
I was not aware of this so thank you. Ultimately I hope to remove this need altogether if Frigate implements an existing feature request to pass the camera name as an attribute.
Agree that regex is the better way to implement these things as there is no doubt as to the accuracy. In terms of assessing the urgency of this change though. Can you have additional periods in an entity name? I'm not certain To Do
|
I don't know home assistant well enough to tell you this. I'm just thinking of this issue from a string parsing frame. Only reason I found this out, is because I ran into this issue and wanted to fix it. So figured I'd pass the info along. |
@suredesigntshirts how do you have this working? it is not compatible with HA |
Description
rstrip bug
The argument you pass to
rstrip
in python is aset of characters
to strip, not astring
to strip.Hence:
rstrip('_1').rstrip('_2').rstrip('_3')
will replace any of these characters at the end of a string[123_]
So a camera which is named
hello123_
would get changed tohello
technically
rstrip('_123')
would do exact same as code you have in your BETA blueprint.Anyways it's wrong.
replace "camera." bug
Additionally the
replace('camera.')
would also error on a camera namedcamera.outdoor.camera.321
would be replaced tooutdoor.
To resolve, I've changed this code from
to
Regex Explained
Docs: https://www.home-assistant.io/docs/configuration/templating/#regular-expressions
^camera\.
=^
is saying only look at start of string. Then look forcamera.
. You need to escape the period, hence the slash.|
= checks for another regex_\d+$
= look for underscore followed by any amount of digits[0-9]
.$
denotes, only look for this at end of the string.Then replace either of those if found with blank string
''
potential issue with replace("notify.")
I assume you also only want to strip this if it's at start of the string. I've added regex_replace in my code for this as well. This bug also exists in STABLE i assume and should also be fixed there.
other issue with all camera names are only integers
I originally had my camera's named in frigate to their last 3 digits of their IPs because I'm lazy. This caused errors where python thought they were
int
and notstrings
I believe, causing other issues. I didn't debug this and instead just changed them to be prefixed with a string. This issue is not resolved (or may not even exist)diff
test code: test-strip.py
Version
dev
Automation Config
doesn't matter
Frigate Config
doesn't matter
Any other relevant information
No response
The text was updated successfully, but these errors were encountered: