Page 1 of 1
[Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Tuesday 10 February 2015 12:12
by lmolenaar
Could someone advise what the best approach is for adding a new hardware device?
I have a Yamaha receiver, for which an automation library has already been created by somebody else: (
link).
This library supports:
- checking/setting the on/of state
- checking/setting the volume value
- checking/setting the active input
- retrieving a list of available inputs
Do I need to write a script that contains functions for all of the features above that can be called/integrated in Domoticz? e.g. being able to turn the receiver on/of, change the input, set the volume
e.g. the following .py script:
Code: Select all
import rxv
receivers = rxv.find()
print(receivers)
rx = receivers[0]
print("On ? %s" % (rx.on))
print("Volume ? %s" % (rx.volume))
print("Input ? %s" % (rx.input))
Returns:
Code: Select all
[<RXV model_name="RX-V775" ctrl_url="http://192.168.0.14:80/YamahaRemoteControl/ctrl" at 0x2a29b10>]
On ? False
Volume ? -30.5
Input ? HDMI2
Re: [Advise needed] How to add receiver/amp to Domoticz?
Posted: Friday 31 July 2015 16:56
by waggie
I'm also searching for this. I would like to have a switch, where I also could put some text in it. I tried to rename de switch (to put status info in it), I tried switch type mediaplayer, which only supports a level. So I'm lost now. The only thing could help is a virtual sensor of type text, but that one is a littlebit simple. A switch would be most nice to have with a text part.
Re: [Advise needed] How to add Yamaha receiver/amp to Domoti
Posted: Sunday 13 December 2015 23:26
by JCLB
I've currently achieved the 3 following value reading:
-On or Off (dummy switch)
-Volume (dummy Sound Level)
-Input (dummy text)
it's a loop running 30 times with 10 seconds sleep.
So I start it every 5 min in CRON
*/5 * * * * /home/pi/domoticz/scripts/YamahaRXV.py >/dev/null 2>&1
This avoid to reload the script and libraries every time.
A lots of other options are available from phone app, like choosing DSP and so on. I don't know if it's setup in rxv library.
I will see if I can make another script to send commands but I managed to manually set volume and input with rxv library.
I still think a good logitech harmony hub is a better choice for sending commands.
YamahaRXV.py
Code: Select all
#!/usr/bin/python
import rxv
import time
from urllib2 import urlopen
# change these values
yamaha = "http://192.168.0.190:80"
domoticz = "http://127.0.0.1:8080"
idx_Volume = 6
idx_Input = 7
idx_On = 8
# End
rx = rxv.RXV(str(yamaha)+"/YamahaRemoteControl/ctrl", "RX-V671")
LastVolume = 100
LastInput = "none"
LastState = "unknown"
i = 0
numbers = []
while i < 30:
numbers.append(i)
i = i + 1
Volume = rx.volume
Input = rx.input
State = rx.on
# Volume
if Volume != LastVolume:
response = urlopen(domoticz+'/json.htm?type=command¶m=udevice&idx='+str(idx_Volume)+'&nvalue=0&svalue='+str(Volume))
response.read()
# Input
# List your custom names with if, elif
if Input != LastInput:
if Input == "HDMI2":
InputR="TV"
else:
InputR=Input
response = urlopen(domoticz+'/json.htm?type=command¶m=udevice&idx='+str(idx_Input)+'&nvalue=0&svalue='+str(InputR))
response.read()
# STATE ON
if State != LastState:
if State == True:
print('On')
StateR="On"
else:
print('Off')
StateR="Off"
response = urlopen(domoticz+'/json.htm?type=command¶m=switchlight&idx='+str(idx_On)+'&switchcmd='+str(StateR))
response.read()
LastVolume = Volume
LastInput = Input
LastState = State
time.sleep(10)
print('end')
Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Wednesday 23 March 2016 11:09
by spyseiko
Will this also work on the RX-A series ?
Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Thursday 31 March 2016 20:33
by assenzuid
On a RX-A serie I get only the Volume status, other status is not updated.
Within python below commands works good and also able to manage switch input from AV1 to AV4 or to turn off or on the reveiver.
Code: Select all
>>> import rxv
>>> receivers = rxv.find()
>>> print(receivers)
>>> print(receivers)
[<RXV model_name="RX-A1010" ctrl_url="http://192.168.xxx.xxx:80/YamahaRemoteControl/ctrl" at 0xb6cc9050L>]
>>> rx.on = True
>>> rx.volume
-60.5
>>> rx.inputs()
{'USB': 'USB', 'AV4': None, 'AV5': None, 'AV6': None, 'AV7': None, 'AV1': None, 'AV2': None, 'AV3': None, 'AUDIO2': None, 'Napster': 'Napster', 'NET RADIO': 'NET_RADIO', 'AUDIO4': None, 'AUDIO1': None, 'UAW': None, 'AUDIO3': None, 'PC': 'PC', 'PHONO': None, 'V-AUX': None, 'MULTI CH': None, 'TUNER': 'Tuner', 'iPod (USB)': 'iPod_USB', 'iPod': 'iPod', 'Bluetooth': 'Bluetooth'}
>>> rx.input = "AV1"
>>> rx.input
'AV1'
>>> rx.input = "AV4"
>>> rx.input
'AV4'
>>> rx.on = False
>>>
Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Thursday 21 April 2016 8:54
by spyseiko
Think i just have to try it.
Will report back after testing.
Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Wednesday 05 October 2016 17:46
by lupo2a
I modified the code in order to get the initial status of the virtual devices in Domoticz so to send the Json commands only if the values readed within the while cycle changed.
In this way the event firing in Domoticz when the script is runned by cron is avoided
Code: Select all
#!/usr/bin/python
import rxv
import time
import sys
import json
from urllib2 import urlopen
#print "Start program: %s" % time.ctime()
# change these values
yamaha = "http://192.168.1.80:80"
domoticzurl = "http://127.0.0.1:8080"
idx_Volume = 14
idx_Input = 15
idx_On = 12
# Get yamaha status in domoticz
response = urlopen(domoticzurl+'/json.htm?type=devices&rid='+str(idx_On))
string = response.read()
json_obj = json.loads(string)
if json_obj["status"] == "OK":
for i, v in enumerate(json_obj["result"]):
if json_obj["result"][i]["Status"] == "On":
LastState = True
if json_obj["result"][i]["Status"] == "Off":
LastState = False
#print("Acceso: " +str(LastState))
#Get yamaha volume in Domoticz
response = urlopen(domoticzurl+'/json.htm?type=devices&rid='+str(idx_Volume))
string = response.read()
json_obj = json.loads(string)
if json_obj["status"] == "OK":
for i, v in enumerate(json_obj["result"]):
VolumeStr = json_obj["result"][i]["Data"]
Vol = VolumeStr.split(" ")
LastVolume = float(Vol[0])
#print("Volume:" + str(LastVolume))
#Get yamaha input in domoticz
response = urlopen(domoticzurl+'/json.htm?type=devices&rid='+str(idx_Input))
string = response.read()
json_obj = json.loads(string)
if json_obj["status"] == "OK":
for i, v in enumerate(json_obj["result"]):
LastInput = json_obj["result"][i]["Data"]
#print("Input: " + str(LastInput))
rx = rxv.RXV(str(yamaha)+"/YamahaRemoteControl/ctrl", "RX-V577")
i = 0
numbers = []
while i < 29:
#print "Inizio loop: %d " % i
numbers.append(i)
i = i + 1
Volume = rx.volume
Input = rx.input
State = rx.on
# Volume
if Volume != LastVolume:
#print("LastVolume: "+str(LastVolume))
#print("Volume: "+str(Volume))
response = urlopen(domoticzurl+'/json.htm?type=command¶m=udevice&idx='+str(idx_Volume)+'&nvalue=0&svalue='+str(Volume))
response.read()
# Input
# List your custom names with if, elif
if Input != LastInput:
#print("LastInput: "+str(LastInput))
#print("Input: "+str(Input))
if Input == "HDMI2":
InputR="TV"
else:
InputR=Input
response = urlopen(domoticzurl+'/json.htm?type=command¶m=udevice&idx='+str(idx_Input)+'&nvalue=0&svalue='+str(InputR))
response.read()
# STATE ON
if State != LastState:
#print("LastState: "+str(LastState))
#print("State: "+str(State))
if State == True:
#print('On')
StateR="On"
else:
#print('Off')
StateR="Off"
response = urlopen(domoticzurl+'/json.htm?type=command¶m=switchlight&idx='+str(idx_On)+'&switchcmd='+str(StateR))
response.read()
LastVolume = Volume
LastInput = Input
LastState = State
#print "Before sleep 10 : %s" % time.ctime()
time.sleep(4)
#print "After sleep 10 : %s" % time.ctime()
#print('end')
Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Saturday 29 October 2016 20:58
by devros
hello, thanks for script, but what should i set to domoticz side to read yamaha states? I did Cron stuff but im i dunno how to set dummy that read cron script state
thanks
Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?
Posted: Saturday 22 April 2017 13:59
by lmolenaar