AlexxIT/go2rtc · error
hass: no entity_id
Error message
hass: no entity_id
What it means
NewClient parses a URL and requires an entity_id query parameter identifying the Home Assistant entity to control. If the query string does not contain a non-empty entity_id, construction is aborted with this error before any network connection is attempted.
Solutions
- Add the entity_id query parameter to the URL, e.g. ws://host:8123/api/websocket?token=TOKEN&entity_id=camera.front
- Verify the parameter name is exactly entity_id (case-sensitive, via query.Get)
- Log/print the parsed URL query in your config assembly to confirm the value reaches NewClient
- Check that config templating/env expansion is not producing an empty entity_id value
Example fix
// before
client, err := hass.NewClient("ws://ha.local:8123/api/websocket?token=" + token)
// after
client, err := hass.NewClient("ws://ha.local:8123/api/websocket?token=" + token + "&entity_id=camera.front") Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(rawURL)
if u == nil || u.Query().Get("entity_id") == "" {
return errors.New("URL must include entity_id query parameter")
}
client, err := hass.NewClient(rawURL) Type guard
func hasEntityID(rawURL string) bool {
u, err := url.Parse(rawURL)
return err == nil && u.Query().Get("entity_id") != ""
} Prevention
- Build the HA URL in one helper that always appends both token and entity_id
- Unit-test URL construction for the entity you control
- Validate query parameters before calling NewClient
When it happens
Trigger: Calling hass.NewClient with a URL like ws://host:8123/api/websocket?token=... but omitting &entity_id=<entity>, or misspelling the parameter (e.g. entityid=), or passing an empty entity_id value.
Common situations: Config file or environment variable building the Home Assistant URL lost the entity_id part; users copy a token-only URL from HA docs; URL building code forgets to url-encode/append the entity query param.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/42147e7809c7b024.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/hass/client.go:26
"github.com/AlexxIT/go2rtc/pkg/webrtc"
pion "github.com/pion/webrtc/v4"
)
type Client struct {
conn *webrtc.Conn
}
func NewClient(rawURL string) (*Client, error) {
u, err := url.Parse(rawURL)
if err != nil {
return nil, err
}
query := u.Query()
entityID := query.Get("entity_id")
if entityID == "" {
return nil, errors.New("hass: no entity_id")
}
var uri, token string
if u.Host == "supervisor" {
uri = "ws://supervisor/core/websocket"
token = SupervisorToken()
} else {
uri = "ws://" + u.Host + "/api/websocket"
token = query.Get("token")
}
if token == "" {
return nil, errors.New("hass: no token")
}
// 1. Check connection to Hass
hassAPI, err := NewAPI(uri, token)View on GitHub (pinned to c245815e75)