Skip to content

Update wake_on_lan parameter#37406

Closed
MattXcz wants to merge 1 commit intohome-assistant:devfrom
MattXcz:patch-1
Closed

Update wake_on_lan parameter#37406
MattXcz wants to merge 1 commit intohome-assistant:devfrom
MattXcz:patch-1

Conversation

@MattXcz
Copy link
Copy Markdown

@MattXcz MattXcz commented Jul 3, 2020

Adding default port for WOL

Proposed change

Type of change

adding default value for WOL (port 9)

  • 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

Example entry for configuration.yaml:

broadcast_port: "9"

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

making default port 9
@MattXcz MattXcz changed the title Update switch.py Update wake_on_lan parameter Jul 3, 2020
Copy link
Copy Markdown
Contributor

@cgtobi cgtobi left a comment

Choose a reason for hiding this comment

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

LGTM

@dshokouhi dshokouhi added this to the 0.112.2 milestone Jul 3, 2020
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_MAC): cv.string,
vol.Optional(CONF_BROADCAST_ADDRESS): cv.string,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The address also requires a default. For both, please use the DEFAULT_ parameters in the wakeonlan package. https://github.com/remcohaszing/pywakeonlan/blob/master/wakeonlan.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternative is to not pass the args at all to the wlan function.

kwargs = {}
if CONF_BROADCAST_PORT in call.data:
    kwargs['port'] = call.data[CONF_BROADCASTPORT]

await hass.async_add_job(
    partial(
        wakeonlan.send_magic_packet,
        mac_address,
        **kwargs,
    )
)

btw this is also broken in the __init__.py service.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@balloob I have had a PR to fix this as well that sort of takes this approach. #37387

looks like there might be duplicate issues for the port option addition. I would not default the port in HA but leave that up to the library at this time.

@balloob balloob modified the milestones: 0.112.2, 0.112.3, 0.112.4 Jul 3, 2020
@stshontikidis
Copy link
Copy Markdown
Contributor

This will still leave the turn_on() service in a broken state since it only checks for the broadcast_address to add the kwargs so if a user only sets a port in their config that will never be passed to the actual send_magic_packet() service. Further it will still log the port giving the user bad debug info.

@balloob balloob removed this from the 0.112.4 milestone Jul 8, 2020
@balloob
Copy link
Copy Markdown
Member

balloob commented Jul 8, 2020

Closing this in favor of #37387

@balloob balloob closed this Jul 8, 2020
hahn-th pushed a commit to hahn-th/core that referenced this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

from 0.112.0, wake_on_line does not function

6 participants