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

Initial support for zone control #42

Merged
merged 30 commits into from
Feb 17, 2019
Merged

Initial support for zone control #42

merged 30 commits into from
Feb 17, 2019

Conversation

jwiese
Copy link
Contributor

@jwiese jwiese commented Feb 10, 2019

No description provided.

@jwiese jwiese mentioned this pull request Feb 10, 2019
Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Looks generally good, thanks! 💯 I added a couple of points which needs to be cleared before this can be merged, just for the sake of maintainability.

README.rst Outdated Show resolved Hide resolved
@@ -263,7 +263,7 @@ def is_muted(self):
return self.mute == "on"

def __str__(self):
s = "Volume: %s/%s" % (self.volume, self.maxVolume)
s = "Zone %s Volume: %s/%s" % (self.output[self.output.rfind("=")+1:], self.volume, self.maxVolume)
Copy link
Owner

Choose a reason for hiding this comment

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

This feels potentially error-prone when it comes to devices with no zones, doesn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was assuming that there was always at least one zone, but I guess there are maybe some devices where that isn't the case?

Ultimately, there are a couple of places that feel a little brittle like this because, as you mentioned below, Zones are not cached in the device, which they probably should be. I had thought about it, but seemed like a bigger change to the overall structure of the library.

For now, I just changed this to see if self.output contained a string that contains '=', but happy to do something more substantial.

Copy link
Owner

Choose a reason for hiding this comment

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

I'll have to think about it a bit, but maybe the proper solution is to create a default zone (with output="") and replace Input with Zone altogether, as the functionality in both of those containers is very much the same?

Copy link
Owner

Choose a reason for hiding this comment

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

What kind of features each zone has? Source and volume control, but are there more? After this PR is merged, I'm going to do a heavy cleanup on the codebase to make it easier to maintain, and at that point it maybe makes sense to create a real zone class having methods related to controlling all zone-specific functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Input source
  • Volume
  • Activate (on/off)

These are different from Inputs (I think), because Inputs don't have a volume or a source associated with them (in fact, Inputs are the sources)

Inputs for Zones are a little funny because it seems that not all inputs can be activated for a zone, but this is listed on the inputs, not the zones, e.g.:

{ 'active':'inactive', 'connection':'unknown', 'iconUrl':'', 'label':'', 'meta':'meta:bd-dvd', 'outputs':[ 'extOutput:zone?zone=1', 'extOutput:zone?zone=4' ], 'title':'cast ', 'uri':'extInput:bd-dvd' },

songpal/containers.py Outdated Show resolved Hide resolved
songpal/containers.py Outdated Show resolved Hide resolved
songpal/discovery.py Outdated Show resolved Hide resolved
songpal/main.py Outdated Show resolved Hide resolved
songpal/main.py Outdated Show resolved Hide resolved
@jwiese
Copy link
Contributor Author

jwiese commented Feb 16, 2019

I guess one question here is if there are additional functions that will be required to integrate this smoothly into Home Assistant. I don't have experience contributing to Home Assistant yet, so I'm not sure how that is going to go. This maybe gets back to @rytilahti's question about whether some of the zone logic should be cached in the device.

Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

This is looking fine, I left a couple of comments and after those are done we can merge this!

README.rst Show resolved Hide resolved
songpal/containers.py Outdated Show resolved Hide resolved
songpal/main.py Outdated Show resolved Hide resolved
README.rst Show resolved Hide resolved
devinfos/STR-DN1060.json Outdated Show resolved Hide resolved
songpal/main.py Outdated Show resolved Hide resolved
songpal/containers.py Outdated Show resolved Hide resolved
@rytilahti
Copy link
Owner

rytilahti commented Feb 16, 2019

I guess one question here is if there are additional functions that will be required to integrate this smoothly into Home Assistant. I don't have experience contributing to Home Assistant yet, so I'm not sure how that is going to go. This maybe gets back to @rytilahti's question about whether some of the zone logic should be cached in the device.

See my comment above about "default" zone, I think that's the way to go and will make integrating with homeassistant easier. The current songpal platform has to be converted into a component (I have some code around, but haven't yet managed to finish the conversion), which shall then request the available zones from the device and initialize a media_player platform for each zone. This will need some added logic to deliver the notifications to correct instance per zone name.

@jwiese
Copy link
Contributor Author

jwiese commented Feb 17, 2019

I think I got 'em all

@rytilahti
Copy link
Owner

rytilahti commented Feb 17, 2019

Looks good, let's get it merged! :-) edit: I released 0.10 containing this, thanks again for your contribution! 🥇

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.

2 participants