v18 Leia Play/pause toggle example?
#16
How to get iRule working with Kodi v18.1 (Leia)

There are two good methods of solving @houser's problem:
  1. "open" solution using Lua code (IoT devices; e.g. Vera, SmartThings, etc.)
  2. 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.

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:
  1. Gateway configured as a NETWORK gateway with your Web Socket port as the port number (default: 9090); set protocol to TCP
  2. Create a Device handler in iRule Builder
  3. Add a new Device Code to the Kodi device
  4. Enter your URL in this format: 
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
Headless Linux Kodi box [Ubuntu 16.04.5 LTS Server] | Dedicated Media Server [Ubuntu 16.04.5 LTS Server]
Reply
#17
(2019-04-11, 21:52)HTGeek Wrote: How to get iRule working with Kodi v18.1 (Leia)

There are two good methods of solving @houser's problem:
  1. "open" solution using Lua code (IoT devices; e.g. Vera, SmartThings, etc.)
  2. 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.

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:
  1. Gateway configured as a NETWORK gateway with your Web Socket port as the port number (default: 9090); set protocol to TCP
  2. Create a Device handler in iRule Builder
  3. Add a new Device Code to the Kodi device
  4. Enter your URL in this format: 
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 

Thanks so much for this! Thought I might have to resign myself between using Yatse for Kodi control and switching to Irule to control my displays and amps etc.
Reply
#18
Just returning to mention for others looking for a solution for this, that it started working after some excellent advice from here:
https://getsatisfaction.com/irule/topics...n-delivery
The trick with iRule for at least me was to drop the encoding and use a network gateway rather than http.
Along with some cleverly doctored fixes in that thread it works great. FWIW, YMMV
Good luck.
Reply
#19
(2019-04-27, 17:01)houser Wrote: Just returning to mention for others looking for a solution for this, that it started working after some excellent advice from here:
https://getsatisfaction.com/irule/topics...n-delivery
The trick with iRule for at least me was to drop the encoding and use a network gateway rather than http.
Along with some cleverly doctored fixes in that thread it works great. FWIW, YMMV
Good luck.
What do you mean by "drop the encoding"?  I have my gateway reconnected to Kodi via Network Gateway and I get a green sync in the app so I believe that part is working... my formatting on the command just must be off but I can't figure it out.

Thanks.
Reply
#20
(2019-11-27, 06:24)JohnLew Wrote:
(2019-04-27, 17:01)houser Wrote: Just returning to mention for others looking for a solution for this, that it started working after some excellent advice from here:
https://getsatisfaction.com/irule/topics...n-delivery
The trick with iRule for at least me was to drop the encoding and use a network gateway rather than http.
Along with some cleverly doctored fixes in that thread it works great. FWIW, YMMV
Good luck.
What do you mean by "drop the encoding"?  I have my gateway reconnected to Kodi via Network Gateway and I get a green sync in the app so I believe that part is working... my formatting on the command just must be off but I can't figure it out.

Thanks. 
Hi John,

I meant URL encoded or not. Example below of the same command encoded and not that works here FWIW:

Play/pause toggle Kodi 18.xx non encoded:
jsonrpc?request={"jsonrpc":"2.0","method":"Player.PlayPause","params":{"playerid":1},"id":1}

Play/pause toggle Kodi 17.xx encoded:
jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Player.PlayPause%22%2C%22params%22%3A%7B%22playerid%22%3A1%7D%2C%22id%22%3A1%7D
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Leia Play/pause toggle example?00