Page 3 of 4
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 20 January 2016 2:38
by mongoose
Hi,
Just brought a synology NAS and so getting everything migrated from my Rpi.
Just a question of how to install the onkyo functionality on the NAS.
On the Pi I SSH in and did the:
sudo apt-get install python-setuptools
sudo easy_install onkyo-eiscp
But I assume it works a bit different on the NAS.
cheers
Larry
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 20 January 2016 21:35
by mcwieger
You can use easy_install or pip on Synology.
Please check if you have pip installed (e.g. using Putty). If not, install the Python package first in the package center.
Use pip install onkyo-eiscp to install the package. You can now find it in /usr/bin.
An alternative is to use the php script which is available here:
https://www.domoticz.com/wiki/Control_Onkyo
Just place this on any location on your Synology (e.g. create folder /web/onkyo/ and place the script there. You can use it immediately via the command line or in a script using curl (should also be installed on your Synology).
The only thing with the script is that not all commands are in it, but you can very easily modify the script to your needs, using the Excel document with EISCP commands you can find in this topic. Let me know if you need the version I created.
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 20 January 2016 21:36
by mcwieger
bizziebis wrote:I had that same problem until I manually flipped the switch once. From that moment on the script worked. Don't know if you have something like that going on.
Tried that, but doesn't do the trick...
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 20 January 2016 21:42
by mcwieger
jake wrote:
- Querying listening modes for instance, returns a different string then the string needed to SET the listening mode (for instance: Query result is 'Video 6' 'PC', while setting it to that same input, 'pc' is sufficient. I started a new topic for that: how can can make a sort of table that compares query results, with SET commands?
http://www.domoticz.com/forum/viewtopic.php?t=9854 Unfortunately no answers yet and as a mechanical engineer, I can't dream it up myself
Please look at Proohu01's topic above, it looks like the answer is there (using egrep).
jake wrote:
- The Onkyo status needs to be pulled, while Onky itself is pushing it's status over the network:
I have the ONKYO app installed on my phone. When this app is running and I change input/volume/listening mode with my std IR remote, the app is updated immediately. My conclusion is that therefore the receiver must be pushing / publishing it's status changes all the time. How to catch these results?
The answer seems to be in the second script Proohu01 provided, but it doesn't work for me yet.
Re: Onkyo receiver <--> Domoticz
Posted: Thursday 21 January 2016 7:58
by proohu01
Creating the LUA script was a bit of trial and error for me too. I'm not a programmer. Coding is just not my thing. (to bad because there is so much I would like to create)
So the best thing to do is to try the commands at the command line and have a look at the results.
Eg. This command should give an output of just
on or
standby
Code: Select all
/usr/local/bin/onkyo --host 192.168.x.x --port 60128 system-power:query | egrep "standby|on" -o
Try putting some extra "print" lines in there to see the results at different point of the script. For example: print(result)
I find it better to try my LUA scripts in the scripts folder instead of the new Script Editor (database) because is gives me more (better) output in the log. When it is working there, it should also work when you paste it in the Domoticz script editor.
Not much else to say really. It is working here just the way I posted it.
Re: Onkyo receiver <--> Domoticz
Posted: Friday 22 January 2016 19:46
by mvveelen
proohu01 wrote:
Code: Select all
--[[
Script name : Onkyo-Get
Trigger type : TIME
Created by proohu01 https://www.domoticz.com/forum/viewtopic.php?f=17&t=1491&start=20
Also have a look at https://www.domoticz.com/wiki/Control_Onkyo
This LUA script will try to determine the power state of an Onkyo receiver. By default, it runs ones every minute.
A virtual dummy switch in Domoticz will reflect the correct power state when a change in power state is discovered.
--]]
-- Set some local variables
local onkyohostip = '192.168.1.16' -- IP address of the Onkyo
local onkyohostport = '60128' -- Onkyo port number. Default is 60128
local virt_onkyo = 'Receiver Livingroom' -- The name of the dummy switch in Domoticz used as Onkyo device
local logging = 'true' -- Set to true or false to get some (color) logging
-- YOU SHOULD PROBABLY LEAVE EVERYTHING AS IS BELOW THIS POINT
-- Function for more color during logging
function print_color(color, message)
if (logging == "true") then
print('<b style="color:'..color..'">'..message..'</b>')
-- Usage example: print_color('RED', 'Hello world')
-- Possible colors are...
-- GREEN | RED | BLUE | YELLOW | ORANGEY| GOLD | GOLD2 | GREY | WHITE | SUBWHITE | MAGENTA
-- LIGHTRED | LIGHTBLUE | TORQUISEBLUE | SPRINGGREEN | GREENYELLOW | PURPLE | SEXHOTPINK
-- CHOCOLATE | CYAN | IVORY | LIGHTYELLOW | SEXGREEN | SEXTEAL | SEXPINK | SEXBLUE
end
end
commandArray = {}
-- Create a temp file. Execute and parse output to temp file. Read the file into a string. Delete the temp file.
n = os.tmpname ()
os.execute ('/usr/local/bin/onkyo --host '..onkyohostip..' --port '..onkyohostport..' system-power:query | egrep "standby|on" -o > ' .. n)
for line in io.lines (n) do
result = line
end
os.remove (n)
-- check if the value is valid or has some weird reading
if (result == 0 or result == nil) then
print_color('RED', 'Input error. Value is 0 or nil. Skipping this reading')
return commandArray
else
if (result == "standby") and otherdevices[virt_onkyo] == 'On' then
print_color('GREEN', 'Now powering off the Onkyo...')
commandArray[virt_onkyo]='Off'
end
if (result == "on") and otherdevices[virt_onkyo] == 'Off' then
print_color('GREEN', 'Now powering on the Onkyo...')
commandArray[virt_onkyo]='On'
end
end
return commandArray
I tried to edit this file for my Synology and the tmp files are written, but the values aren't read AND the files aren't deleted after the reading. Too bad. Maybe a simple ping script will do the trick to see if the device is ON or OFF.....
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 02 February 2016 11:57
by mcwieger
proohu01 wrote:
Try putting some extra "print" lines in there to see the results at different point of the script. For example: print(result)
Maybe more general LUA questions, but:
- how can I see the script is actually executed every x minutes?
- where can I expect to see the print lines? In the general Domoticz log?
- should I create a switch (or something else) to write the output to? I also use the Kodi app as an example, which displays the current movie that is played. Do I need to create something similar to display the current status of the Onkyo receiver?
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 02 February 2016 12:19
by proohu01
- how can I see the script is actually executed every x minutes?
In the domoticz log. You don't see it if you are using the "events" (aka script editor). You will see it if you use the old lua file based method.
- where can I expect to see the print lines? In the general Domoticz log?
Yep.
- should I create a switch (or something else) to write the output to? I also use the Kodi app as an example, which displays the current movie that is played. Do I need to create something similar to display the current status of the Onkyo receiver?
The script I posted only switches a virtual switch within Domoticz on of off. So you should create at least a virtual switch and use the name of that switch in the LUA code.
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 02 February 2016 12:22
by Westcott
A time script will show in the log (Setup->Log) something like -
2016-02-02 11:10:00.309 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_yourscriptname.lua
And yes, the print() statements will also show up in the log.
You can combine text and values in a single print by concatenating them with a .. e.g
print('Value = ' .. variableName)
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 02 February 2016 20:29
by mcwieger
Thanks guys.
I didn't use the right naming convention (script_time_ as prefix).
Works now, thanks!
Re: Onkyo receiver <--> Domoticz
Posted: Thursday 10 March 2016 22:51
by Justintime
Hello,
I am trying to set my temporary subwoofer level on my Onkyo receiver with the Lua script.
But no matter what i try it doesn't set a value. On the device ISCP list my device can be changed with direct dB values.
This is what i have at the moment:
Code: Select all
if devicechanged['Sub']=="On" then
onkyo_change('subwoofer-temporary-level:-15')
else
if devicechanged['Sub']=="Off" then
onkyo_change('subwoofer-temporary-level:8')
end
end
This is what i have found in the eiscp commands list:
Code: Select all
'name': 'subwoofer-temporary-level',
'values': OrderedDict([((-15,
0,
12), {'description': 'sets Subwoofer Level -15dB - 0dB - +12dB', 'name': '15db-0db-12db'}),
('UP', {'description': 'LEVEL + Key', 'name': 'up'}),
('DOWN', {'description': u'LEVEL \u2013 KEY', 'name': 'down'}),
('QSTN', {'description': 'gets the Subwoofer Level', 'name': 'query'})])}),
Am i doing something wrong?
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 12 March 2016 9:47
by jake
What happens when you type the command right in the rpi prompt? That way you can see the answer from the Onkyo.
Verstuurd vanaf mijn Transformer TF101 met Tapatalk
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 12 March 2016 12:45
by mvveelen
I'm using the "second" script for showing the status of the receiver in Domoticz.
script_time_onkyostatus.lua
Code: Select all
--[[
Script name : Onkyo-Get
Trigger type : TIME
Created by proohu01 https://www.domoticz.com/forum/viewtopic.php?f=17&t=1491&start=20
Also have a look at https://www.domoticz.com/wiki/Control_Onkyo
This LUA script will try to determine the power state of an Onkyo receiver. By default, it runs ones every minute.
A virtual dummy switch in Domoticz will reflect the correct power state when a change in power state is discovered.
--]]
-- Set some local variables
local onkyohostip = '192.168.0.115' -- IP address of the Onkyo
local onkyohostport = '60128' -- Onkyo port number. Default is 60128
local virt_onkyo = 'Onkyo receiver' -- The name of the dummy switch in Domoticz used as Onkyo device
local logging = 'true' -- Set to true or false to get some (color) logging
-- YOU SHOULD PROBABLY LEAVE EVERYTHING AS IS BELOW THIS POINT
-- Function for more color during logging
function print_color(color, message)
if (logging == "true") then
print('<b style="color:'..color..'">'..message..'</b>')
-- Usage example: print_color('RED', 'Hello world')
-- Possible colors are...
-- GREEN | RED | BLUE | YELLOW | ORANGEY| GOLD | GOLD2 | GREY | WHITE | SUBWHITE | MAGENTA
-- LIGHTRED | LIGHTBLUE | TORQUISEBLUE | SPRINGGREEN | GREENYELLOW | PURPLE | SEXHOTPINK
-- CHOCOLATE | CYAN | IVORY | LIGHTYELLOW | SEXGREEN | SEXTEAL | SEXPINK | SEXBLUE
end
end
commandArray = {}
-- Create a temp file. Execute and parse output to temp file. Read the file into a string. Delete the temp file.
n = os.tmpname ()
os.execute ('/usr/bin/onkyo --host '..onkyohostip..' --port '..onkyohostport..' system-power:query | egrep "standby|on" -o > ' .. n)
for line in io.lines (n) do
result = line
end
os.remove (n)
-- check if the value is valid or has some weird reading
if (result == 0 or result == nil) then
print_color('RED', 'Input error. Value is 0 or nil. Skipping this reading')
return commandArray
else
if (result == "standby") and otherdevices[virt_onkyo] == 'On' then
print_color('GREEN', 'I see that the Onkyo receiver is OFF, now setting the dummy switch to OFF...')
commandArray[virt_onkyo]='Off'
end
if (result == "on") and otherdevices[virt_onkyo] == 'Off' then
print_color('GREEN', 'I see that the Onkyo receiver is ON, now setting the dummy switch to ON...')
commandArray[virt_onkyo]='On'
end
end
return commandArray
Unfortunately it takes about a minute to alter the status, but that isn't really a big problem. Now I wanted to be able to use the Dummy switch to control the Onkyo too, so I could manage the Onkyo by using Domoticz.
So I added the following lines to the ON and OFF commands (IP Synology = 192.168.0.124):
ON
Code: Select all
http://192.168.0.124/onkyo/onkyo.php?command=PWR¶ms=01
OFF
Code: Select all
http://192.168.0.124/onkyo/onkyo.php?command=PWR¶ms=00
For this I had to upload a PHP script to the web folder on my Synology:
onkyo.php
Code: Select all
<?php
$command = $_GET['command'];
$params = $_GET['params'];
$hostname = '192.168.0.115';
$port = 60128;
switch ($command)
{
case 'PWR':
case 'AMT':
case 'SLI':
case 'TUN':
$message = '!1' . $command . $params;
break;
case 'MVL':
if ($params > 60)
exit(1);
$message = '!1' . $command . strtoupper(str_pad(dechex($params), 2, '0', STR_PAD_LEFT));
break;
default:
exit(1);
}
print $message;
$fp = pfsockopen($hostname, $port);
$packet = "ISCP\x00\x00\x00\x10\x00\x00\x00" . chr(strlen($message) + 1) . "\x01\x00\x00\x00" . $message . "\x0D";
fwrite($fp, $packet);
fclose($fp);
?>
So far I think (...) it all works.
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 12 March 2016 21:30
by Justintime
When i give commands in the terminal i get this:
Code: Select all
pi@raspberrypi ~ $ onkyo subwoofer-temporary-level:12
Error: "subwoofer-temporary-level" is not a valid command in zone "main"
Tried the PHP version. That one is working......uhhhh half haha
I can get the "-" Subwoofer level in the reciever but not the "+" Values.
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 15 March 2016 20:15
by Justintime
Can someone test this feature for me??
Re: RE: Re: Onkyo receiver <--> Domoticz
Posted: Thursday 17 March 2016 23:01
by jake
Justintime wrote:Can someone test this feature for me??
I tried (Onkyo ...535), but without success. This is what I got reported back:
pi@domoticz-pi ~ $ onkyo subwoofer-temporary-level:12
Traceback (most recent call last):
File "/usr/local/bin/onkyo", line 9, in <module>
load_entry_point('onkyo-eiscp==0.9.1', 'console_scripts', 'onkyo')()
File "/usr/local/lib/python2.7/dist-packages/onkyo_eiscp-0.9.1-py2.7.egg/eiscp/script.py", line 129, in
run
sys.exit(main() or 0)
File "/usr/local/lib/python2.7/dist-packages/onkyo_eiscp-0.9.1-py2.7.egg/eiscp/script.py", line 115, in
main
iscp_command = command_to_iscp(command)
File "/usr/local/lib/python2.7/dist-packages/onkyo_eiscp-0.9.1-py2.7.egg/eiscp/core.py", line 209, in co
mmand_to_iscp
return '%s%s' % (prefix, value)
UnboundLocalError: local variable 'value' referenced before assignment
When I did the query, it worked well:
pi@domoticz-pi ~ $ onkyo subwoofer-temporary-level:query
<eISCP(TX-NR535) 192.168.1.53:60128>: SWLQSTN
('subwoofer-temporary-level', '00')
Re: RE: Re: RE: Re: Onkyo receiver Domoticz
Posted: Friday 18 March 2016 8:24
by Justintime
jake wrote:Justintime wrote:Can someone test this feature for me??
I tried (Onkyo ...535), but without success. This is what I got reported back:
pi@domoticz-pi ~ $ onkyo subwoofer-temporary-level:12
Traceback (most recent call last):
File "/usr/local/bin/onkyo", line 9, in <module>
load_entry_point('onkyo-eiscp==0.9.1', 'console_scripts', 'onkyo')()
File "/usr/local/lib/python2.7/dist-packages/onkyo_eiscp-0.9.1-py2.7.egg/eiscp/script.py", line 129, in
run
sys.exit(main() or 0)
File "/usr/local/lib/python2.7/dist-packages/onkyo_eiscp-0.9.1-py2.7.egg/eiscp/script.py", line 115, in
main
iscp_command = command_to_iscp(command)
File "/usr/local/lib/python2.7/dist-packages/onkyo_eiscp-0.9.1-py2.7.egg/eiscp/core.py", line 209, in co
mmand_to_iscp
return '%s%s' % (prefix, value)
UnboundLocalError: local variable 'value' referenced before assignment
When I did the query, it worked well:
pi@domoticz-pi ~ $ onkyo subwoofer-temporary-level:query
<eISCP(TX-NR535) 192.168.1.53:60128>: SWLQSTN
('subwoofer-temporary-level', '00')
Thanks for testing out.
QSTN command reports back correct to me too. Only the digits won't respond to -A B C etc etc.
Could be a nice feature combined with Harmony to crank up the sub a bit when watching movies.
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 25 May 2016 14:10
by Keptenkurk
For your information:
Loss of networking and/or audio on Onkyo:
Having enjoyed interfacing Domoticz to my Onkyo NR TX414 for over 2 years my Onkyo unit started to show trouble: The network interface would go down (and come up only after a power cycle). Upgrading firmware to the latest did not help. Problems got worse when audio was lost too.
Started googling the issue an it appears that it relates to a defective board which will be repaired for free, even outside the warranty period.
Check
here if your unit is impacted.
This Warranty Extension Program runs until dec 31st, 2018.
Onkyo did a pickup and return two weeks ago through UPS and I got my repaired receiver back after a week. All for free! The unit works again as before!
Great service!!
/paul
Re: RE: Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 25 May 2016 17:11
by jake
Keptenkurk wrote:For your information:
Loss of networking and/or audio on Onkyo:
Having enjoyed interfacing Domoticz to my Onkyo NR TX414 for over 2 years my Onkyo unit started to show trouble: The network interface would go down (and come up only after a power cycle). Upgrading firmware to the latest did not help. Problems got worse when audio was lost too.
Started googling the issue an it appears that it relates to a defective board which will be repaired for free, even outside the warranty period.
Check
here if your unit is impacted.
This Warranty Extension Program runs until dec 31st, 2018.
Onkyo did a pickup and return two weeks ago through UPS and I got my repaired receiver back after a week. All for free! The unit works again as before!
Great service!!
/paul
Thanks for sharing
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 25 May 2016 22:40
by jake
I have Kodi installed on a 2nd RPI and I have Kodi connected as a device in Domoticz.
This is what I use to automatically switch on the Onkyo receiver at the time I select a video or audio through my phone/tablet Yatse app:
Code: Select all
local onkyohostip = '192.168.1.33' -- IP address of the Onkyo
local onkyohostport = '60128' -- Onkyo port number. Default is 60128
-- function to change settings receiver
function onkyo_change(command)
--os.execute('/usr/local/bin/onkyo '..command)
os.execute('/usr/local/bin/onkyo --host '..onkyohostip..' --port '..onkyohostport..' '..command)
end
-- turn on the receiver when Kodi starts playing and desktop is not running
if (devicechanged['Kodi Media Center']=="Audio" or devicechanged['Kodi Media Center']=="Video") then
onkyo_change(Onkyo_Input_Selector_BD)
--Check if Onkyo device switch in Domoticz is 'Off' now and update it's status to 'On'
if otherdevices ['Onkyo TX-NR535']=='Off' then
commandArray ['Onkyo TX-NR535']="On"
end
end
When the Onky receiver doesn't receive any input for 20 minutes, it turns off automatically. However, since the RPI with Kodi is always on and sends the HDMI signal, the receiver won't turn off. I therefore created my own 'turn-off' script and used a uservariable to determine the delay (even more fancy than the standard 'hard coded' 20 minutes of Onky itself)
Code: Select all
local Onkyo_Input_BD_uservar = "('input-selector', ('dvd', 'bd', 'dvd'))"
-- turn the receiver on/off with dummy switch 'Onkyo TX-NR535 '
if devicechanged['Onkyo TX-NR535']=="On" then
onkyo_change('system-power:on')
else
if devicechanged['Onkyo TX-NR535']=="Off" then
onkyo_change('system-power:standby')
end
end
-- turn off the receiver after Kodi sits 'idle' for x many minutes
if (otherdevices['Kodi Media Center'] == 'On' and otherdevices['Onkyo TX-NR535'] == 'On') then
if timedifference(otherdevices_lastupdate['Kodi Media Center']) > uservariables ['Onkyo_idle_delay'] then
status = onkyo_status('input-selector:query')
if status[2]==Onkyo_Input_BD_uservar then
commandArray['Onkyo TX-NR535']='Off'
print ("Onkyo receiver is turned off after ".. uservariables ['Onkyo_idle_delay'].." seconds since last item was played on Kodi media player")
end
end
end
I also write to a uservariable the current listening mode at the time that the Kodi device status changes to 'Pause' or 'Stop'. I (want to) use that to automatically update the listening mode when I switch from audio to video (or vice versa), because for audio I usually prefer 5-Ch-Audio and for video Theather-Dimensional.
Code: Select all
-- function to get information from receiver
function onkyo_status(command)
local result = {}
local output = io.popen ('onkyo '..command)
for line in output:lines() do
table.insert(result, line)
end
output:close()
return result
end
--Update listeningmode at Paused or Stop, only when current listeningmode is changed from uservariable
if devicechanged['Kodi Media Center']== ("Paused" or "On") then
Onkyo_Listeningmode = onkyo_status ('listening-mode:query')
if uservariables ['KodiStatus']=="Audio" then
if Onkyo_Listeningmode[2]~= uservariables ['KodiAudioListeningMode'] then
commandArray ['Variable:KodiAudioListeningMode'] = Onkyo_Listeningmode[2]
print ('Wijzig KodiAudioListeningMode naar: '.. Onkyo_Listeningmode[2])
end
elseif uservariables ['KodiStatus']=="Video" then
if Onkyo_Listeningmode[2]~= uservariables ['KodiVideoListeningMode'] then
commandArray ['Variable:KodiVideoListeningMode'] = Onkyo_Listeningmode[2]
print ('Wijzig KodiVideoListeningMode naar: '.. Onkyo_Listeningmode[2])
end
end
end
The next section doesn't work 100%. I want to set the listeningmode to whatever I stored in the uservariable last time I used Kodi.
I have an issue with the lastupdate field. I want to set the Listening mode 3 seconds after Kodi starts playing. This to allow the Onkyo receiver to power-on and it is ready to receive the next command. However, I don't understand when the 'lastupdate' command is fired
Code: Select all
-- function to extract the Onkyo 'set' command out of a 'query' command.
-- example:
-- onkyo input-selector:query results in ('input-selector', ('dvd', 'bd', 'dvd'))
-- the onkyo set command is just 'dvd' or 'bd' (to set it: onkyo input-selector:bd)
function queryTOset (query_mode,query_result)
local queryToset_result
-- check if query_mode is part of query_result
l = string.find (query_result, query_mode,1,true) --print ('L = ' ..l)
--l = string.match ("('listening-mode', 'direct')", "listening-mode") print ('L = ' ..l)
if l == nil then
print ('did not find query mode in query result')
print ('query_mode is: ' ..query_mode)
print ('query_result is: ' ..query_result)
query_result = onkyo_status(query_mode ..':query') print ('no valid query mode found, will use current status of receiver')
query_result = query_result[2]
end
-- query_result starts with "('" (2 characters), followed by the query-mode, followed by "', '" or "', (" (4 characters) Together this is 6 characters before the 'set' string' starts
querylength = string.len(query_mode)+ 6 -- for 'input-selector' it will be 14+6=20
-- reduce query_result string and start right away with the first set command, which starts with a ' or ( sign
queryToset_result = string.sub (query_result,querylength)
-- find out how many characters the first set command has. example: 'bd' is altogether 4 characters. Find the 1st ' sign
start_set = string.find (queryToset_result,"\'", 1) print ('start of set command for ' ..query_mode .. ' = '.. start_set ..' character')
setlength = string.find (queryToset_result,"\'", start_set+1) print ('length of set command for ' ..query_mode .. ' = '.. setlength - start_set + 1 ..' character')
-- extract first 'set' command out of string
queryToset_result = string.sub (queryToset_result,start_set,setlength) print ('set command for ' ..query_mode ..' = ' ..queryToset_result)
return queryToset_result
end
--Update the listeningmode, if necesssary, after Kodi started playing with a 3 seconds delay (to allow the 'turn Onkyo' on command to run. The receiver doesn't
--receive commands when they are sent too close to eachtother.
if (timedifference(otherdevices_lastupdate['Kodi Media Center']) > 3 and timedifference(otherdevices_lastupdate['Kodi Media Center']) < 15) then
print('Test kodi last update caught')
if (devicechanged['Kodi Media Center']=="Audio" or devicechanged['Kodi Media Center']=="Video") then
--Request current listening mode from receiver
Onkyo_Listeningmode = onkyo_status ('listening-mode:query')
--Check if current listening mode matches the one stored in the uservariable
if (Onkyo_Listeningmode[2] ~= uservariables ['KodiAudioListeningMode'] and otherdevices['Kodi Media Center']=="Audio") then
--Listening mode doesn't match up: extract 'set' command out of given query result with the following function:
new_listening_mode = queryTOset ('listening-mode', uservariables ['KodiAudioListeningMode'])
print ('new listening mode = ' ..new_listening_mode)
onkyo_change('listening-mode:' ..new_listening_mode)
elseif (Onkyo_Listeningmode[2] ~= uservariables ['KodiVideoListeningMode'] and otherdevices['Kodi Media Center']=="Video") then
--Listening mode doesn't match up: extract 'set' command out of given query result with the following function:
new_listening_mode = queryTOset ('listening-mode', uservariables ['KodiVideoListeningMode'])
print ('new listening mode = ' ..new_listening_mode)
onkyo_change('listening-mode:' ..new_listening_mode)
end
end
end