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

Add ControlBusMode to __init__.py #97

Closed
wants to merge 1 commit into from

Conversation

Solmath
Copy link

@Solmath Solmath commented Feb 23, 2025

In addition to the changes by @ichbinsteffen in #92, I think it might be useful to expose ControlBusMode in aiostreammagic.

Then we could add something like

if self.client.state.control_bus is not ControlBusMode.OFF:
        features |= CONTROL_BUS_FEATURES

to media_player.py in the HA integration. I have a PR for this ready.

With the recent addition of set_control_bus_mode() in #92 it should be relatively easy to also add an entity for the control bus in HA.

@Solmath Solmath requested a review from noahhusby as a code owner February 23, 2025 18:07
@ichbinsteffen
Copy link
Contributor

ichbinsteffen commented Feb 23, 2025

Hi @Solmath

you probably havent seen my first PR or the description of it.

This

With the recent addition of set_control_bus_mode() in #92 it should be relatively easy to also add an entity for the control bus in HA.

was my plan for the Home Assistant integration :)

About

In the Home Assistant integration I have noticed that volume can not be controlled when pre_amp_mode is disabled.
In the StreamMagic app, the volume can still be controlled when PreAmp mode is disabled but the Control Bus mode is "Amplifier". It then controls the control bus volume and so changes volume on the connected amplifier. In the app you can of course not see the current volume state because control bus is uni-directional.

I have looked into the code of the Home Assistant integration and found that the ControlBusMode in the "state" property is not even accounted for and that the volume controls (PREAMP_FEATURES) are only added when pre-amp mode is enabled. I would like to change that.
So as a first step it is necessary that aiostreammagic has the ability to control the control bus mode.

So yes, I also have prepared a PR in the Home Assistant repo to introduce a switch for control_bus_mode and enable volume control. home-assistant/core#139131

What would you put int CONTROL_BUS_FEATURES ?
So far I have seen that I can only control ON/OFF and volume of my connected amplifier. So Power On/Off is already in the features property, the only thing missing is Volume_step as far as I know. Is there more? (i cant change any more things from the StreamMagic app..)

@@ -10,6 +10,7 @@
State,
Source,
NowPlaying,
ControlBusMode,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary?

The ControlBusMode is accessible from the State

Copy link
Author

@Solmath Solmath Feb 23, 2025

Choose a reason for hiding this comment

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

The current setting of the control bus can be accessed with client.state.control_bus, however the possible values (off, amplifier, receiver) are unknown. Therefore, my idea was to make the enum accessible so its values can be used for comparison wit the current setting.

@Solmath
Copy link
Author

Solmath commented Feb 23, 2025

you probably havent seen my first PR or the description of it.

As a matter of fact I saw it after I had already done the changes on HA side. I had hoped it could be done without any changes in aiostreammagic.

What would you put int CONTROL_BUS_FEATURES ? So far I have seen that I can only control ON/OFF and volume of my connected amplifier. So Power On/Off is already in the features property, the only thing missing is Volume_step as far as I know. Is there more? (i cant change any more things from the StreamMagic app..)

I think only MediaPlayerEntityFeature.VOLUME_STEP is necessary, because ON/OFF is already part of the base features and will just be forwarded to the amp anyway.

Channel or output selection would be a nice feature, but I don't think the control bus supports that at the moment. I guess we'd have to ask Cambridge Audio for a definitive answer.

@noahhusby
Copy link
Owner

@Solmath I took care of this in my latest commit, didn't see the PR until just now. Closing this. Will review your home-assistant PR once it's ready.

@noahhusby noahhusby closed this Feb 24, 2025
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