diff --git a/homeassistant/components/wake_on_lan/switch.py b/homeassistant/components/wake_on_lan/switch.py index 4bf2c650396..2f019ca6158 100644 --- a/homeassistant/components/wake_on_lan/switch.py +++ b/homeassistant/components/wake_on_lan/switch.py @@ -2,7 +2,6 @@ from __future__ import annotations import logging -import platform import subprocess as sp import voluptuous as vol @@ -158,24 +157,14 @@ class WolSwitch(SwitchEntity): def update(self): """Check if device is on and update the state. Only called if assumed state is false.""" - if platform.system().lower() == "windows": - ping_cmd = [ - "ping", - "-n", - "1", - "-w", - str(DEFAULT_PING_TIMEOUT * 1000), - str(self._host), - ] - else: - ping_cmd = [ - "ping", - "-c", - "1", - "-W", - str(DEFAULT_PING_TIMEOUT), - str(self._host), - ] + ping_cmd = [ + "ping", + "-c", + "1", + "-W", + str(DEFAULT_PING_TIMEOUT), + str(self._host), + ] status = sp.call(ping_cmd, stdout=sp.DEVNULL, stderr=sp.DEVNULL) self._state = not bool(status) diff --git a/tests/components/wake_on_lan/test_switch.py b/tests/components/wake_on_lan/test_switch.py index 1396ae80f1e..cac287a87a1 100644 --- a/tests/components/wake_on_lan/test_switch.py +++ b/tests/components/wake_on_lan/test_switch.py @@ -1,5 +1,4 @@ """The tests for the wake on lan switch platform.""" -import platform import subprocess from unittest.mock import patch @@ -66,38 +65,6 @@ async def test_valid_hostname(hass): assert state.state == STATE_ON -async def test_valid_hostname_windows(hass): - """Test with valid hostname on windows.""" - assert await async_setup_component( - hass, - switch.DOMAIN, - { - "switch": { - "platform": "wake_on_lan", - "mac": "00-01-02-03-04-05", - "host": "validhostname", - } - }, - ) - await hass.async_block_till_done() - - state = hass.states.get("switch.wake_on_lan") - assert state.state == STATE_OFF - - with patch.object(subprocess, "call", return_value=0), patch.object( - platform, "system", return_value="Windows" - ): - await hass.services.async_call( - switch.DOMAIN, - SERVICE_TURN_ON, - {ATTR_ENTITY_ID: "switch.wake_on_lan"}, - blocking=True, - ) - - state = hass.states.get("switch.wake_on_lan") - assert state.state == STATE_ON - - async def test_broadcast_config_ip_and_port(hass, mock_send_magic_packet): """Test with broadcast address and broadcast port config.""" mac = "00-01-02-03-04-05" @@ -245,38 +212,6 @@ async def test_off_script(hass): assert len(calls) == 1 -async def test_invalid_hostname_windows(hass): - """Test with invalid hostname on windows.""" - - assert await async_setup_component( - hass, - switch.DOMAIN, - { - "switch": { - "platform": "wake_on_lan", - "mac": "00-01-02-03-04-05", - "host": "invalidhostname", - } - }, - ) - await hass.async_block_till_done() - - state = hass.states.get("switch.wake_on_lan") - assert state.state == STATE_OFF - - with patch.object(subprocess, "call", return_value=2): - - await hass.services.async_call( - switch.DOMAIN, - SERVICE_TURN_ON, - {ATTR_ENTITY_ID: "switch.wake_on_lan"}, - blocking=True, - ) - - state = hass.states.get("switch.wake_on_lan") - assert state.state == STATE_OFF - - async def test_no_hostname_state(hass): """Test that the state updates if we do not pass in a hostname."""