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

Turn on samsungtv with wakeonlan #50964

Merged
merged 1 commit into from
May 22, 2021
Merged

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented May 22, 2021

Proposed change

If we have the mac address from discovery, we can use it to wake
the TV. Currently the TV goes unavailable when you turn it off
as the only way to turn it back on is wake on lan or via the remote
which makes the integration far less useful out of box.

This is the recommended way to turn the tv on
https://pypi.org/project/samsungtvws/

Users that have the TV on a smart switch or other system can use a turn_on_action as this continues
to take precedence of the built-in wake on lan functionality.

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

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.
  • 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:

If we have the mac address from discovery, we can use it to wake
the TV.  Currently the TV goes unavailable when you turn it off
as the only way to turn it back on is wake on lan or via the remote.

Users who are not using host networking can use a script instead.
@probot-home-assistant
Copy link

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

@escoand
Copy link
Contributor

escoand commented May 22, 2021

Side note, not all TV are able to wake on lan: prepare for many user issues. We had this situation already some time ago. Thats why we removed it in favor of the "official" wol integration.

@escoand
Copy link
Contributor

escoand commented May 22, 2021

... or was it just on the intergation's doc? Not sure.

@bdraco
Copy link
Member Author

bdraco commented May 22, 2021

I added a 'TV does not turn on' section to the docs so the users can figure out what to do in that case.

Yes, there will always be users who don't bother to read the docs but that's already a large chunk of the issues and it doesn't seem likely (sans the usual initial amount from any change in behavior) its going to stop many users from opening an issue if the tv is not turning on vs going unavailable (current behavior).

Comment on lines +253 to +256
send_magic_packet(self._mac, ip_address=self._host)
# If the ip address changed since we last saw the device
# broadcast a packet as well
send_magic_packet(self._mac)
Copy link
Contributor

Choose a reason for hiding this comment

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

would assume to broadcast based on mac should be enough to perform WoL 🤔

Copy link
Member Author

@bdraco bdraco May 22, 2021

Choose a reason for hiding this comment

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

If they have a bifurcated network directly sending to the ip address may be needed since 255.255.255.255 will go to the default interface and the tv may be connected to another interface

Copy link
Member

Choose a reason for hiding this comment

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

does "bifurcated" include "vpn" ? (this is the day to learn new words 😄

Copy link
Contributor

@mib1185 mib1185 May 22, 2021

Choose a reason for hiding this comment

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

magic packets can only be send inside the same/own broadcast domain, so no to vpn, nor other only routed reachable targets ;)

But yes to add also ip in the first, to be able to handle multi NIC setups 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

does "bifurcated" include "vpn" ? (this is the day to learn new words 😄

It could any network interface vpn or otherwise. In this case its likely a second network physical interface.

Copy link
Member

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

LGTM.

Comment on lines +253 to +256
send_magic_packet(self._mac, ip_address=self._host)
# If the ip address changed since we last saw the device
# broadcast a packet as well
send_magic_packet(self._mac)
Copy link
Member

Choose a reason for hiding this comment

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

does "bifurcated" include "vpn" ? (this is the day to learn new words 😄

@bdraco bdraco merged commit 45897b5 into home-assistant:dev May 22, 2021
@bdraco bdraco deleted the samsungtv_turn_on branch May 22, 2021 20:33
@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2021
async def async_turn_on(self):
"""Turn the media player on."""
if self._on_script:
await self._on_script.async_run(context=self._context)
elif self._mac:
await self.hass.async_add_executor_job(self._wake_on_lan)
Copy link
Member

Choose a reason for hiding this comment

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

Note that we should not allow adding any options for this wake on lan usage. If users need options they will need to use the script.

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

Successfully merging this pull request may close these issues.

7 participants