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 Upnp volume control/status to SamsungTV #68663

Merged
merged 66 commits into from Mar 27, 2022

Conversation

epenet
Copy link
Contributor

@epenet epenet commented Mar 25, 2022

#68717 needs to be merged first

Proposed change

Add Upnp volume control/status to SamsungTV
Adds SUPPORT_VOLUME_SET to _attr_supported_features

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

Hey there @chemelli74, mind taking a look at this pull request as it has been labeled with an integration (samsungtv) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Mar 25, 2022
@epenet
Copy link
Contributor Author

epenet commented Mar 25, 2022

cc @bdraco, @sermayoral

I still need to add tests, and parse the source list.
However, since GetSourceList isn't supported on my TV I cannot complete the source list just yet.

@epenet
Copy link
Contributor Author

epenet commented Mar 25, 2022

cc @bdraco, @sermayoral

I still need to add tests, and parse the source list. However, since GetSourceList isn't supported on my TV I cannot complete the source list just yet.

I have removed the Upnp app_list request - I can add in a follow-up PR
I think this is good to go

@epenet epenet marked this pull request as ready for review March 25, 2022 10:07
@epenet epenet requested a review from chemelli74 as a code owner March 25, 2022 10:07
@epenet epenet changed the title Add Upnp services to SamsungTV Add Upnp volume control/status to SamsungTV Mar 25, 2022
@epenet epenet requested review from bdraco and removed request for chemelli74 March 25, 2022 10:07
@sermayoral
Copy link
Contributor

@epenet. What do you need?

@epenet
Copy link
Contributor Author

epenet commented Mar 25, 2022

@epenet. What do you need?

For this PR => just confirmation that these three work correctly for you:

  • get volume level
  • set volume level
  • get mute status

@epenet
Copy link
Contributor Author

epenet commented Mar 25, 2022

@epenet. What do you need?

For Upnp app-list, maybe you can ping me on discord (https://discord.com/invite/home-assistant - epenet#1188) to discuss further

@sermayoral
Copy link
Contributor

For Upnp app-list, maybe you can ping me on discord (https://discord.com/invite/home-assistant - epenet#1188) to discuss further

Not A Number:

image

Here is the full log: https://pastebin.com/rV1HyFx9

@epenet
Copy link
Contributor Author

epenet commented Mar 25, 2022

@sermayoral I have set a default value for the TVs that do not respond on url http://{self._host}:9197/dmr

I am not sure how to handle TVs that have Upnp on a different URL.

@bdraco
Copy link
Member

bdraco commented Mar 25, 2022

We need to add "async-upnp-client==0.27.0" to manifest.json

@bdraco
Copy link
Member

bdraco commented Mar 25, 2022

  "ssdp": [
    {
      "st": "urn:samsung.com:device:RemoteControlReceiver:1"
    },
    {
      "manufacturer": "Samsung",
      "st": "urn:schemas-upnp-org:service:RenderingControl:1"
    },
    {
      "manufacturer": "Samsung Electronics",
      "st": "urn:schemas-upnp-org:service:RenderingControl:1"
    }    
  ],

ssdp needs to change as well

@bdraco
Copy link
Member

bdraco commented Mar 26, 2022

Testing looks good

I'll split this after some sleep

A reauth flow is no longer required to detect the need for
encryption as it can now be detected during setup

Fixes being able to setup legacy TVs since the encrypted
check previously would prevent them from proceeding

Improves the failure case where the user cannot hit
the button to allow Home Assistant connect to the TV
in time by allowing them to retry
@bdraco
Copy link
Member

bdraco commented Mar 26, 2022

Changes split into #68717

@bdraco
Copy link
Member

bdraco commented Mar 27, 2022

Fixed the conflicts

Dev automation moved this from By Code Owner to Reviewer approved Mar 27, 2022
@bdraco
Copy link
Member

bdraco commented Mar 27, 2022

In testing found a case where reauth was requested when it wasn't needed. If you turn off the tv during an update

2022-03-27 11:28:29 INFO (MainThread) [homeassistant.components.samsungtv] Failed to get remote for 192.168.106.51, re-authentication required: ConnectionClosedError(None, Close(code=1011, reason='keepalive ping timeout'), None)

I'll open another PR for that: #68762

@bdraco bdraco merged commit c024033 into home-assistant:dev Mar 27, 2022
Dev automation moved this from Reviewer approved to Done Mar 27, 2022
@epenet epenet deleted the samsungtv-upnp branch March 27, 2022 22:28
return

get_volume, get_mute = await asyncio.gather(
service.action("GetVolume").async_call(InstanceID=0, Channel="Master"),
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is in line with our design requirements. Protocol details should stay in a 3rd party library. The library should handle the UPnP setup and command details.

Copy link
Member

Choose a reason for hiding this comment

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

I figured this was ok since we have the similar pattern in the upnp and dlna* integrations

Copy link
Member

@bdraco bdraco Mar 28, 2022

Choose a reason for hiding this comment

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

Not sure it's possible, and I'm out of time to dig in more for today, but maybe we create a new profile for Samsung Tv

async_upnp_client.profiles.samsungtv?

Copy link
Member

Choose a reason for hiding this comment

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

I would consider them exceptions as they are general integrations similar to mqtt.

The Samsung TV integration is not that.

Copy link
Member

Choose a reason for hiding this comment

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

@epenet async_upnp_client.profiles.samsungtv or a new library? It doesn't seem to fit in any of the existing ones.

Not sure what is better

Copy link
Member

Choose a reason for hiding this comment

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

I haven't looked into the details, and I won't be back home for a while so but I wonder if we could actually get subscriptions working as well so we could get push updates.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants