{"id":42009838,"url":"https://github.com/bdsoha/vitrea-client","last_synced_at":"2026-01-26T02:20:37.150Z","repository":{"id":155524365,"uuid":"584688584","full_name":"bdsoha/vitrea-client","owner":"bdsoha","description":"🏠 Vitrea Smart Home API Client","archived":false,"fork":false,"pushed_at":"2025-11-09T14:49:30.000Z","size":516,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-09T16:22:04.512Z","etag":null,"topics":["api-client","automation","smart-home","smarthome","vitrea"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdsoha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-03T09:02:04.000Z","updated_at":"2025-11-09T14:48:24.000Z","dependencies_parsed_at":"2024-09-12T16:45:12.765Z","dependency_job_id":"fdae4796-eecd-41f2-82d9-21b52a368de9","html_url":"https://github.com/bdsoha/vitrea-client","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/bdsoha/vitrea-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdsoha%2Fvitrea-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdsoha%2Fvitrea-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdsoha%2Fvitrea-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdsoha%2Fvitrea-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdsoha","download_url":"https://codeload.github.com/bdsoha/vitrea-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdsoha%2Fvitrea-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28764895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T00:37:26.264Z","status":"online","status_checked_at":"2026-01-26T02:00:08.215Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","automation","smart-home","smarthome","vitrea"],"created_at":"2026-01-26T02:20:36.560Z","updated_at":"2026-01-26T02:20:37.135Z","avatar_url":"https://github.com/bdsoha.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vitrea Client\n\nA robust TypeScript client for the Vitrea Smart Home ecosystem that handles the complexities of\nsocket communication, connection management, and protocol versioning so you don't have to.\n\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/bdsoha/vitrea-client/test.yml?branch=master\u0026logo=github\u0026style=for-the-badge)](https://github.com/bdsoha/vitrea-client/actions/workflows/test.yml)\n[![NPM Version](https://img.shields.io/npm/v/vitrea-client?style=for-the-badge\u0026logo=npm)](https://www.npmjs.com/package/vitrea-client)\n[![License](https://img.shields.io/github/license/bdsoha/vitrea-client?style=for-the-badge)](LICENSE)\n[![Node.js Version](https://img.shields.io/node/v/vitrea-client?style=for-the-badge\u0026logo=node.js)](https://nodejs.org/)\n\n\u003c/div\u003e\n\n## Why Vitrea Client?\n\nSmart home integrations shouldn't be fragile.\nThis client was built from the ground up with real-world reliability in mind:\n\n- **Battle-tested connection handling:** Automatic retries, exponential backoff, and intelligent reconnection.\n- **Zero-downtime heartbeats:** Keeps your connection alive without manual intervention.\n- **Thread-safe messaging:** Built-in mutex prevents race conditions and message collisions.\n- **Protocol flexibility:**  Seamlessly supports both V1 legacy and V2 modern protocols.\n- **Production-ready logging:** Integrates with your existing logging infrastructure.\n\n## Quick Start\n\n### Installation\n\n```bash\nnpm install vitrea-client\n```\n\nRequires Node.js 18.17+ or 20.5+\n\n### Basic Usage\n\n```ts\nimport { VitreaClient, Requests, ProtocolVersion } from 'vitrea-client'\n\n// Connect to your Vitrea system\nconst client = VitreaClient.create({\n    host: '192.168.1.23',\n    port: 11501,\n    username: 'admin',\n    password: 'your-password',\n    version: ProtocolVersion.V2\n})\n\nawait client.connect()\n\n// Get room information\nconst rooms = await client.send(new Requests.RoomCount())\nconsole.log(`Found ${rooms.total} rooms`)\n\n// Get node meta information\nconst meta = await client.send(new Requests.NodeMetaData(7))\nconsole.log('Node 7 meta')\nconsole.log(`   ID:          ${meta.id}`)\nconsole.log(`   Room ID:     ${meta.roomID}`)\nconsole.log(`   Version:     ${meta.version}`)\nconsole.log(`   MAC Address: ${meta.macAddress}`)\nconsole.log(`   LED Level:   ${meta.ledLevel}`)\nconsole.log(`   Locked?:     ${meta.isLocked}`)\nconsole.log(`   Total Keys:  ${meta.totalKeys}`)\nconsole.log(`   Key List:    ${meta.keysList}`)\n\n// Monitor real-time key presses\nclient.onKeyStatus(status =\u003e {\n    console.log(`${status.isOn ? 'ON' : 'OFF'}: Room ${status.nodeID}, Key ${status.keyID}`)\n})\n```\n\n## Configuration\n\n### Connection Settings\n\n```ts\nconst client = VitreaClient.create({\n    // Required connection details\n    host: '192.168.1.23',        // Your Vitrea system IP\n    port: 11501,                 // Default Vitrea port\n    username: 'admin',           // Your username\n    password: 'password',        // Your password\n    version: ProtocolVersion.V2  // Use V2 for latest features\n}, {\n    // Optional socket configuration\n    requestBuffer: 250,          // ms between requests (prevents overwhelming)\n    requestTimeout: 1000,        // ms to wait for responses\n    heartbeatInterval: 2500,     // ms between heartbeat pings\n    shouldReconnect: true,       // Auto-reconnect on disconnect\n    ignoreAckLogs: false        // Filter out acknowledgment noise\n})\n```\n\n### Complete Configuration Reference\n\n| Setting                 | Description                   | Default        | Notes                                      |\n| ----------------------- | ----------------------------- | -------------- | ------------------------------------------ |\n| **Connection**          |                               |                |                                            |\n| `host`                  | Vitrea system IP address      | `192.168.1.23` |                                            |\n| `port`                  | Connection port               | `11501`        |                                            |\n| `username`              | Authentication username       | `null`         | Required for most operations               |\n| `password`              | Authentication password       | `null`         | Required for most operations               |\n| `version`               | Protocol version              | `V2`           | V2 recommended for new projects            |\n| **Reliability**         |                               |                |                                            |\n| `requestBuffer`         | Delay between requests *(ms)* | `250`          | Prevents server overload                   |\n| `requestBufferVariance` | Jitter factor *(0.0-1.0)*     | `0.15`         | Adds randomness to prevent thundering herd |\n| `requestTimeout`        | Request timeout *(ms)*        | `1000`         | How long to wait for responses             |\n| `heartbeatInterval`     | Heartbeat frequency *(ms)*    | `2500`         | Keep-alive interval                        |\n| `shouldReconnect`       | Auto-reconnect on failure     | `true`         | Recommended for production                 |\n| **Debugging**           |                               |                |                                            |\n| `log`                   | Custom logger instance        | `null`         | Implement LoggerContract interface         |\n| `ignoreAckLogs`         | Hide acknowledgment logs      | `false`        | Reduces log noise                          |\n\n### Environment Variables\n\nFor production deployments, use environment variables instead of hardcoding credentials:\n\n```bash\nexport VITREA_VBOX_HOST=192.168.1.23\nexport VITREA_VBOX_PORT=11501\nexport VITREA_VBOX_USERNAME=admin\nexport VITREA_VBOX_PASSWORD=secure-password\n```\n\nThe client will automatically pick up any `VITREA_VBOX_*` environment variables that match\nconfiguration keys.\n\n## API Reference\n\n### Request Types\n\nThe `Requests` namespace provides all available commands:\n\n| Command                   | Purpose                              | Example Usage                                                                                               |\n| ------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------- |\n| **System Information**    |                                      |                                                                                                             |\n| `NodeCount`               | Get total nodes in system            | `await client.send(new Requests.NodeCount())`                                                               |\n| `RoomCount`               | Get total rooms in system            | `await client.send(new Requests.RoomCount())`                                                               |\n| `NodeMetaData`            | Get node details and capabilities    | `await client.send(new Requests.NodeMetaData(nodeID: number))`                                              |\n| `RoomMetaData`            | Get room information                 | `await client.send(new Requests.RoomMetaData(roomID: number))`                                              |\n| **Status \u0026 Control**      |                                      |                                                                                                             |\n| `KeyStatus`               | Get current state of a key           | `await client.send(new Requests.KeyStatus(nodeID: number, keyID: number))`                                  |\n| `KeyParameters`           | Get key configuration settings       | `await client.send(new Requests.KeyParameters(nodeID: 1, keyID: number))`                                   |\n| `ToggleKeyStatus`         | Control lights/devices               | `await client.send(new Requests.ToggleKeyStatus(nodeID: number, keyID: number, dimmer: number))`            |\n| `ToggleNodeStatus`        | Control node lock and LED backlight  | `await client.send(new Requests.ToggleNodeStatus(11, LockStatus.UNLOCKED, LEDBackgroundBrightness.NORMAL))` |\n| `NodeStatus`              | Get comprehensive node status        | `await client.send(new Requests.NodeStatus(nodeID: number))`                                                |\n| `InternalUnitStatuses`    | Subscribe to internal status changes | `await client.send(new Requests.InternalUnitStatuses())`                                                    |\n| **Connection Management** |                                      |                                                                                                             |\n| `Login`                   | Authenticate with the system         | `await client.send(new Requests.Login())`                                                                   |\n| `Heartbeat`               | Manual heartbeat (auto-handled)      | `await client.send(new Requests.Heartbeat())`                                                               |\n| `ToggleHeartbeat`         | Enable/disable auto-heartbeat        | `await client.send(new Requests.ToggleHeartbeat(false))`                                                    |\n\n### Protocol Versions\n\n- **V2 *(Recommended)*:** Modern protocol with full feature support.\n- **V1 *(Legacy)*:** Compatibility mode for older systems.\n\nThe client automatically handles protocol differences.\nV2 provides enhanced metadata and improved error handling.\n\n## Advanced Features\n\n### Custom Logging\n\nIntegrate with your existing logging infrastructure:\n\n```ts\nimport { ConsoleLogger, VitreaClient } from 'vitrea-client'\n\n// Built-in console logger\nconst client = VitreaClient.create(\n    { host: '192.168.1.23', username: 'admin', password: 'secret' },\n    { log: new ConsoleLogger() }\n)\n\n// Your existing logger (must implement LoggerContract)\nconst client = VitreaClient.create(\n    { host: '192.168.1.23', username: 'admin', password: 'secret' },\n    { log: yourLogger, ignoreAckLogs: true } // Hide noisy acknowledgments\n)\n```\n\n### Real-Time Event Monitoring\n\nReact to system changes as they happen:\n\n```typescript\nimport { VitreaClient, Responses } from 'vitrea-client'\n\nconst client = VitreaClient.create({ /* config */ })\nawait client.connect()\n\n// Monitor all key state changes\nclient.onKeyStatus((status: Responses.KeyStatus) =\u003e {\n    console.log(`Room ${status.nodeID}, Key ${status.keyID}: ${status.isOn ? 'ON' : 'OFF'}`)\n\n    // React to specific events\n    if (status.nodeID === 1 \u0026\u0026 status.keyID === 'security-panel' \u0026\u0026 status.isOn) {\n        handleSecurityActivation()\n    }\n})\n\n// Connection status monitoring\nclient.on('connected', () =\u003e console.log('System connected'))\nclient.on('disconnected', () =\u003e console.log('System disconnected'))\nclient.on('reconnecting', () =\u003e console.log('Attempting reconnection...'))\n```\n\n## Contributing\n\nFound a bug or want to contribute?\nCheck out our [GitHub repository](https://github.com/bdsoha/vitrea-client) or open an issue.\n\n## License\n\nMIT © [Dov Benyomin Sohacheski](https://github.com/bdsoha)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdsoha%2Fvitrea-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdsoha%2Fvitrea-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdsoha%2Fvitrea-client/lists"}