2

I am trying to build a simple python script to control kodi from my linux machine. I can get the basic method calls to work and get the gist of how things are but when it comes to 'listening' for notifications such as Application.OnVolumeChanged, Player.OnPlay, etc., I have no idea where to start from, how to subscribe to these notifications.

The best knowledge I have is that notifications can be subscribed using websockets or TCP and the following piece of code I could piece together,

import asyncio
import websockets
from jsonrpcclient.websockets_client import WebSocketsClient

async def main():
    async with websockets.connect('ws://192.168.1.104:9000') as ws:
        response = await WebSocketsClient(ws).request('Application.OnVolumeChanged')
        print(response)

asyncio.get_event_loop().run_until_complete(main())

One immediate thing I can notice with above code is authorization details aren't being sent to kodi. Apart from that, I have no clue where to go from here (and if this is indeed the right direction).

Any help will be appreciated!

API reference page I have been following - JSON RPC API v8

Paritosh
  • 367
  • 5
  • 20
  • This should have all the python parts in place you will need, just grab some ;) https://pypkg.com/pypi/homeassistant/f/homeassistant/components/media_player/kodi.py – Razze Sep 03 '17 at 00:54

0 Answers0