This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Control KODI
#1
Good afternoon,

Has anyone tried to control KODI through homelynk?
I would like to know if it is possible and how it can be done in such a case.


Thank you so much,
Reply
#2
(18.04.2017, 15:32)Superchango Wrote: Good afternoon,

Has anyone tried to control KODI through homelynk?
I would like to know if it is possible and how it can be done in such a case.


Thank you so much,

Hello, yes i use it but my code is very basic and needs some beautification Sad

the library
Code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
function kodiHandler(iServer,iPort,sendPort)  -- first call  if not ready then    require('socket')        lastdatareceived = nil    ready = true  end    -- client connected  if connected then    while true do      char, err = client:receive(1)      -- error while receiving, closed socket      if err == 'closed' then          connected = false        sleep(1)        break      end              if char ~= nil then        lastdatareceived = os.time()        warningclosed = true        warningfailed = true        warningerrors = true        warningtimeou = true                         table.insert(buffer, char)        tmpbuf = table.concat(buffer)        if ( json.pdecode(tmpbuf) ) then          data = tmpbuf          parse(data)          buffer = {}        end      else        now = os.time()        deltatime = now - lastdatareceived      end              -- receive incoming send requests          msg, ip, port = sendServer:receivefrom()             if msg then        -- send command        --log("send: "..msg)        client:send(msg)             end            --[[ clear not complete buffer      if deltatime > 10 and #buffer > 0 then        log( #buffer )        buffer = {}        lastdatareceived = os.time()      end      -]]    end        -- first call or previously disconnected  else    -- close previous connection when disconnected    if client then      client:close()      client = nil    end    if sendServer then      sendServer:close()      sendServer = nil    end        -- create tcp client    client = socket.tcp()    client:settimeout(5)    connected, err = client:connect(iServer, iPort)        -- connect ok, reset buffer    if connected then      lastdatareceived = os.time()      warningclosed = true      warningfailed = true      warningerrors = true      warningtimeou = true      --log('[KODI-client] connection ok: '..iServer)      buffer = {}            -- create udp server to receive incoming send requests             if not sendServer then               sendServer = socket.udp()               sendServer:setsockname('*', sendPort)               sendServer:settimeout(0.1)             end            sleep(5)            -- send initial command      --client:send( '{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 0 }, "id": 1}' )                -- error while connecting,    else             --log(err)      if warningfailed then log('[KODI-client] connection failed (conn): '.. err) end      warningfailed = false      sleep(5)    end  end    -- incoming command parser  function parse(data)    -- log other info, not mapped, if useful    --log("data received: "..data)    --log(json.pdecode(data))  end end

the resident script
Code:
1234567891011121314
require('user.nit_kodi') require('json') kodiHandler("192.168.x.x","9090","18007") -- callback from handler -- tv recording play function tvrecPlay()  log("test1") end -- tv recording - pause or stop function tvrecStop()   log("test2") end
in another script u can use for example:
Code:
1
udpsend( '{ "jsonrpc": "2.0", "id": 1, "method": "Application.SetVolume", "params": { "volume": 50 } }', "18007" )
Reply
#3
Thanks I will put with it to see if I am able to perform a control of my HTPC with KODI
Reply
#4
Hi,

My "solution" is even more basic.

I installed an USB IR Flirc receiver on my Kodi box and programmed it with a Samsung remote control. I then use a Global Caché IR transmitter that is controlled through simple TCP commands.

In my visualisation I have programmed a "universal" remote control with which I can control my cable decoder, AVR, Kodi and TV.

Attached Files Thumbnail(s)
   
Reply
#5
One more simple KODI control solution:


Code:
1234567891011121314151617181920212223242526
require('socket.http') socket.http.TIMEOUT = 5 -- play --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "play" }, "id": 1 }') -- pause -------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "pause" }, "id": 1 }, "id": 1 }') -- down --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Down", "id": 1}') -- up ----------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Up", "id": 1}') -- right -------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Right", "id": 1}') -- left --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Left", "id": 1}') -- home --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Home", "id": 1}') -- select ------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Select", "id": 1}')
Reply
#6
(19.04.2017, 14:23)leonidas Wrote: One more simple KODI control solution:


