Skip to content

Commit

Permalink
Migrate Vulcan to has entity name (home-assistant#99020)
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek authored and grace43 committed Oct 9, 2023
1 parent cc5185d commit c88f550
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
20 changes: 11 additions & 9 deletions homeassistant/components/vulcan/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from datetime import date, datetime, timedelta
import logging
from typing import cast
from zoneinfo import ZoneInfo

from aiohttp import ClientConnectorError
Expand Down Expand Up @@ -56,26 +57,27 @@ async def async_setup_entry(
class VulcanCalendarEntity(CalendarEntity):
"""A calendar entity."""

_attr_has_entity_name = True
_attr_translation_key = "calendar"

def __init__(self, client, data, entity_id) -> None:
"""Create the Calendar entity."""
self.student_info = data["student_info"]
self._event: CalendarEvent | None = None
self.client = client
self.entity_id = entity_id
self._unique_id = f"vulcan_calendar_{self.student_info['id']}"
self._attr_name = f"Vulcan calendar - {self.student_info['full_name']}"
self._attr_unique_id = f"vulcan_calendar_{self.student_info['id']}"
student_info = data["student_info"]
self._attr_unique_id = f"vulcan_calendar_{student_info['id']}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, f"calendar_{self.student_info['id']}")},
identifiers={(DOMAIN, f"calendar_{student_info['id']}")},
entry_type=DeviceEntryType.SERVICE,
name=f"{self.student_info['full_name']}: Calendar",
name=cast(str, student_info["full_name"]),
model=(
f"{self.student_info['full_name']} -"
f" {self.student_info['class']} {self.student_info['school']}"
f"{student_info['full_name']} -"
f" {student_info['class']} {student_info['school']}"
),
manufacturer="Uonet +",
configuration_url=(
f"https://uonetplus.vulcan.net.pl/{self.student_info['symbol']}"
f"https://uonetplus.vulcan.net.pl/{student_info['symbol']}"
),
)

Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/vulcan/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@
}
}
}
},
"entity": {
"calendar": {
"calendar": {
"name": "[%key:component::calendar::title%]"
}
}
}
}

0 comments on commit c88f550

Please sign in to comment.