AlexxIT/go2rtc · error

not homekit source

Error message

not homekit source

What it means

This error is returned by the HomeKit API unpair handler (apiUnpair) when a stream matching the requested stream name exists, but none of its source URLs is a HomeKit-compatible source. findHomeKitURL scans stream.Sources() for a URL scheme that the HAP (HomeKit Accessory Protocol) module can unpair from; when no source qualifies, the unpair operation cannot proceed.

Solutions

  1. Verify the stream's configured sources include a HomeKit-scheme URL that findHomeKitURL recognizes before calling unpair
  2. Check the stream name in the unpair request matches the stream that actually has the HomeKit source
  3. Re-add the HomeKit source to the stream config, unpair, then remove it
  4. Skip unpairing for streams without HomeKit sources in client code

Example fix

// before
curl -X POST http://localhost:1984/api/homekit?stream=cam
// after — only call unpair on streams whose source is a homekit URL
// streams: cam: ["homekit://...", ...]  (ensure homekit source present)
curl -X POST http://localhost:1984/api/homekit?stream=cam
Defensive patterns

Strategy: validation

Validate before calling

// Go: check stream sources for a homekit URL before calling unpair API
url := findHomeKitURL(stream.Sources())
if url == "" {
    return fmt.Errorf("stream %s has no homekit source; skip unpair", name)
}

Prevention

When it happens

Trigger: Calling the HomeKit unpair API endpoint for a stream whose sources are regular RTSP/HTTP/other URLs rather than a HomeKit (HAP) source; the stream name resolves via streams.Get but findHomeKitURL returns an empty string.

Common situations: Attempting to remove a HomeKit pairing for a camera that was never added as a HomeKit accessory, typos in the stream name resolving to the wrong stream, or a stream whose HomeKit source was removed/replaced with a non-HomeKit source in the config.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/35b4463eae8e9a00. Report an issue: GitHub.

Appendix: source

Thrown at internal/homekit/api.go:159

	conn, err := hap.Pair(url)
	if err != nil {
		return err
	}

	streams.New(id, conn.URL())

	return app.PatchConfig([]string{"streams", id}, conn.URL())
}

func apiUnpair(id string) error {
	stream := streams.Get(id)
	if stream == nil {
		return errors.New(api.StreamNotFound)
	}

	rawURL := findHomeKitURL(stream.Sources())
	if rawURL == "" {
		return errors.New("not homekit source")
	}

	if err := hap.Unpair(rawURL); err != nil {
		return err
	}

	streams.Delete(id)

	return app.PatchConfig([]string{"streams", id}, nil)
}

func findHomeKitURLs() map[string]*url.URL {
	urls := map[string]*url.URL{}
	for name, sources := range streams.GetAllSources() {
		if rawURL := findHomeKitURL(sources); rawURL != "" {
			if u, err := url.Parse(rawURL); err == nil {
				urls[name] = u
			}

View on GitHub (pinned to c245815e75)