Skip to content

Commit

Permalink
fixed notify data bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasJoKuJonas committed Nov 22, 2024
1 parent 0c085e1 commit 7557bb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
20 changes: 15 additions & 5 deletions custom_components/webuntis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,15 @@ async def _async_status_request(self) -> None:
"target": service.get("target", {}),
}

data.update(
get_notification_data_homework(
event, service, self.title, self
)
dic, notify_data = get_notification_data_homework(
event, service, self.title, self
)

for key, value in notify_data.items():
data["data"][key] = value

data.update(dic)

await async_notify(
self._hass,
service_id=service["entity_id"],
Expand Down Expand Up @@ -1147,7 +1150,14 @@ async def update_notify(self):

changes = get_changes(change, lesson, lesson_old, server=self)

data.update(get_notification_data(changes, service, self.title))
dic, notify_data = get_notification_data(
changes, service, self.title
)

for key, value in notify_data.items():
data["data"][key] = value

data.update(dic)

await async_notify(
self._hass,
Expand Down
10 changes: 7 additions & 3 deletions custom_components/webuntis/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ async def validate_login(

credentials["server"] = urlparse(credentials["server"]).netloc


try:
socket.gethostbyname(credentials["server"])
except Exception as exc:
Expand Down Expand Up @@ -769,10 +768,15 @@ async def async_step_test_notify_service(
"time_end": datetime.datetime.now().strftime("%H:%M:%S"),
}

data.update(
get_notification_data(changes, config, self.config_entry.title)
dic, notify_data = get_notification_data(
changes, config, self.config_entry.title
)

for key, value in notify_data.items():
data["data"][key] = value

data.update(dic)

success = await async_notify(
self.hass,
service_id=config["entity_id"],
Expand Down
6 changes: 2 additions & 4 deletions custom_components/webuntis/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ def get_notification_data(changes, service, entry_title):
)

result["message"] = message
result["data"] = data

return result
return result, data


"""
Expand Down Expand Up @@ -225,8 +224,7 @@ def get_notification_data_homework(parameters, service, entry_title, server):
return {
"message": message,
"title": title,
"data": data,
}
}, data


def get_changes(change, lesson, lesson_old, server):
Expand Down

0 comments on commit 7557bb4

Please sign in to comment.