diff --git a/custom_components/vulcan/fetch_data.py b/custom_components/vulcan/fetch_data.py index f89791c..de7dda7 100644 --- a/custom_components/vulcan/fetch_data.py +++ b/custom_components/vulcan/fetch_data.py @@ -296,24 +296,25 @@ async def get_latest_message(client): """ latest_message: dict[str, int | str] = {"timestamp": 0} - async for messagebox in await client.data.get_message_boxes(): - async for message in await client.data.get_messages(messagebox.global_key): - if message.sent_date.timestamp > latest_message["timestamp"]: - latest_message["id"] = message.id - latest_message["title"] = message.subject - latest_message["content"] = re.sub( - re.compile("<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});"), - "", - message.content, - ) - if message.sender is not None: - latest_message["sender"] = message.sender.name - else: - latest_message["sender"] = "Nieznany" - latest_message["date"] = ( - f"{message.sent_date.time.strftime('%H:%M')} {message.sent_date.date.strftime('%d.%m.%Y')}" - ) - latest_message["timestamp"] = message.sent_date.timestamp + async for message in await client.data.get_messages( + client.student.message_box.global_key + ): + if message.sent_date.timestamp > latest_message["timestamp"]: + latest_message["id"] = message.id + latest_message["title"] = message.subject + latest_message["content"] = re.sub( + re.compile("<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});"), + "", + message.content, + ) + if message.sender is not None: + latest_message["sender"] = message.sender.name + else: + latest_message["sender"] = "Nieznany" + latest_message["date"] = ( + f"{message.sent_date.time.strftime('%H:%M')} {message.sent_date.date.strftime('%d.%m.%Y')}" + ) + latest_message["timestamp"] = message.sent_date.timestamp if not latest_message: latest_message = { "id": 0, diff --git a/custom_components/vulcan/manifest.json b/custom_components/vulcan/manifest.json index c9a4229..03355ad 100644 --- a/custom_components/vulcan/manifest.json +++ b/custom_components/vulcan/manifest.json @@ -7,6 +7,6 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/Antoni-Czaplicki/vulcan-for-hassio/issues", "quality_scale": "silver", - "requirements": ["vulcan-api==2.3.2"], - "version": "0.16.0" + "requirements": ["vulcan-api==2.4.0"], + "version": "0.16.1" }