Skip to content

Commit

Permalink
Breaking Change: Change event data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 authored and github-actions[bot] committed Nov 26, 2021
1 parent 63faef3 commit db8b7ef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.pythonPath": "/Users/raman.gupta/projects/personal/ha-zoom-automation/venv/bin/python3",
"python.pythonPath": "/Users/raman/projects/ha-zoom-automation/venv/bin/python",
"files.associations": {
"*.yaml": "home-assistant"
}
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ trigger:
platform: event
event_type: zoom_webhook
event_data:
status:
event: <ZOOM_EVENT_NAME>
event: <ZOOM_EVENT_NAME>
```

### Conditions and Actions
Expand Down
4 changes: 2 additions & 2 deletions custom_components/zoom/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ class ZoomAuthenticatedUserBinarySensor(ZoomBaseBinarySensor):

async def async_event_received(self, event: Event) -> None:
"""Update status if event received for this entity."""
status = event.data["status"]
token = event.data["token"]
status = event.data
token = status.pop("token")
if (
token == self._config_entry.data[CONF_VERIFICATION_TOKEN]
and status[ATTR_EVENT] == CONNECTIVITY_EVENT
Expand Down
4 changes: 1 addition & 3 deletions custom_components/zoom/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ async def post(self, request: Request) -> Response:
data = await request.json()
status = WEBHOOK_RESPONSE_SCHEMA(data)
_LOGGER.debug("Received event: %s", status)
hass.bus.async_fire(
f"{HA_ZOOM_EVENT}", {"status": status, "token": token}
)
hass.bus.async_fire(f"{HA_ZOOM_EVENT}", {**status, "token": token})
except Exception as err:
_LOGGER.warning(
"Received authorized event but unable to parse: %s (%s)",
Expand Down
10 changes: 8 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ async def test_api(hass):
with patch(
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_request",
return_value=AiohttpClientMockResponse(
"get", "zoom_url", status=HTTPStatus.OK, json={"id": "test", "first_name": "test"}
"get",
"zoom_url",
status=HTTPStatus.OK,
json={"id": "test", "first_name": "test"},
),
):
await api.async_get_contact_user_profile("test")
Expand All @@ -63,7 +66,10 @@ async def test_api(hass):
with patch(
"homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session.async_request",
return_value=AiohttpClientMockResponse(
"get", "zoom_url", status=HTTPStatus.OK, json={"id": "test", "first_name": "test"}
"get",
"zoom_url",
status=HTTPStatus.OK,
json={"id": "test", "first_name": "test"},
),
):
await api.async_get_my_user_profile()

0 comments on commit db8b7ef

Please sign in to comment.