Commit Graph

2253 Commits

Author SHA1 Message Date
Sergey Krashevich 78ef8fc064 perf(homekit): optimize motion detector with frame-based timing
Replace time.Now() calls in hot path with frame-based timing:
- Pre-compute triggerLevel (integer comparison instead of float division)
- Calibrate hold/cooldown budgets from FPS (default 30fps)
- Periodic FPS recalibration every 150 frames for accuracy
- Active motion path: 47ns → 3.6ns (13x faster)

Update schema.json with detect mode and motion_threshold.
Add threshold tuning guide to README.
2026-03-05 08:50:27 +03:00
Sergey Krashevich a591186da6 test(homekit): add tests and benchmarks for HDS protocol and HKSV consumer
HDS protocol tests (15 tests, 4 benchmarks):
- Message structure for SendMediaInit and SendMediaFragment
- Multi-chunk splitting for fragments > 256KB
- Chunk boundary handling and sequence preservation
- WriteEvent/WriteResponse/WriteRequest round-trip
- opack helper functions

HKSV consumer tests (14 tests, 3 benchmarks):
- Consumer creation and field initialization
- GOP buffer flush with sequence numbering
- Activate with init segment and seqNum=2
- Activate timeout and error handling
- Stop safety (double-stop, deactivation)
- WriteTo blocking until Stop

Also fixes broken hds_test.go (undefined Client → NewConn).
2026-03-05 06:43:11 +03:00
Sergey Krashevich 1856b7ace4 fix(homekit): fix HKSV recording by correcting HDS protocol and adding GOP buffering
The HKSV recording was failing because:
1. The dataSend.data message structure was wrong - `packets` was a flat integer
   instead of an array of objects with `data` and `metadata` fields matching
   the HAP-NodeJS specification
2. Each video/audio frame was sent as a separate mediaFragment, but Home Hub
   expects GOP-based fragments (~2-4 seconds of accumulated data)
3. Large fragments were not chunked (max 256 KiB per chunk)

Changes:
- Fix HDS dataSend.data message structure to use proper packets array with
  nested data/metadata (dataType, dataSequenceNumber, dataChunkSequenceNumber,
  isLastDataChunk, dataTotalSize)
- Add 256 KiB chunking for large media fragments
- Buffer moof+mdat pairs in hksvConsumer and flush on keyframe boundaries
  (GOP-based fragmentation)
- Pre-start consumer at pair-verify for instant init segment delivery
- Add write-response support to HAP PUT handler for ch131 DataStream setup
- Fix HAP service linking to match HAP-NodeJS reference
- Add default SelectedCameraRecordingConfiguration (ch209) value
- Start continuous motion generator at pair-verify with dedup protection
2026-03-05 06:26:06 +03:00
Sergey Krashevich 35fd1383c8 fix(homekit): adjust motion detection threshold and improve hold time checks 2026-03-05 03:09:02 +03:00
Sergey Krashevich 15b0cc4c0c feat(homekit): implement motion detection with configurable threshold and add motion detector functionality 2026-03-04 15:08:06 +03:00
Sergey Krashevich 81dd9e37d8 chore: update .gitignore to include .claude* and .ruff* files 2026-03-04 14:20:33 +03:00
Sergey Krashevich ab27a042c1 feat(homekit): add HKSV support with motion detection and doorbell functionality
- Introduced HKSV configuration options in homekit.go, allowing for motion detection and doorbell features.
- Implemented API endpoints for triggering motion detection and doorbell events.
- Enhanced server.go to handle HKSV sessions and manage motion detection states.
- Created new accessory types for HKSV and doorbell in accessory.go.
- Added support for audio recording configurations in ch207.go.
- Defined new services for motion detection and doorbell in services_hksv.go.
- Implemented opack encoding/decoding for HDS protocol in opack.go and protocol.go.
- Updated OpenAPI documentation to reflect new endpoints and features.
- Extended schema.json to include HKSV configuration options.
2026-03-04 13:53:17 +03:00
Sergey Krashevich a0a36f87bd feat(tests): add CDN URL extraction and patching tests
- implement tests for extracting CDN URLs from HTML files
- add tests for parsing CDN URLs and patching HTML content
- ensure functionality works with real HTML files and CDN URLs
2026-02-16 05:20:25 +03:00
Sergey Krashevich 73c43dbf8b Add CDN dependency download script and update Dockerfiles for offline web UI 2026-02-16 04:50:24 +03:00
Sergey Krashevich 7748346b1f fix(index.html): respect 12-hour format 2026-02-14 07:26:53 +03:00
Sergey Krashevich 39febb67b6 feat(index.html): add time history for system info graph
- introduce timeHistory array to track timestamps
- implement formatClock function for time formatting
- create renderXAxisLabels function for x-axis labels
2026-02-13 15:47:08 +03:00
Sergey Krashevich 8d329fea2e feat(index.html): implement system info update handling
- add timer for periodic updates of system information
- enhance renderInfo function to handle unsupported usage
- improve updateInfo function to manage historical data updates
2026-02-13 15:34:40 +03:00
Sergey Krashevich cfc9c86a66 fix(index.html): replace hash symbol with block character in graph - change the character used for bars from '#' to '█' for better visual representation 2026-02-13 15:13:04 +03:00
Sergey Krashevich 8a083d6f53 feat(index.html): enhance system information display
- add ASCII graph rendering for CPU and memory usage
- implement history tracking for better visualization
- introduce error handling for data fetching

