Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion homeassistant/components/wake_on_lan/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@

DEFAULT_NAME = "Wake on LAN"
DEFAULT_PING_TIMEOUT = 1
DEFAULT_BROADCAST_PORT = 9

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.

vol.Optional(CONF_BROADCAST_PORT): cv.port,
vol.Optional(CONF_BROADCAST_PORT, default=DEFAULT_BROADCAST_PORT): cv.port,
vol.Optional(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_OFF_ACTION): cv.SCRIPT_SCHEMA,
Expand Down