Code:
1234567891011121314151617181920212223242526
require('socket.http') socket.http.TIMEOUT = 5 -- play --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "play" }, "id": 1 }') -- pause -------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "pause" }, "id": 1 }, "id": 1 }') -- down --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Down", "id": 1}') -- up ----------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Up", "id": 1}') -- right -------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Right", "id": 1}') -- left --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Left", "id": 1}') -- home --------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Home", "id": 1}') -- select ------------------------------------------------------------------------------------------- data1 = socket.http.request('http://192.168.1.79:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Input.Select", "id": 1}')

With this solution you have no incoming data, so you can't turn off your lights when a movie starts for example.
Reply
#7
(19.04.2017, 14:28)gjniewenhuijse Wrote: With this solution you have no incoming data, so you can't turn off your lights when a movie starts for example.

Yes, but it's better than using Global Cache.
Reply
#8
(20.04.2017, 07:25)leonidas Wrote: Yes, but it's better than using Global Cache.

yes, you're right.
Reply
#9
(19.04.2017, 12:04)baggins Wrote: Hi,

My "solution" is even more basic.

I installed an USB IR Flirc receiver on my Kodi box and programmed it with a Samsung remote control. I then use a Global Caché IR transmitter that is controlled through simple TCP commands.

In my visualisation I have programmed a "universal" remote control with which I can control my cable decoder, AVR, Kodi and TV.

Hi Baggins,

Since I see the "Telenet" symbol on your visualisation I assume we live in the same country. 
To avoid re-inventing hot water, here Could you share some tcp commands you use to control your cable decoder + give some insight on how you built the visualisation shown in the screenshot of your post?

kr,

B.
Reply
#10
(11.09.2017, 21:02)Bart Wrote:
(19.04.2017, 12:04)baggins Wrote: Hi,

My "solution" is even more basic.

I installed an USB IR Flirc receiver on my Kodi box and programmed it with a Samsung remote control. I then use a Global Caché IR transmitter that is controlled through simple TCP commands.

In my visualisation I have programmed a "universal" remote control with which I can control my cable decoder, AVR, Kodi and TV.

Hi Baggins,

Since I see the "Telenet" symbol on your visualisation I assume we live in the same country. 
To avoid re-inventing hot water, here Could you share some tcp commands you use to control your cable decoder + give some insight on how you built the visualisation shown in the screenshot of your post?

kr,

B.

Hi,

As I've stated, I use a Global Caché (it actually is the Basalte version) transmitter attached to the Telenet Digicorder.
Here is the script I use to control the Digicorder:

