Assuming your lines are “separated” with a carriage return, why don’t you create a template sensor that would extract the first line only instead of potentially breaking the code (and having to maintain it)? {{states.calendar.[CALENDAR_NAME].attributes.description.splitlines()[0]}}