diff --git a/.vscode/settings.json b/.vscode/settings.json index 1002e56..923d287 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } diff --git a/README.md b/README.md index 632594f..51d454c 100644 --- a/README.md +++ b/README.md @@ -208,8 +208,7 @@ trigger: platform: event event_type: zoom_webhook event_data: - status: - event: + event: ``` ### Conditions and Actions diff --git a/custom_components/zoom/binary_sensor.py b/custom_components/zoom/binary_sensor.py index 12ac9b4..ed21a35 100644 --- a/custom_components/zoom/binary_sensor.py +++ b/custom_components/zoom/binary_sensor.py @@ -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 diff --git a/custom_components/zoom/common.py b/custom_components/zoom/common.py index 45dc0bc..19a6c73 100644 --- a/custom_components/zoom/common.py +++ b/custom_components/zoom/common.py @@ -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)", diff --git a/tests/test_api.py b/tests/test_api.py index 6d3abbe..44c43e3 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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") @@ -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()