Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support STR pre-amplifier and integrated amplifier #40

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

iain-cx
Copy link

@iain-cx iain-cx commented Jan 29, 2023

Addresses #38.

The STR pre-amplifier supports four listening modes: Stereo, Mono, Both left and Both right.

It only has one zone.

Minimum and maximum volume is -96.0dB and +7.0dB. Volume can be set in 0.5dB increments. This PR reworks volume_to_attenuation() and attenuation_to_volume() to handle this case, while preserving the -90dB to 0dB range of other devices. Note that in doing so we change the type of volume from int to float. Regression testing is advised.

The device supports Home Theatre Bypass mode AKA HTB, in which the output from a separate AV receiver can be connected to the pre-amplifier, which will pass through the signal to the connected power amplifier when the pre-amplifier is in standby mode. HTB inputs are discussed in #38, however they are not able to be selected independently. The official Anthem app does show them in the input list, but fails to switch to them. They don't show up at all on the device front panel. It is therefore probably not a bug that this library cannot select them.

Several commands which apply to AV receivers are not supported by the STR. In particular, BRT is the read-only bitrate property on a receiver, but the read/write left/right channel balance adjust on the pre-amplifier. The Z1BRT0 commands adjusts balance to the right channel by 0.5dB, Z1BRT50 adjusts by 2.5dB and Z1BRT100 adjusts by 5dB (the maximum), At startup most devices would receive Z1BRT? to query the current source bitrate, but the STR (probably incorrectly) interprets the command as Z1BRT0. After instantiating the AVR class ten times, you would see your pre-amplifier shift the balance fully to the right. We now avoid doing that by adding BRT to the list of commands which should not be sent at connection startup, as well as other commands which are not mentioned in the documentation from Anthem.

Iain Patterson added 3 commits January 29, 2023 14:21
Don't hardcode the supported attenuation range as -90dB to 0dB.
Instead make it a property of the AVR class.
Note that we now treat the attenuation value as a float with 0.5dB
precision.
Only one zone.
Only four listening modes.
Attenuation range from -96dB to +7dB in 0.5dB steps.
The BRT command, which means query bitrate in most devices, is changed
to move the left/right balance to the right.  Z1BRT0 is equivalent to
moving balance 0.5dB to the right, Z1BRT50 moves it by 2.5dB and
Z1BRT100 by 5dB.  When we send Z1BRT? to query bitrate, we actually shift
the balance 0.5dB to the right, which is probably a bug on the device.
Simply using this API would inadvertently adjust the balance fully to
the right over time!
@mattlathrop
Copy link

HTB is Input 32. A name isn't returned but you can tell it to switch to 32 and it does work. I'm working on a fork of your code to add this.

Copy link
Collaborator

@Hyralex Hyralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's looking good. When I have a chance, I'll try this version with my MRX 520 to make sure it still works.

anthemav/protocol.py Show resolved Hide resolved
@mattlathrop
Copy link

I've opened a PR on this PR (maybe there was a better way to do that..) but you can find it here. iain-cx#1

@iain-cx
Copy link
Author

iain-cx commented Jun 29, 2023

HTB is Input 32. A name isn't returned but you can tell it to switch to 32 and it does work.

Executive summary: input 32 doesn't work for me.

I actually came to the conclusion that Anthem doesn't want us to go into the menu and set up an input for HTB. When you configure bypass in the settings, you choose either an RCA or XLR jack to use for it, and HTB will then work regardless of whether or not you configure an input.

In fact you can't actually configure an input using a jack that you already configured for HTB, and if you do configure one first, then subsequently configure the jack, the input shows up with the HTB suffix in the input list but you can't select it either on the front panel or with the Anthem app.

All of this leads me to conclude that you aren't supposed to set up an input at all, although the documentation doesn't make that clear, given that you and I, amongst others, read it and thought that we were supposed to.

Right now I don't have an input configured for HTB, and when I tried to select input 32 nothing happens.

If I telnet to port 14999 and send Z1INP32 I just get an error response from the device. When I did have an input configured, sending the raw input switching command with the number of my input also failed.

I'm on firmware 1.8.30. Maybe it's different on older versions but I'm not sure that special casing input 32 is the right thing to do.

@iain-cx
Copy link
Author

iain-cx commented Jun 29, 2023

I've opened a PR on this PR (maybe there was a better way to do that..) but you can find it here. iain-cx#1

Heh, I don't know what the best way to handle a PR on PR situation is, either. But I would propose that we discuss the changes here, for clarity.

