How to use the wakeonlan.send_magic_packet function in wakeonlan

To help you get started, we’ve selected a few wakeonlan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github remcohaszing / pywakeonlan / test_wakeonlan.py View on Github external
def test_send_magic_packet(sock):
    """
    Test whether the magic packets are broadcasted to the specified network.

    """
    send_magic_packet(
        "133713371337", "00-00-00-00-00-00", ip_address="example.com", port=7
    )
    assert sock.mock_calls == [
        call(socket.AF_INET, socket.SOCK_DGRAM),
        call().__enter__(),
        call().__enter__().setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1),
        call().__enter__().connect(("example.com", 7)),
        call()
        .__enter__()
        .send(
            b"\xff\xff\xff\xff\xff\xff"
            b"\x137\x137\x137"
            b"\x137\x137\x137"
            b"\x137\x137\x137"
            b"\x137\x137\x137"
            b"\x137\x137\x137"
github xchwarze / samsung-tv-ws-api / example / example.py View on Github external
sys.path.append('../')

from samsungtvws import SamsungTVWS

# Normal constructor
tv = SamsungTVWS('192.168.xxx.xxx')

# Autosave token to file 
token_file = os.path.dirname(os.path.realpath(__file__)) + '/tv-token.txt'
tv = SamsungTVWS(host='192.168.xxx.xxx', token_file=token_file)

# Toggle power
tv.shortcuts().power()

# Power On
wakeonlan.send_magic_packet('CC:6E:A4:xx:xx:xx')

# Open web in browser
tv.open_browser('https://duckduckgo.com/')

# View installed apps (Spotify)
tv.app_list()

# Open apps (Spotify)
tv.run_app('3201606009684')
github home-assistant / home-assistant / homeassistant / components / wake_on_lan / switch.py View on Github external
def turn_on(self, **kwargs):
        """Turn the device on."""
        if self._broadcast_address:
            wakeonlan.send_magic_packet(
                self._mac_address, ip_address=self._broadcast_address
            )
        else:
            wakeonlan.send_magic_packet(self._mac_address)
github oddworldng / cmsysbot-telegram / cmsysbot / system / remote.py View on Github external
def wake_on_lan(target_mac: str):
    send_magic_packet(target_mac)
github nickw444 / home / home-assistant / martin-pl / custom_components / samsungwsctl / media_player.py View on Github external
def turn_on(self):
        _LOGGER.debug("Sending WOL magic packet mac %s to wake device",
                      self._mac)
        import wakeonlan
        wakeonlan.send_magic_packet(self._mac)
github home-assistant / home-assistant / homeassistant / components / samsungtv / media_player.py View on Github external
def turn_on(self):
        """Turn the media player on."""
        if self._mac:
            wakeonlan.send_magic_packet(self._mac, ip_address=self._broadcast)
        else:
            self.send_key("KEY_POWERON")
github roberodin / ha-samsungtv-custom / custom_components / samsungtv_custom / media_player.py View on Github external
def turn_on(self):
        """Turn the media player on."""
        if self._mac:
            wakeonlan.send_magic_packet(self._mac)
        else:
            self.send_key("KEY_POWERON")
github alexmohr / sonyapilib / sonyapilib / device.py View on Github external
def wakeonlan(self, broadcast='255.255.255.255'):
        """Start the device either via wakeonlan."""
        if self.mac:
            wakeonlan.send_magic_packet(self.mac, ip_address=broadcast)
github home-assistant / home-assistant / homeassistant / components / wake_on_lan / switch.py View on Github external
def turn_on(self, **kwargs):
        """Turn the device on."""
        if self._broadcast_address:
            wakeonlan.send_magic_packet(
                self._mac_address, ip_address=self._broadcast_address
            )
        else:
            wakeonlan.send_magic_packet(self._mac_address)

wakeonlan

A small python module for wake on lan.

MIT
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis