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,
19.04.2017, 05:45 (This post was last modified: 19.04.2017, 05:49 by gjniewenhuijse.)
(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
the library
Code:
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 udp server to receive incoming send requests
if not sendServer then
sendServer = socket.udp()
sendServer:setsockname('*', sendPort)
sendServer:settimeout(0.1)
end
-- 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:
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
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.
(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.
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?
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:
--[[
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)