Hi,
I developed an own frontend (react) and use homeassistant as backend.
At the moment I try to use the push notifications from homeassistant.
I found in the documentation a description, how to enable push notifications via websockets.
But I have problems to use this, because if I try to create the subscription via custom webhook_id I get the response “Webhook ID not found”.
Here is an simple python testscript to reproduce the behaviour.
Please help me to find my problem ![]()
import asyncio
import websockets
import json
# Replace these with your Home Assistant details
HASS_URL = "ws://192.168.178.75:8123/api/websocket"
HASS_TOKEN = "my-hidden-token"
WEBHOOK_ID = "xyz" # eindeutige ID für Push-Kanal
async def connect_to_hass():
async with websockets.connect(HASS_URL) as websocket:
# Initial message
initial_message = await websocket.recv()
print(f"Initial message: {initial_message}")
# Authenticate
auth_message = {"type": "auth", "access_token": HASS_TOKEN}
await websocket.send(json.dumps(auth_message))
auth_response = await websocket.recv()
print(f"Auth response: {auth_response}")
if json.loads(auth_response)["type"] == "auth_ok":
print("✅ Successfully authenticated!")
# Enable push notifications
push_channel_msg = {
"id": 1,
"type": "mobile_app/push_notification_channel",
"webhook_id": WEBHOOK_ID,
"support_confirm": True
}
await websocket.send(json.dumps(push_channel_msg))
print("Requested push notification channel.")
# Listen for all incoming messages
while True:
message = await websocket.recv()
data = json.loads(message)
print("\nIncoming message:")
print(json.dumps(data, indent=2))
# Check if it's a push notification
if data.get("type") == "event":
event_data = data.get("event", {})
if "message" in event_data:
print("✅ Push notification received:", event_data["message"])
else:
print("❌ Authentication failed!")
# Run
asyncio.get_event_loop().run_until_complete(connect_to_hass())