Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions homeassistant/components/unifi/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,18 @@ def unique_id(self):

@property
def is_on(self):
"""Return true if client is blocked."""
return self.client.blocked
"""Return true if client is allowed to connect."""
return not self.client.blocked

@property
def available(self):
"""Return if controller is available."""
return self.controller.available

async def async_turn_on(self, **kwargs):
"""Block client."""
await self.controller.api.clients.async_block(self.client.mac)
"""Turn on connectivity for client."""
await self.controller.api.clients.async_unblock(self.client.mac)

async def async_turn_off(self, **kwargs):
"""Unblock client."""
await self.controller.api.clients.async_unblock(self.client.mac)
"""Turn off connectivity for client."""
await self.controller.api.clients.async_block(self.client.mac)
4 changes: 2 additions & 2 deletions tests/components/unifi/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ async def test_switches(hass, mock_controller):

blocked = hass.states.get("switch.block_client_1")
assert blocked is not None
assert blocked.state == "on"
assert blocked.state == "off"

unblocked = hass.states.get("switch.block_client_2")
assert unblocked is not None
assert unblocked.state == "off"
assert unblocked.state == "on"


async def test_new_client_discovered(hass, mock_controller):
Expand Down