Page 2 of 4
Re: Onkyo receiver <--> Domoticz
Posted: Friday 28 February 2014 15:32
by safi78
mongoose wrote:Safi78: any progress with the speech? I just came across this:
http://www.rmnd.net/speech-recognition- ... d-arduino/
Also back on topic, with the Onkyo receiver, do you have multiple zones? As with Zone 1, I can switch it on and back to being on standby, but Zone 2 I can only switch it on only, but not off/or back to standby... bit strange
cheers
Larry
Hey Larry,
No I don't have multiple Zones, so can't check that, sorry. And for the speech part, I gave up after trying the mentioned speech packages. The sound stuff all seems very buggy (tested it on multiple Rasps). Think I'll just wait until it's fixed I guess.
regards,
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 04 March 2014 8:34
by Keptenkurk
safi78 wrote:I'm really curious what you're gonna use / commands you implement! Let me know

Finally found some time to make use of this.
Apart from removing the Kaku switch power on/off the Onkyo and switching it on by "onkyo PWR01" and off by "onkyo PWR00" i now have some breakfast music.
Swiching off the burglar alarm after i get up will trigger:
- onkyo SLI28 (switch to internet radio - 1.FM smooth Jazz is on preference 1)
onkyo MVL0A (set master volume to a nice background level)
onkyo NCTPLAY (start playing internet radio)
...playing some "no worries" music to start the day
/paul
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 04 March 2014 12:24
by bizziebis
Keptenkurk wrote:safi78 wrote:I'm really curious what you're gonna use / commands you implement! Let me know

