openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.57k forks source link

[YamahaReceiver] VolumeDB is not updated #3034

Closed MaximeLussier closed 6 years ago

MaximeLussier commented 6 years ago

When using the VolumeDB Zone control channel, the item is never updated with the current value (in dB). Also, setting the value does not seem to have an effect.

Expected Behavior

Current Behavior

The value remains at 0. Setting the value has no effect.

Possible Solution

It does not seem (in the code) that the CHANNEL_VOLUME_DB is updated in refreshFromState or zoneStateChanged...

As for why setting the value has no effect, I did not dig into it in the code.

Setting the value using cUrl works (setting to -40dB): curl -X POST -d '<?xml version="1.0" encoding="utf-8"?>-4001dB' http://10.35.2.2/YamahaRemoteControl/ctrl

Steps to Reproduce (for Bugs)

item: Dimmer Yamaha_Volume_DB "Volume [%.1f]" {channel="yamahareceiver:zone:UPNP_ID:Main_Zone:zone_channels#volumeDB"} Sitemap: Setpoint item=Yamaha_Volume_DB label="Volume DB" minValue=-80 maxValue=12 step=0.5

  1. The value is not updated with the current volume DB (regular % volume works)
  2. Setting the value has no effect

Context

Cannot display/Set the volume in DB while the IVR displays the volume in DB.

Your Environment

OpenHab 2.2.0-1 Ubuntu 16.04

zarusz commented 6 years ago

I will plan to look into this as part of my upcoming PR. However, this would go into OH 2.3.0-snapshot version.

mikkov1 commented 6 years ago

Not sure if this is the cause for original bug, but with RX-V3900 volume functions do not work because receiver is handling volume with <Vol>...</Vol> instead of <Volume>...</Volume> as in current implementation.

So in ZoneControlXML.java fixing following makes everything work as it should: Update():

value = XMLUtils.getNodeContentOrDefault(basicStatus, "Volume/Lvl/Val",
 String.valueOf(YamahaReceiverBindingConstants.VOLUME_MIN));

replace with:

value = XMLUtils.getNodeContentOrDefault(basicStatus, "Vol/Lvl/Val",
                String.valueOf(YamahaReceiverBindingConstants.VOLUME_MIN));

setVolumeDB:

 comReference.get().send(XMLUtils.wrZone(zone,
 "<Volume><Lvl><Val>" + String.valueOf(vol) + "</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume>"));

replace with:

 comReference.get().send(XMLUtils.wrZone(zone,
 "<Vol><Lvl><Val>" + String.valueOf(vol) + "</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Vol>"));

and then similarly in SetMute. Since I have only RX-V3900 I don't know if using works with newer receivers.

MaximeLussier commented 6 years ago

My receiver is a RX-V675, the volume control works when using the volume in percentage, the db items however do nothing.

zarusz commented 6 years ago

@MaximeLussier I have made the volumeDB fix in my fork. The custom build JAR for 2.3.0-snapshot is on my DropBox. Once tested I plan to push a PR with all my other ongoing changes.

Are you able to verify the fix on your model? On my AVR the volumeDB works like a charm now :) To run the binding you would first have to upgrade your OH to latest unstable 2.3.0-snapshot, then uninstall stock yamaha addon, and put my custom JAR in the addons folder of OH.

zarusz commented 6 years ago

@mikkov1 thanks for sharing. This is really weird that Yamaha expects a different element on RX-V3900 for the volume. Other models work fine and the problem you describe has a different root cause here. It sounds like none of the volume/mute channels work for you?

Among other pending changes, I could look into fixing this too for your model. Please send me the XML for your device:

http://<Your_Yamaha_IP>/YamahaRemoteControl/desc.xml
mikkov1 commented 6 years ago

@zarusz you are right, none of the volume channels work. Here is the desc.xml from RX-V3900:


<scpd>
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
</scpd>

However, now with versions after 2.1 release discovery of zones does work for my model at all. The reason is that binding now expects <Feature_Existence> node in device information xml and my receiver does not provide it. All it gives is 

<YAMAHA_AV rsp="GET" RC="0">
    <System>
        <Config>
        <Model_Name>RX-V3900</Model_Name>
        <System_ID>0CE4E483</System_ID>
            <Version>
            <Main> Y.0125.0205</Main>
            <Sub>V119</Sub>
            </Version>
        </Config>
    </System>
</YAMAHA_AV>

There is post about this in the community, but should I make separate issue for this? Anyway there is no point really to fix volume issue before this can be addressed also.

Thanks for support and all the effort. 
MaximeLussier commented 6 years ago

@zarusz Thanks, I will test the fixed jar as soon as possible.

I've attached the desc.xml file from my RX-V675 if it can help in any way to improve the plugin

desc.txt

mikkov1 commented 6 years ago

@zarusz Actually on 3900 description comes from http://192.168.0.1/YamahaRemoteControl/UnitDesc.xml

Here is the file:

UnitDesc.txt

zarusz commented 6 years ago

Thanks for both the desc XMLs. I will attach this to the developer documentation in my upcomming PR.

@mikkov1 regarding:

However, now with versions after 2.1 release discovery of zones does work for my model at all. The reason is that binding now expects node in device information xml and my receiver does not provide it. All it gives is

There is post about this in the community, but should I make separate issue for this? Anyway there is no point really to fix volume issue before this can be addressed also.

Nice, we are getting even more differences between models now ;) Ideally this should require a separate issue. Please loop me into the conversation (same nickname) or please share the link here. I will see what I can do about <Feature_Existence> on your model.

As part of this ticket I will address the volume element name only. With that could you please send me the response this HTTP POST http://<IP>/YamahaRemoteControl/ctrl request:

<?xml version="1.0" encoding="utf-8"?><YAMAHA_AV cmd="GET"><Main_Zone><Basic_Status>GetParam</Basic_Status></Main_Zone></YAMAHA_AV>

You could use a tool like Postman.

mikkov1 commented 6 years ago

Here is output for Main Zone Basic status: Main_Zone_Basic_Status.txt

Here is link to the forum post I wrote: https://community.openhab.org/t/yamahareceiver-zone-discovery-not-working-with-rx-v3900/38350

MaximeLussier commented 6 years ago

@zarusz I installed an instance of openhab2 and tested the addon jar you provided. The dB volume is indeed fixed and works as expected!

zarusz commented 6 years ago

PR has be submitted: https://github.com/openhab/openhab2-addons/pull/3264