[Advise needed] How to add Yamaha receiver/amp to Domoticz?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
lmolenaar
Posts: 2
Joined: Friday 05 December 2014 13:08
Target OS: Linux
Domoticz version:
Location: Eindhoven
Contact:

[Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post 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
Last edited by ThinkPad on Friday 31 July 2015 17:15, edited 1 time in total.
Reason: Added 'Yamaha' to topictitle ;)
waggie
Posts: 1
Joined: Tuesday 10 February 2015 15:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Groningen
Contact:

Re: [Advise needed] How to add receiver/amp to Domoticz?

Post 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.
JCLB
Posts: 7
Joined: Saturday 15 August 2015 17:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoti

Post 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&param=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&param=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&param=switchlight&idx='+str(idx_On)+'&switchcmd='+str(StateR))
		response.read()

	LastVolume = Volume
	LastInput = Input
	LastState = State

	time.sleep(10)

print('end')
spyseiko
Posts: 12
Joined: Tuesday 05 January 2016 14:51
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.4967
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post by spyseiko »

Will this also work on the RX-A series ?
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post 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
>>>
spyseiko
Posts: 12
Joined: Tuesday 05 January 2016 14:51
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.4967
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post by spyseiko »

Think i just have to try it.
Will report back after testing.
lupo2a
Posts: 32
Joined: Thursday 29 September 2016 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post 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&param=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&param=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&param=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')
Raspberry PI 4
Domoticz: V2023.2
- Aeotec Gen5 EU
- Neo CoolCam Door Detector and plug
- FIBARO FGWPE Wall Plug
- 6 FIBARO System FGRM222 Roller Shutter Controller 2
- Kodi SamnsungTV Yamaha plugin
- pluginn manager
- Netatmo
devros
Posts: 183
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post 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
lmolenaar
Posts: 2
Joined: Friday 05 December 2014 13:08
Target OS: Linux
Domoticz version:
Location: Eindhoven
Contact:

Re: [Advise needed] How to add Yamaha receiver/amp to Domoticz?

Post by lmolenaar »

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest