Split IP Address Text

Hi I have a message like (192.168.2.50) I need to remove the both parenthesis with a split expression or something like that can you help me?
I use this, but I think there is a best way to do this:

message: {{ states.persistent_notification.http_login.attributes.message.split (" (") [1].replace(")","") }}

No need to slpit it. Just replace twice. ( and )

message: {{ state_attr('persistent_notification.http_login', 'message')|replace(")","")|replace("(","") }}

Also please heed this warning:

https://www.home-assistant.io/docs/configuration/templating/#states

1 Like

You could also use python slice

message: {{ state_attr('persistent_notification.http_login', 'message')[1:-1] }}
2 Likes

That’s a better idea.