chore(main.js): define system info update interval
- set a common refresh interval for system info updates
2026-02-13 15:11:22 +03:00
Sergey Krashevich 0b80fa53cf feat(api): add system resource monitoring functionality
- implement getSystemInfo to gather CPU and memory usage
- add platform-specific implementations for memory and CPU usage
- enhance OpenAPI documentation to include system resource metrics
2026-02-13 14:49:20 +03:00
Sergey Krashevich beb96dd076 Merge remote-tracking branch 'upstream/master' 2026-02-13 14:07:55 +03:00
Sergey Krashevich ab80450b66 Expose process PID in API and UI
Include the process PID in the API info payload and surface it in the frontend. apiHandler now adds app.Info["pid"] = os.Getpid(); openapi.yaml documents the new pid property as an integer with an example; www/index.html is updated to show pid alongside version and config. This aids debugging and identifying the running process.
2026-02-13 11:12:00 +03:00
Alex X 01c7451556 Restore fix audio sample rate for some xiaomi cameras #2006 2026-02-13 10:59:38 +03:00
Sergey Krashevich c2d3963e93 Merge remote-tracking branch 'upstream/master' into 260213-fix-schemas-race-condition 2026-02-13 10:37:57 +03:00
Sergey Krashevich aa4e90d9d8 Ensure schemas wait for init 2026-02-13 10:37:20 +03:00
Sergey Krashevich 1f2c4b35ed fix(api): fix YAML merge functionality
- implement recursive merging of YAML with patch support
- preserve comments and formatting during merge operations
- add tests for various merge scenarios in config_test.go
2026-02-10 14:57:52 +03:00
Sergey Krashevich 74b92c2d78 chore(.gitignore): update ignored files list
- add CLAUDE.md to the ignored files for better cleanliness
2026-02-10 13:30:09 +03:00
Alex X f68c602a7d Add sitemap to website 2026-02-08 14:00:55 +03:00
Alex X 7f36033bff Merge pull request #2080 from skrashevich/260208-fix-grammar
Fix documentation grammar
2026-02-08 13:04:29 +03:00
Sergey Krashevich 6304987a26 Review uncommitted changes 2026-02-08 08:50:18 +03:00
Alex X 2735bafd86 Rename mpegts module to mpeg 2026-02-08 07:10:30 +03:00
Alex X 44f6f111c4 Move kasa source to separate module 2026-02-08 07:01:14 +03:00
Alex X e5bb03349b Add support pet feeder to xiaomi source #2078 2026-02-07 16:14:10 +03:00
Alex X e90f159c68 Add meta info to website 2026-02-07 13:19:11 +03:00
Alex X be4b6c3271 Update docs 2026-02-07 09:12:31 +03:00
Alex X f3ad4ad977 Fix links in docs 2026-02-07 00:08:47 +03:00
Alex X 7083afe9b2 Merge pull request #2044 from skrashevich/documentation-site
(website): new documentation site
2026-02-06 21:49:35 +03:00
Alex X d01b99d105 BIG docs refactoring 2026-02-06 21:45:55 +03:00
Sergey Krashevich 3984a074a1 webui: add back buttom to links.html 2026-02-04 06:23:39 +03:00
Sergey Krashevich 1b06558140 feat(styles): add external stylesheet for consistent theming and layout 2026-02-04 06:04:05 +03:00
Sergey Krashevich e37da9a056 style: update theme toggle styles to remove borders and animations 2026-02-04 05:28:12 +03:00
Sergey Krashevich c0a2e04ad0 feat(ui): add info and probe pages for detailed stream analysis 2026-02-04 05:15:33 +03:00
Sergey Krashevich 18cd71c602 fix(links): add word wrapping for mobile devices
Add word-break and overflow-wrap CSS properties to prevent long URLs
and stream names from breaking the layout on mobile devices. This fixes
horizontal overflow issues with long text in link items, code blocks,
and stream names.
2026-02-04 04:56:10 +03:00
Sergey Krashevich ab4955f8fc webui: fix header on mobiles 2026-02-03 13:53:49 +03:00
Alex X d1d7846aed Merge pull request #2064 from jmelancondev/webrtc/ice-server-urls-list
webrtc: Fix ice_servers parsing for a list of URLs
2026-02-03 13:42:13 +03:00
Sergey Krashevich 51a213c7da webui: links.html rewrite 2026-02-03 13:32:18 +03:00
Sergey Krashevich 0c91ca7113 webui: fix streams table 2026-02-03 13:25:49 +03:00
Sergey Krashevich c019924763 webui: navigation bar improve 2026-02-03 13:20:09 +03:00
Sergey Krashevich 3b33ffe2e2 webui: link to docs 2026-02-03 13:18:58 +03:00
Alex X 8d58cc7f97 Merge pull request #2065 from skrashevich/260201-small-fixes
Fix error handling in stream creation and patching tests
2026-02-03 13:15:16 +03:00
Sergey Krashevich 92eaaddcef style(config): update styles for main and config sections in HTML 2026-02-03 12:38:43 +03:00
Sergey Krashevich 3d439e030a fix(ui): toggle display of elements on click events in add.html 2026-02-03 12:22:19 +03:00
Sergey Krashevich 430dfc1c31 style: remove transition properties from index.html and main.js 2026-02-03 10:30:03 +03:00
Sergey Krashevich 85daab7ec6 style: update button colors to use CSS variables for improved theming 2026-02-03 10:20:56 +03:00
Sergey Krashevich fe5736905e feat: redesign web UI with theme toggle and improved styling 2026-02-03 09:51:09 +03:00