Regardless of what I wrote above about HTB, the float handling stuff looks good and I can certainly merge it and repush here.

@mattlathrop
Copy link

HTB is Input 32. A name isn't returned but you can tell it to switch to 32 and it does work.

Executive summary: input 32 doesn't work for me.

I actually came to the conclusion that Anthem doesn't want us to go into the menu and set up an input for HTB. When you configure bypass in the settings, you choose either an RCA or XLR jack to use for it, and HTB will then work regardless of whether or not you configure an input.

In fact you can't actually configure an input using a jack that you already configured for HTB, and if you do configure one first, then subsequently configure the jack, the input shows up with the HTB suffix in the input list but you can't select it either on the front panel or with the Anthem app.

All of this leads me to conclude that you aren't supposed to set up an input at all, although the documentation doesn't make that clear, given that you and I, amongst others, read it and thought that we were supposed to.

Right now I don't have an input configured for HTB, and when I tried to select input 32 nothing happens.

If I telnet to port 14999 and send Z1INP32 I just get an error response from the device. When I did have an input configured, sending the raw input switching command with the number of my input also failed.

I'm on firmware 1.8.30. Maybe it's different on older versions but I'm not sure that special casing input 32 is the right thing to do.

I reached out the Anthem support ages ago about this and they said it was definitely possible to switch to HTB. My guess is it depends on which I put you select? Can you try RCA4 and see if that makes it 32? If not could you start up the monitor in this code and switch to HTB to see which input it reports?

@iain-cx
Copy link
Author

iain-cx commented Jun 29, 2023

Can you try RCA4 and see if that makes it 32?

I set it for subwoofer bypass, since only RCA3 can be set for fronts, but even then there was no difference. The input appeared in the list with HTB suffix and I couldn't select it with the front panel, the Anthem app or this library.

If not could you start up the monitor in this code and switch to HTB to see which input it reports?

It reports the input it was on before I tried to switch, because I can't switch.

@mattlathrop
Copy link

Huh so how do you get into HTB? Which equipment are you using? I can certainly switch to the input on the front panel.

@iain-cx
Copy link
Author

iain-cx commented Jun 29, 2023

The front left/right channels from my AV receiver is connected to RCA3, which is configured for HTB Fronts. I only have one subwoofer, so its output from the receiver is connected to RCA4 left, and RCA4 is configured for HTB Sub.

To enter bypass, I switch the pre-amplifier to standby mode, which flips the relays to connect RCA3 and RCA4 directly to the device outputs, ie my power amplifier and subwoofer.

That's the way the documentation says to do it, as I recall.

@mattlathrop
Copy link

Do you have the separates or the integrated? I think that may be the difference? For me (integrated) I can only pick a single input as HTB. To switch to it I have to power on the integrated (obviously since if it was off the power amp would be off) and switch to the input labeled HTB RCAX (or XLR). It does seem to be 32 regardless of which input I pick to be HTB. It sounds like we may need to special case the integrated and the pre-amp since they handle this differently?

@iain-cx
Copy link
Author

iain-cx commented Jun 29, 2023

Aha that's the difference. Yes, I have the separates.
The pre-amplifier identifies itself with IDMSTR PA. According to Anthem's documentation, the integrated should respond with IDMSTR IA, in which case we can detect it separately.

@mattlathrop
Copy link

Yep! IDMSTR IA is correct. Just verified.

@mattlathrop
Copy link

@iain-cx I updated my PR real quick. Could you test when you get some time on your PA?

iain-cx and others added 2 commits June 30, 2023 08:18
Add HTB and parse volume as float
@iain-cx
Copy link
Author

iain-cx commented Jun 30, 2023

Looks good.

@iain-cx iain-cx changed the title Support STR pre-amplifier Support STR pre-amplifier and integrated amplifier Jul 6, 2023
@Hyralex
Copy link
Collaborator

Hyralex commented Jul 7, 2023

Sorry for the delay. I'm concerned that this won't work with HA properly. It looks like you ignore the MAC command, but this commands (or any other command to get the mac address) is required for the HA integration. This is how we define the unique device ID. While it could work in theory with 1 unit, you would run into issues if you have a second unit. Is there any command that can return the MAC address of the device?

@iain-cx
Copy link
Author

iain-cx commented Jul 7, 2023

The supported way to get the MAC address on these devices (as well as on x20 receivers and other devices) is to send IDN?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants