{"id":44384058,"url":"https://github.com/yamanote1138/jmri-client","last_synced_at":"2026-04-01T23:03:51.362Z","repository":{"id":7608164,"uuid":"8966173","full_name":"yamanote1138/jmri-client","owner":"yamanote1138","description":"WebSocket client for JMRI with real-time throttle control, auto-reconnection, and browser/Node.js support","archived":false,"fork":false,"pushed_at":"2026-03-22T07:50:55.000Z","size":256,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-22T22:44:01.684Z","etag":null,"topics":["jmri","model-trains","nodejs","typescript","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yamanote1138.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"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":"2013-03-23T05:20:45.000Z","updated_at":"2026-03-22T07:49:07.000Z","dependencies_parsed_at":"2023-01-12T07:15:35.433Z","dependency_job_id":null,"html_url":"https://github.com/yamanote1138/jmri-client","commit_stats":null,"previous_names":["discgolfer1138/jmri-client"],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/yamanote1138/jmri-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamanote1138%2Fjmri-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamanote1138%2Fjmri-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamanote1138%2Fjmri-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamanote1138%2Fjmri-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yamanote1138","download_url":"https://codeload.github.com/yamanote1138/jmri-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamanote1138%2Fjmri-client/sbom","scorecard":{"id":1243244,"data":{"date":"2026-01-26","repo":{"name":"github.com/yamanote1138/jmri-client","commit":"7ff93da7889e4130d2558c57950a0d10abb8cd3d"},"scorecard":{"version":"v5.4.1-0.20260109214540-85483c21ffbb","commit":"85483c21ffbb0f125cf1d16aa53f283d574f4ca5"},"score":2.4,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build-and-test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#fuzzing"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/yamanote1138/jmri-client/build-and-test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/yamanote1138/jmri-client/build-and-test.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#pinned-dependencies"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#license"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#sast"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: https://osv.dev/GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: https://osv.dev/GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: https://osv.dev/GHSA-jr5f-v2jv-69x6","Warn: Project is vulnerable to: https://osv.dev/GHSA-wf5p-g6vw-rhxx","Warn: Project is vulnerable to: https://osv.dev/GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: https://osv.dev/GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: https://osv.dev/GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: https://osv.dev/GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: https://osv.dev/GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: https://osv.dev/GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: https://osv.dev/GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: https://osv.dev/GHSA-mh29-5h37-fv8m","Warn: Project is vulnerable to: https://osv.dev/GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: https://osv.dev/GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: https://osv.dev/GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/85483c21ffbb0f125cf1d16aa53f283d574f4ca5/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2026-02-12T07:56:43.173Z","repository_id":7608164,"created_at":"2026-02-12T07:56:43.173Z","updated_at":"2026-02-12T07:56:43.173Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["jmri","model-trains","nodejs","typescript","websocket"],"created_at":"2026-02-12T00:21:20.351Z","updated_at":"2026-04-01T23:03:51.334Z","avatar_url":"https://github.com/yamanote1138.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jmri-client\n\n[![Build](https://github.com/yamanote1138/jmri-client/actions/workflows/build-and-test.yml/badge.svg?branch=main)](https://github.com/yamanote1138/jmri-client/actions/workflows/build-and-test.yml)\n![License](https://img.shields.io/npm/l/jmri-client)\n![NPM Version](https://img.shields.io/npm/v/jmri-client)\n\nWebSocket client for [JMRI](http://jmri.sourceforge.net/) with real-time updates and full throttle control.\n\n[![NPM](https://nodei.co/npm/jmri-client.png?compact=true)](https://nodei.co/npm/jmri-client/)\n\n## Features\n\n- ✅ **WebSocket-based** - Real-time bidirectional communication\n- ✅ **Event-driven** - Subscribe to power changes, throttle updates, and more\n- ✅ **Full Throttle Control** - Speed (0.0-1.0), direction, and functions (F0-F28)\n- ✅ **Browser \u0026 Node.js** - Works in browsers and Node.js with auto-detection\n- ✅ **Mock Mode** - Test and demo without JMRI hardware\n- ✅ **Auto-reconnection** - Exponential backoff with jitter\n- ✅ **Heartbeat monitoring** - Automatic ping/pong keepalive\n- ✅ **TypeScript** - Full type definitions included\n- ✅ **Dual module support** - ESM and CommonJS\n- ✅ **Extensible** - Subclass `JmriClient` to add support for additional JMRI object types\n\n## Installation\n\n```bash\nnpm install jmri-client\n```\n\n**Requirements:** Node.js 18+\n\n## Quick Start\n\n```typescript\nimport { JmriClient, PowerState } from 'jmri-client';\n\n// Create client\nconst client = new JmriClient({\n  host: 'jmri.local',\n  port: 12080\n});\n\n// Listen for events\nclient.on('connected', () =\u003e console.log('Connected!'));\nclient.on('power:changed', (state) =\u003e {\n  const stateStr = state === PowerState.ON ? 'ON' :\n                   state === PowerState.OFF ? 'OFF' : 'UNKNOWN';\n  console.log('Power:', stateStr);\n});\n\n// Control power\nawait client.powerOn();\n\n// Acquire and control a throttle\nconst throttleId = await client.acquireThrottle({ address: 3 });\nawait client.setThrottleSpeed(throttleId, 0.5);  // 50% speed\nawait client.setThrottleDirection(throttleId, true);  // Forward\nawait client.setThrottleFunction(throttleId, 'F0', true);  // Headlight on\n\n// Clean up\nawait client.releaseThrottle(throttleId);\nawait client.disconnect();\n```\n\n## Documentation\n\n- **[API Reference](docs/API.md)** - Complete API documentation\n- **[Browser Usage](docs/BROWSER.md)** - Using jmri-client in web browsers\n- **[Examples](docs/EXAMPLES.md)** - Common usage patterns\n- **[Mock Mode](docs/MOCK_MODE.md)** - Testing without hardware\n- **[Migration Guide](docs/MIGRATION.md)** - Upgrading from v2.x\n- **[Troubleshooting](docs/TROUBLESHOOTING.md)** - Common issues and solutions\n\n## Key Concepts\n\n### Event-Driven Architecture\n\nSubscribe to real-time updates from JMRI:\n\n```typescript\nclient.on('connected', () =\u003e { });\nclient.on('disconnected', (reason) =\u003e { });\nclient.on('power:changed', (state) =\u003e { });\nclient.on('throttle:updated', (id, data) =\u003e { });\n```\n\n### Throttle Control\n\nFull control of DCC locomotives:\n\n```typescript\nconst throttle = await client.acquireThrottle({ address: 3 });\nawait client.setThrottleSpeed(throttle, 0.5);\nawait client.setThrottleDirection(throttle, true);\nawait client.setThrottleFunction(throttle, 'F0', true);\nawait client.releaseThrottle(throttle);\n```\n\n### Auto-Reconnection\n\nAutomatically reconnects with exponential backoff:\n\n```typescript\nclient.on('reconnecting', (attempt, delay) =\u003e {\n  console.log(`Reconnecting attempt ${attempt} in ${delay}ms`);\n});\n```\n\n### Extending JmriClient\n\n`JmriClient` exposes its `wsClient` as `protected`, so you can subclass it to add support for JMRI object types not yet built in (e.g., sensors, lights, routes, blocks):\n\n```typescript\nimport { JmriClient } from 'jmri-client';\nimport type { PartialClientOptions } from 'jmri-client';\n\nclass MyExtendedClient extends JmriClient {\n  constructor(options?: PartialClientOptions) {\n    super(options);\n\n    // this.wsClient is available — use it to send/receive JMRI JSON messages\n    this.wsClient.on('update', (message: any) =\u003e {\n      if (message.type === 'sensor') {\n        this.emit('sensor:changed', message.data.name, message.data.state);\n      }\n    });\n  }\n\n  async listSensors() {\n    const response = await this.wsClient.request({ type: 'sensor', method: 'list' });\n    return Array.isArray(response?.data)\n      ? response.data.map((r: any) =\u003e r.data ?? r)\n      : [];\n  }\n}\n```\n\n`WebSocketClient` is also exported for direct use if you need it. See its `send()`, `request()`, and `on('update', ...)` API for low-level messaging.\n\n## Testing\n\n**Unit Tests** (no hardware required):\n```bash\nnpm test\n```\n\n**Mock Mode Demo** (no hardware required):\n```bash\nnpm run demo:mock\n```\n\n**Functional Test** (requires JMRI hardware):\n```bash\nnpm run functional\n```\n\n⚠️ **Safety**: Includes automatic power-off on exit, errors, and Ctrl+C.\n\nSee **[Mock Mode Guide](docs/MOCK_MODE.md)** and **[Testing Guide](docs/TESTING.md)** for complete instructions.\n\n## Contributing\n\nIssues and pull requests welcome! Please see the [GitHub repository](https://github.com/yamanote1138/jmri-client).\n\n## License\n\nMIT\n\n## Links\n\n- [GitHub Repository](https://github.com/yamanote1138/jmri-client)\n- [NPM Package](https://www.npmjs.com/package/jmri-client)\n- [JMRI Project](http://jmri.sourceforge.net/)\n- [JMRI JSON Protocol](https://www.jmri.org/help/en/html/web/JsonServlet.shtml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamanote1138%2Fjmri-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamanote1138%2Fjmri-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamanote1138%2Fjmri-client/lists"}