-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Draft: Add input and volume support for BDV N9200W #84
base: master
Are you sure you want to change the base?
Conversation
dd3bed7
to
17fa226
Compare
17fa226
to
7b5114f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! 👍 Here's just a very, very quick initial review.
songpal/device.py
Outdated
except SongpalException as e: | ||
found_services = None | ||
if e.code == 12 and e.error_message == "getSupportedApiInfo": | ||
found_services = await self._get_supported_methods_upnp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please separate all UPnP functionality into a separate class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some UPnP code is also inside the containers (such as input & volume), how would you recommend separating this?
Having separate UPnP containers that subclass the regular container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think separate classes implementing the same interface is the way to go. Maybe something like VolumeControl
, InputControl
, which provide the common interface that gets implemented either by songpal or upnp impl, which gets chosen during the initialization procedures?
The code is quite tangled at the moment, especially on the containers and the device files, which was one of the reasons I started refactoring towards service-based classes.
songpal/device.py
Outdated
return addr.lower().replace("-", ":") if addr else addr | ||
|
||
macAddr = get_addr(info, "eth0") | ||
wirelessMacAddr = get_addr(info, "wlan0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response from getNetworkSettings
should be contained in its own container, NetworkSettings
maybe?
Here's what the structure contains based on some logs I have:
DEBUG:songpal.method:system.getNetworkSettings outs: {'netif': <class 'str'>, 'hwAddr': <class 'str'>, 'ipAddrV4': <class 'str'>, 'ipAddrV6': <class 'str'>, 'netmask': <class 'str'>, 'gateway': <class 'str'>, 'dns': 'string*'}
songpal/device.py
Outdated
) | ||
|
||
if self._upnp_renderer is None: | ||
media_renderers = await DmrDevice.async_search(timeout=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possibility to skip multiple discovery queries would be to modify the original Discover.discover()
not to filter with the scalar web api ST, and do filtering during the discovery process.
Attempt to UPnP play the same way as the Songpal app is doing
This reverts commit 2999778.
@rytilahti I've made the requested refactorings. As I have no real songpal device available, I could not test if my changes did have an undesired impact onto the songpal functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @broglep and sorry for the late response! I haven't been using my old HTXT3 for some while, so excuse me for the delay....
The PR looks fine from the surface, but I haven't tested it and I'm sort of afraid to merge this and prepare a new release without testing it. I'll try to find some time to test this with my now-broken soundbar to verify that the basic functionality still works prior merging this.
@@ -516,3 +528,259 @@ async def raw_command(self, service: str, method: str, params: Any): | |||
""" | |||
_LOGGER.info("Calling %s.%s(%s)", service, method, params) | |||
return await self.services[service][method](params) | |||
|
|||
|
|||
class UpnpDevice(Device): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please separate this class into its own file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried that, but gives some circular dependency issues. would require everything to be even more split up (device, device factory and upnp device) as the init.py loads device.py
I find it more concise to have everything in the device.py (as Upnp is just a specalization of device)
First working version of input & volume support. Not the cleanest code, but does the job.
Is implemented so that it should work with potential other variations of devices that have UPnP, but comes with the downside of multiple SSDP discoveries
Addresses #29 and maybe #23