Ver Fonte

Only abbreviate last name in public guest name when it actually shortens it

Avoids a dangling period when last_name is already a single glyph.
ZiB há 2 meses atrás
pai
commit
0bd7e4ab33
1 ficheiros alterados com 3 adições e 1 exclusões
  1. 3 1
      custom_components/room_cal_ha/sensor.py

+ 3 - 1
custom_components/room_cal_ha/sensor.py

@@ -150,7 +150,9 @@ class GuestNameSensor(ReservationStrSensor):
     last_name = parts[len(parts) - 1] if len(parts) > 1 else None
     first_abbr = first_name[0].upper() if first_name else None
     last_abbr = last_name[0].upper() if last_name else None
-    public = f"{first_name} {last_abbr}." if last_abbr else full
+    public = (
+      f"{first_name} {last_abbr}." if last_abbr and last_abbr != last_name else full
+    )
     return {
       "first_name": first_name,
       "first_abbr": first_abbr,