Code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
--[[    Command: Command for execution by controller of Global Cache. To transmit IR command Command=sendir. See full list in GLobal Cache manual.    Modul: The module containing the appropriate IR port (e.g. for iTach=1    NumDev: Number of port in the module starting with 1.    Id: Id number of the command in range 0 – 65535    Freq: IR channel frequency in Hz, from 20000 – 500000    Repeat: on 0 – repeat the command up to 65535 times or while the command transmit is terminated    Offset: Time period to repeat the telegram in the next transmissions (Repeat<>1), 1 – 255    P0,…,Pn: String sequence defining impulse sequence in IR telegram    ^: Symbol defining the end of command string, OD (Hex) --]] local socket = require("socket") function send_Digicorder(command)  log('send_Digicorder called; command ' .. command) tcp = assert(socket.tcp()) tcp:settimeout(0.5)  Device = '192.168.0.26'                                                        Header =  "sendir,1:2,1,38000,1,1,"                                              connected, err = tcp:connect(Device, '4998')                                                     --print (connected) --print (err) Digicorder = {} Digicorder["BACK"] =             "11,12,12,24,12,12,23,24,12,12,23,24,23,25,11,12,23,12,12,12,11,13,11,24,23,3362\r" Digicorder["CHANNEL DOWN"] =     "11,12,11,25,11,13,23,25,11,13,23,25,22,25,11,13,23,25,23,12,11,25,23,3359\r" Digicorder["CHANNEL UP"] =       "11,12,11,25,11,13,22,25,11,13,23,25,23,25,11,13,22,25,23,25,23,25,11,3348\r" Digicorder["CLEAR"] =            "11,13,11,25,11,13,23,25,11,13,23,25,23,25,11,13,23,13,11,13,11,25,11,13,23,3364\r" Digicorder["COMMUNICATION"] =    "12,12,11,25,11,13,22,25,11,12,23,25,23,24,12,13,11,12,23,13,11,12,12,24,23,3362\r" Digicorder["CURSOR DOWN"] =      "11,13,11,25,11,12,23,25,12,12,23,25,23,25,11,13,23,13,11,24,23,25,23,3360\r" Digicorder["CURSOR ENTER"] =     "11,12,11,25,11,13,22,25,11,13,23,25,23,25,11,13,22,13,11,25,23,13,11,25,11,3348\r" Digicorder["CURSOR LEFT"] =      "11,13,11,25,11,12,23,25,11,12,23,25,23,25,11,13,23,13,11,25,11,12,11,13,23,3360\r"                                                         Digicorder["CURSOR RIGHT"] =     "11,13,11,25,11,12,23,25,11,12,23,25,23,25,11,13,23,13,11,25,11,12,23,25,11,3351\r" Digicorder["CURSOR UP"] =        "11,13,11,25,11,13,23,25,11,13,23,24,23,25,11,12,23,25,22,13,11,13,11,25,11,3349\r" Digicorder["DIGIT 0"] =          "11,13,11,25,11,12,23,25,11,12,23,25,23,25,11,13,11,12,23,25,23,25,23,3365\r" Digicorder["DIGIT 1"] =          "11,13,11,25,11,13,23,25,11,13,23,25,22,25,11,13,11,12,12,13,11,13,11,12,23,25,11,3347\r" Digicorder["DIGIT 2"] =          "11,13,11,25,11,13,23,25,11,13,23,25,22,25,11,13,11,12,11,13,11,13,23,25,23,3360\r" Digicorder["DIGIT 3"] =          "11,13,11,25,11,13,23,25,11,13,22,25,23,25,11,13,11,13,11,13,11,13,22,13,11,25,11,3348\r" Digicorder["DIGIT 4"] =          "11,13,11,25,11,13,23,25,11,13,22,25,23,25,11,13,11,13,11,12,23,25,11,12,23,3360\r" Digicorder["DIGIT 5"] =          "11,12,11,25,11,13,22,25,11,12,23,25,23,24,11,13,11,13,11,12,23,24,23,25,11,3327\r" Digicorder["DIGIT 6"] =          "11,13,11,25,11,13,23,25,11,13,23,25,22,25,11,13,11,13,11,12,23,12,11,25,23,3362\r" Digicorder["DIGIT 7"] =          "11,13,11,25,11,13,23,25,11,13,23,25,22,25,11,13,11,13,11,12,23,12,11,13,11,25,11,3353\r" Digicorder["DIGIT 8"] =          "11,13,11,25,11,13,23,25,11,13,23,25,22,25,11,13,11,13,23,25,11,13,11,12,23,3359\r" Digicorder["DIGIT 9"] =          "11,12,11,25,11,13,23,25,11,13,23,25,23,24,11,13,11,13,23,25,11,13,23,25,11,3345\r" Digicorder["ENTER"] =            "11,25,11,13,23,25,11,13,11,13,22,25,22,25,11,13,23,25,11,13,22,25,23,3363\r" Digicorder["EXIT"] =             "11,12,11,25,11,13,23,25,11,13,23,25,23,25,11,13,23,12,11,13,11,25,23,25,11,3350\r" Digicorder["EXTRA"] =            "12,13,11,25,11,12,23,25,11,12,23,25,22,25,11,13,11,12,23,12,12,12,11,13,11,24,12,3351\r" Digicorder["FORWARD"] =          "11,13,11,25,11,13,23,25,11,13,23,25,23,25,23,25,11,13,11,13,11,13,11,13,23,3360\r" Digicorder["FUNCTION BLUE"] =    "11,12,12,24,12,12,23,24,12,13,23,24,23,24,23,25,23,24,11,13,23,24,11,3351\r" Digicorder["FUNCTION GREEN"] =   "12,12,11,25,11,12,23,25,11,12,23,25,23,25,23,24,12,12,23,12,11,13,11,25,11,3350\r" Digicorder["FUNCTION RED"] =     "11,13,11,24,12,12,23,24,12,12,23,24,23,25,23,24,12,13,23,12,11,25,23,3358\r" Digicorder["FUNCTION YELLOW"] =  "12,12,12,25,11,13,22,25,11,13,22,25,23,24,23,25,22,25,11,12,12,12,23,3364\r" Digicorder["GUIDE"] =            "11,13,11,25,11,12,23,25,11,12,23,25,23,25,11,13,11,13,23,12,11,25,23,24,12,3356\r" Digicorder["HELP"] =             "11,13,11,24,12,12,23,24,12,12,23,24,23,25,11,12,23,25,11,12,23,25,23,3359\r" Digicorder["MENU MAIN"] =        "11,12,12,25,11,13,22,25,11,13,23,25,23,25,11,12,23,25,12,12,11,13,11,13,23,3362\r" Digicorder["MUTE TOGGLE"] =      "11,13,11,25,11,12,23,25,11,12,23,25,22,25,11,13,23,25,11,13,11,13,23,25,11,3347\r" Digicorder["PAUSE"] =            "11,13,11,25,11,12,23,25,11,12,23,25,23,25,23,25,11,13,11,13,11,13,23,24,12,3345\r" Digicorder["PLAY"] =             "11,13,11,25,11,12,23,25,11,12,23,25,23,25,23,25,11,13,23,25,11,13,23,3363\r" Digicorder["POWER TOGGLE"] =     "11,12,12,24,12,12,23,24,12,12,23,24,23,24,12,12,12,12,23,24,23,12,12,24,12,3349\r" Digicorder["PREVIOUS CHANNEL"] = "11,13,11,25,11,12,23,25,11,12,23,25,23,25,11,13,23,13,11,12,11,13,11,25,22,3361\r" Digicorder["RECORD"] =           "11,13,11,24,12,13,23,24,11,13,23,24,23,25,23,25,11,13,11,12,23,25,23,3363\r" Digicorder["REVERSE"] =          "11,13,11,25,11,13,23,25,11,13,23,25,22,25,11,13,23,13,11,13,12,12,11,13,11,25,11,3352\r" Digicorder["STOP"]   =           "11,12,11,24,11,12,23,24,11,12,23,24,22,25,22,24,11,12,11,12,22,12,11,24,12,3297\r" Digicorder["TELETEXT"] =         "11,12,12,24,12,12,23,24,12,12,23,24,23,24,23,25,11,12,23,25,23,24,11,3346\r" Digicorder["VOLUME DOWN"] =      "11,13,11,24,12,13,23,24,11,13,23,24,23,25,11,12,23,25,23,25,11,13,22,3362\r" Digicorder["VOLUME UP"] =        "11,13,12,24,11,13,23,24,11,13,23,25,23,25,11,12,23,25,11,12,23,12,11,25,11,3345\r"                                                                                                                        if command == 'OK' then      command = 'CURSOR ENTER'    end     result = tcp:send(Header .. Digicorder[command])       --log('Result: ' .. result)     rec = tcp:receive()     --log(rec)     tcp:close()                                                                                                                                                         end


As far as the visualisation is concerned: Inkscape and GIMP are your friends...
Reply
#11
You can go one step further with Kodi web interface and stream content to your computer from your Kodi system.
Reply


Forum Jump: