JSPM

  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q70759F
  • License MIT

A node to control Kodi with automatic JSON-RPC method discovery (dev version)

Package Exports

  • n8n-nodes-kodi
  • n8n-nodes-kodi/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (n8n-nodes-kodi) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

n8n Kodi Node

A powerful and intelligent n8n node for interacting with Kodi media centers via JSON-RPC API. This node automatically discovers available methods and provides a user-friendly interface for executing Kodi commands.

✨ Features

🚀 Automatic Method Discovery

  • Smart Introspection: Automatically discovers all available Kodi methods via JSON-RPC introspection
  • Method Parsing: Intelligently parses complex Kodi API structures to extract actual methods
  • Real-time Updates: Always shows the latest methods available on your Kodi instance
  • No Hardcoding: Adapts to any Kodi version or configuration automatically

🎯 Three Operation Modes

  1. Discover Methods: Automatically find all available Kodi methods and their descriptions
  2. Execute Method: Run any discovered method with dynamic parameter generation
  3. Raw Request: Send custom JSON-RPC requests for advanced users

🔧 Dynamic Parameter Generation

  • Smart Parameter Detection: Automatically identifies method parameters and return types
  • User-Friendly Interface: Select parameters from dropdowns instead of manual entry
  • Parameter Descriptions: Shows detailed information about each parameter
  • Default Values: Pre-configured with sensible defaults (e.g., ID: n8n)

🎨 Enhanced User Experience

  • Method Filtering: Easy method selection with full descriptions
  • Parameter Validation: Built-in parameter type checking and validation
  • Debug Information: Real-time debugging and method information display
  • Error Handling: Comprehensive error messages and fallback options

📋 Prerequisites

  • n8n: Version 1.0 or higher
  • Kodi: Any version with JSON-RPC enabled
  • Network Access: n8n must be able to reach your Kodi instance

🚀 Installation

npm install n8n-nodes-kodi

Option 2: Manual Installation

  1. Clone this repository
  2. Run npm install
  3. Run npm run build
  4. Copy the dist folder to your n8n custom nodes directory

⚙️ Configuration

1. Kodi Credentials

Create a new credential type with:

  • Host: Your Kodi IP address or hostname
  • Port: Kodi HTTP port (default: 8080)
  • Username: HTTP username (if enabled)
  • Password: HTTP password (if enabled)

2. Node Setup

  1. Add the Kodi node to your workflow
  2. Select your Kodi credentials
  3. Choose the operation mode
  4. Configure method and parameters

📖 Usage

Operation 1: Discover Methods

Use this to see all available methods on your Kodi instance:

  • Automatically discovers methods via JSONRPC.Introspect
  • Shows method names, descriptions, and parameter information
  • Updates in real-time based on your Kodi configuration

Operation 2: Execute Method

Execute any discovered method with dynamic parameters:

  1. Select Method: Choose from the discovered methods
  2. Configure Parameters: Use the dynamic parameter interface
  3. Add Parameters: Click "Add Parameter" to see available options
  4. Set Values: Enter parameter values as needed
  5. Execute: Run the method and see results

Operation 3: Raw Request

For advanced users who need custom JSON-RPC requests:

  • Send any valid JSON-RPC request
  • Useful for testing or custom implementations
  • Full control over request format and parameters

🔍 Dynamic Parameter System

The node automatically generates parameter options based on discovered method information:

  • Parameter Names: Select from available parameters for the chosen method
  • Parameter Types: See parameter types and descriptions
  • Default Values: Sensible defaults are provided where possible
  • Validation: Built-in parameter validation and error checking

📚 Common Use Cases

Media Library Management

  • Scan video/audio libraries
  • Get media information
  • Update library metadata

Playback Control

  • Play/pause/stop media
  • Control volume and seeking
  • Get player status

System Management

  • Get system information
  • Control power states
  • Manage addons

File Operations

  • Browse file systems
  • Get file information
  • Navigate media directories

🛠️ Development

Building the Node

# Install dependencies
npm install

# Build the node
npm run build

# Run linting
npm run lint

# Run tests
npm test

Project Structure

├── nodes/
│   └── Kodi/
│       ├── Kodi.node.ts      # Main node implementation
│       ├── Kodi.credentials.ts # Credential definitions
│       └── Kodi.svg          # Node icon
├── credentials/
│   └── KodiApi.credentials.ts
├── package.json
└── README.md

Key Components

  • Method Discovery: Intelligent parsing of Kodi JSON-RPC introspection
  • Parameter Generation: Dynamic parameter creation based on method definitions
  • Error Handling: Comprehensive error handling with custom error types
  • Type Safety: Full TypeScript implementation with proper type definitions

🔧 Technical Details

JSON-RPC Introspection

The node uses Kodi's built-in JSONRPC.Introspect method to:

  • Discover all available API methods
  • Extract method parameters and return types
  • Parse complex nested API structures
  • Handle different Kodi versions automatically

Method Parsing Algorithm

  1. Primary Parsing: Extract methods from standard introspection paths
  2. Fallback Parsing: Use recursive search for complex structures
  3. Parameter Extraction: Parse parameter definitions and types
  4. Method Consolidation: Combine related method information

Error Handling

  • Custom Error Types: KodiError for Kodi-specific errors
  • Graceful Fallbacks: Continue operation even if some features fail
  • User Feedback: Clear error messages and debugging information
  • Retry Logic: Automatic retry for transient failures

📝 Changelog

Version 0.1.31-dev (Current)

  • NEW: Automatic method discovery via JSON-RPC introspection
  • NEW: Dynamic parameter generation and validation
  • NEW: Three operation modes (Discover, Execute, Raw)
  • NEW: Smart method parsing and parameter extraction
  • NEW: Enhanced user interface with parameter dropdowns
  • NEW: Debug information and real-time method details
  • 🔧 IMPROVED: Complete refactor from declarative to programmatic node
  • 🔧 IMPROVED: Enhanced error handling and user feedback
  • 🔧 IMPROVED: Better parameter validation and type checking
  • 🐛 FIXED: Method discovery depth and parameter extraction
  • 🐛 FIXED: UI rendering issues and field initialization

Version 0.1.20-dev

  • Initial development version
  • Basic JSON-RPC functionality
  • Hardcoded method implementations

🤝 Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

Development Guidelines

  1. Follow the existing code style
  2. Add proper TypeScript types
  3. Include error handling
  4. Update documentation
  5. Run tests and linting

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Credits

  • Original Development: Community contributors
  • AI Assistance: Claude Sonnet 4 (Anthropic)
  • n8n Platform: n8n team for the excellent automation platform
  • Kodi Community: For the comprehensive JSON-RPC API documentation

📞 Support

  • Issues: Use GitHub Issues for bug reports and feature requests
  • Documentation: Check the n8n documentation for general help
  • Community: Join the n8n community for discussions

Note: This is a development version (0.1.31-dev). For production use, please wait for a stable release or test thoroughly in your environment.