Finally found some time to make use of this.
Apart from removing the Kaku switch power on/off the Onkyo and switching it on by "onkyo PWR01" and off by "onkyo PWR00" i now have some breakfast music.
Swiching off the burglar alarm after i get up will trigger:
- onkyo SLI28 (switch to internet radio - 1.FM smooth Jazz is on preference 1)
onkyo MVL0A (set master volume to a nice background level)
onkyo NCTPLAY (start playing internet radio)
...playing some "no worries" music to start the day
/paul
Where did you find the command for starting the internet radio stream? I only came as far as this:
onkyo system-power:on
onkyo volume:32
onkyo input-selector:internet-radio
onkyo internet-radio-preset:1
But then it doesn't start playing
[edit]
Think I found it: onkyo network-usb:play. I'm gonna try it when I'm at home later today. I'n now remotely logged in trough SSH. Chance that the music is already playing at home haha
[/edit]
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 08 March 2014 16:20
by safi78
bizziebis wrote:
[edit]
Think I found it: onkyo network-usb:play. I'm gonna try it when I'm at home later today. I'n now remotely logged in trough SSH. Chance that the music is already playing at home haha
[/edit]
Great! Thanks guys, really usefull
Oh, I found out if you 'select' a stream, sometimes the OSD needs some confirmation(s) in the form of
Because some stream URLS give you several streams to choose from I guess. Maybe that was the problem with the network-usb:play as well.
regards,
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 08 March 2014 16:32
by safi78
And while we are at it:
brings you to the 'Spotify parts' of the machine
I was looking for that earlier, took me a while.
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 08 March 2014 16:59
by safi78
For another 'bad' example (but I don't see another workaround) this starts my 'starred' playlist on Spotify:
Code: Select all
if (devicechanged["Spotify"] == "On") then
os.execute("/usr/local/bin/onkyo system-power:on")
os.execute("/usr/local/bin/onkyo SLI28")
os.execute("/usr/local/bin/onkyo NSV0A")
os.execute("/usr/local/bin/onkyo OSDDOWN")
os.execute("/usr/local/bin/onkyo OSDDOWN")
os.execute("/usr/local/bin/onkyo OSDENTER")
os.execute("/usr/local/bin/onkyo OSDENTER")
end
The SLI28 seems redundant, but you'll have to be "somewhere" in the OSD menu for the NSV command to work
This will also time-out the 'button-press'-event within the domoticz-webinterface, thinking the switch-command failed. Maybe the Dev's can increase (or make it user configurable) the time-out on dummy switches?
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 08 March 2014 17:10
by mbliek
I think when lua is doing his stuff. Domoticz is slowing down and can't be used.
That's why I'm doing all my scripting with bash instead of lua. Only some basic on/off with lua.
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 08 March 2014 17:12
by safi78
mbliek wrote:I think when lua is doing his stuff. Domoticz is slowing down and can't be used.
That's why I'm doing all my scripting with bash instead of lua. Only some basic on/off with lua.
Yeah I figured. But, how would you put all these commands in a bash and then os.execute'em ?
That's taking the same amount of time doesn't it? (I mean, the same timeout will occur, as LUA will wait for the bash to finish, instead of the direct commands?)
Or am I wrong
Re: Onkyo receiver <--> Domoticz
Posted: Saturday 08 March 2014 17:26
by mbliek
I'm using domoticz_main to trigger a bash script.
And then in your bash script called i.e. Onkyo-spotify.sh
You can just put these command. Sorry not at home. Can't really make an example.
You can also just use domoticz_main I guess like this:
Code: Select all
if [ "$device_id" ] = [ "1" ] ; then
if [ "$status" ] = [ "On" ] ; then
exec usr/local/bin/onkyo system-power
exec usr/local/bin/onkyo SLI28
fi
fi
Re: Onkyo receiver <--> Domoticz
Posted: Thursday 26 November 2015 9:45
by jake
I recently found the Wiki about connecting an Onkyo receiver to Domoticz.
At the moment I am working on a little project to automate some steps when I let Kodi (running on a 2nd RPI) plays either video or audio. The Onkyo receiver needs then to switch from 'listening-mode'. I got this partially working, however...
To make the code more robust, I need to verify that both the receiver is "on" and that the "input-selector" is 'BD/DVD' since that is the HDMI port connection that the Kodi RPI is on.
I am able to check the current input by using the provided 'Status' Function:
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
To ask for the current input-selector:
Code: Select all
status_input = onkyo_status('input-selector:query')
When I 'print' the result in the Domoticz log by:
It returns the current input-selector, as expected via the Wiki:
2015-11-26 09:42:29.342 LUA: ('input-selector', ('dvd', 'bd', 'dvd'))
My question is, how can I compare if the current input-selector equals the desired ( ('dvd', 'bd', 'dvd')) one? The ('dvd', 'bd', 'dvd') does not seem to be a STRING, but a table result?
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 08 December 2015 10:43
by mcwieger
Hi all,
I recently started using Domoticz on my Synology NAS, so no experienced user yet, but I'm trying hard to get some things to work. One of them being controlling my receiver.
I managed to install necessary packages and I can control my Onkyo from the command line in Putty. So far so good. Next step is to control it via a script in Domoticz (lua or bash, don't really care, but I''m not very familiar with either). Steps I took:
1. Created a very simple script called 'onkyo_on.lua' doing the following:
commandArray = {}
commandArray[onkyo] = 'onkyo --host 192.168.2.201 --port 60128 system-power=on'
return commandArray
2. Created hardware, Type Dummy
3. Created a switch with hardware of step 2, Switch Type On/Off, Type X10, House Code A, Unit Code 1
4. Added On Action: script://usr/local/domoticz/samplescripts/lua/onkyo_on.lua
I was hoping this would allow me to switch on the receiver, but unfortunately nothing happens when switching on or off. Who knows where this goes wrong? My guess for possible causes:
a. Incorrect script
b. Incorrect script location (also tried directory /usr/local/domoticz/scripts and /usr/local/domoticz/scripts/lua)
c. Incorrect script location referral (I entered full path, should I use a script home folder instead?)
d. Incorrect rights (script appears to have execution rights for all users)
e. Incorrect setup of hardware/device
f. General misconception of this functionality
All help appreciated.
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 08 December 2015 12:24
by proohu01
mcwieger,
I would not use a LUA script for this. Creating a virtual device like you did is oke. Then use the following code in you "domoticz_main" script file. This file is in the root of your scripts folder. If it starts with an underscore "_" rename the file so that it doesn't start with _
Don't forget to change the device_id to match your virtual device. (In my case 24)
Code: Select all
if [ "$device_id" = "24" ] ; then
if [ "$status" = "Off" ] ; then
exec `/usr/local/bin/onkyo --host 192.168.2.201 --port 60128 system-power:standby` &
fi
if [ "$status" = "On" ] ; then
exec `/usr/local/bin/onkyo --host 192.168.2.201 --port 60128 system-power:on` &
fi
fi
FYI, don't forget to chage the path for the onkyo binary in this script if your situation is different. (/usr/local/bin/)
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 08 December 2015 20:52
by mcwieger
Thanks for that! I'll have a try.
What if I do want to use LUA/Bash scripts, did I still follow the right steps?
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 08 December 2015 21:19
by mcwieger
Ok, works using domoticz_main. Had to set rights to 755 to be able to execute.
So if I want to add additional functions (e.g. change input selector or volume), I should add additional switches?
What type is adviced in those cases? On/off is applicable to switch on and off, but how to control the other switch types? E.g. how to control a dimmer, as this could be convenient for volume control?
And if I want to select the input selector, I would like to have more than 2 options, so are there any switch types that have more statuses than on/off?
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 09 December 2015 8:49
by proohu01
I can't help you with that. I just use it as on/off for the Onkyo.
I guess you would have to create on/off devices for each and every function. Perhaps us a scene to switch multiple items?
A virtual dimmer should work for volume control with a proper LUA script. Perhaps someone on the forum has more experience with that.
Re: Onkyo receiver <--> Domoticz
Posted: Sunday 10 January 2016 15:02
by mcwieger
@Jake: I saw you're working on a better integration of your Onkyo in Domoticz. Could you give some more info on your project to get the status and write it to the log?
I'm looking to find a way to resolve the following issue: when I turn on the Onkyo using Domoticz, but turn it off using the regular remote control, the status is not updated and it looks like the receiver is still on.
Possible solution would be:
1. Create a switch to query Onkyo status
2. Write the status to this switch
3. Run a blockly script every x minutes that adjusts the actual Onkyo On/Off switch accordingly
Obviously, step 2 is the hard part. Any ideas how to do that? Or another way to resolve the issue?
Re: Onkyo receiver <--> Domoticz
Posted: Wednesday 13 January 2016 15:12
by proohu01
The recent addition of the script editor in Domoticz triggered me to put all my LUA scripts into the database. I wanted to have the Onkyo logic in there also. I re-wrote a LUA script with some input from this page:
https://www.domoticz.com/wiki/Control_Onkyo
Basically in now have two LUA scripts in the Domoticz database. One is able to turn on or off the receiver. The other queries the receiver so that the correct power state is always visible in Domoticz.
It is probably not the best LUA scripting out there but
I just wanted to share my script. I hope it is of any use to others...
Code: Select all
--[[
Script name : Onkyo-Set
Trigger type : DEVICE
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 chages the power state of an Onkyo receiver by switching a virtual dummy switch in Domoticz.
--]]
-- 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 = {}
-- function to change settings Onkyo receiver
function onkyo_change(command)
os.execute('/usr/local/bin/onkyo --host '..onkyohostip..' --port '..onkyohostport..' '..command)
end
-- Switch the Onkyo receiver on/off with the dummy switch
if devicechanged[virt_onkyo]=="On" then
onkyo_change('system-power:on')
print_color('GREEN', 'The Onkyo receiver has been switched ON physically, or by dummy Domoticz swtich')
else
if devicechanged[virt_onkyo]=="Off" then
onkyo_change('system-power:standby')
print_color('GREEN', 'The Onkyo receiver has been switched OFF physically, or by dummy Domoticz swtich')
end
end
return commandArray
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
Re: Onkyo receiver <--> Domoticz
Posted: Thursday 14 January 2016 22:55
by jake
mcwieger wrote:@Jake: I saw you're working on a better integration of your Onkyo in Domoticz. Could you give some more info on your project to get the status and write it to the log?
I'm looking to find a way to resolve the following issue: when I turn on the Onkyo using Domoticz, but turn it off using the regular remote control, the status is not updated and it looks like the receiver is still on.
Possible solution would be:
1. Create a switch to query Onkyo status
2. Write the status to this switch
3. Run a blockly script every x minutes that adjusts the actual Onkyo On/Off switch accordingly
Obviously, step 2 is the hard part. Any ideas how to do that? Or another way to resolve the issue?
My project scope is to let the Onkyo receiver follow my use of Kodi media player. What works at the moment is:
I choose an album with the Yatse app, connected to a 2nd RPI running Kodi (Xbian).
The script will do the following
- detect a devicechange on the Kodi Media player from 'on' to 'audio' (or 'video')
- Domoticz changes the Onkyo input to the HDMI input for the Kodi player
Result: if the receiver is off, it will be turned on to the right input, if it was already on, it will just change input
- Last used listening mode (stored in a Domoticz variable, one for 'audio' one for 'video') will be made active
- Detect a devicechange from 'audio' to 'video' or vice versa or to 'on'
- Store the actual 'listening mode' in the Domotiz variable
Problems I run into:
-Timing, timing, timing:
Command order like:
- Detect 'Audio' --> SET to 'pause'
- Turn Onkyo on
- wait 2 seconds (to let the Onkyo boot, it seems to miss the command completely during boot
- change listening mode
- Set 'play'
are not executed on time, or not at all. The Kodi media player is not always put to 'pause', the 2 second delay will not delay the next command, but seems to be executed somewhat later etc. Very strange
- 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
- 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?
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 19 January 2016 21:18
by mcwieger
proohu01 wrote:The other queries the receiver so that the correct power state is always visible in Domoticz.
I'm trying to get the second script to work. Since I'm not using a RPI but a Synology, I slightly changed it to reflect the correct path of the Onkyo control app. Placed it in the /scripts/lua folder, gave execute rights and restarted Domoticz. It doesn't update the status, however.
Any idea what the issue could be? I use the name of the switch, not the ID. Switch is type X10 (On/Off) and controlled via domoticz_main.
Re: Onkyo receiver <--> Domoticz
Posted: Tuesday 19 January 2016 21:49
by bizziebis
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.