2019-04-11, 21:52
How to get iRule working with Kodi v18.1 (Leia)
There are two good methods of solving @houser's problem:
Option 1: How to Trigger Kodi API from a Vera Device
If you have a Vera or similar device, you can do it via curl (as mentioned above).
iRule is beautiful, but excruciatingly frustrating to configure. It has to be horribly programmed behind the scenes, IMHO. It was certainly not well managed from a software dev perspective.
I won't go into details, but in a nutshell, if you have a Vera, create a Device in iRule to support Vera scenes. Create an HTTP gateway pointed to your Vera box. Create a scene in Vera with no devices and use the code below to call the appropriate command.
Note: Vera will require you assign either a device or a notification to the scene. Just assign some dummy device or notify yourself (useful for testing).
During the Vera scene creation, there is a section called "Also, execute the following Luup code:" in step 3. Left click that to open the code editing screen. Enter this code and press Save.
Obviously, you will need to customize the JSON API commands and IP address to suit your needs. The example above will move the UI cursor up. When you execute the scene, the action will fire.
Option 2: Trigger Kodi API with iRule Custom Device URL
The key to getting it to work in iRule are the following details:
If you have any existing HTTP gateways for Kodi, you may need to remove them to get it all to work properly
There are two good methods of solving @houser's problem:
- "open" solution using Lua code (IoT devices; e.g. Vera, SmartThings, etc.)
- iRule only solution
Option 1: How to Trigger Kodi API from a Vera Device
If you have a Vera or similar device, you can do it via curl (as mentioned above).
iRule is beautiful, but excruciatingly frustrating to configure. It has to be horribly programmed behind the scenes, IMHO. It was certainly not well managed from a software dev perspective.
I won't go into details, but in a nutshell, if you have a Vera, create a Device in iRule to support Vera scenes. Create an HTTP gateway pointed to your Vera box. Create a scene in Vera with no devices and use the code below to call the appropriate command.
Note: Vera will require you assign either a device or a notification to the scene. Just assign some dummy device or notify yourself (useful for testing).
During the Vera scene creation, there is a section called "Also, execute the following Luup code:" in step 3. Left click that to open the code editing screen. Enter this code and press Save.
Lua:os.execute('curl -X POST -H "content-type:application/json" http://192.168.1.2:8080/jsonrpc -d \'{"jsonrpc":"2.0","id":1,"method":"Input.Up"}\'')
Obviously, you will need to customize the JSON API commands and IP address to suit your needs. The example above will move the UI cursor up. When you execute the scene, the action will fire.
Option 2: Trigger Kodi API with iRule Custom Device URL
The key to getting it to work in iRule are the following details:
- Gateway configured as a NETWORK gateway with your Web Socket port as the port number (default: 9090); set protocol to TCP
- Create a Device handler in iRule Builder
- Add a new Device Code to the Kodi device
- Enter your URL in this format:
json:jsonrpc?request={"jsonrpc":"2.0","method":"Input.Up", "id":1}
If you have any existing HTTP gateways for Kodi, you may need to remove them to get it all to work properly