UniFi - reverse connectivity logic (#25691)
* Make connectivity control in line with other implementationspull/25756/head
parent
2925f9e57a
commit
4e2094c893
|
@ -266,8 +266,8 @@ class UniFiBlockClientSwitch(UniFiClient, SwitchDevice):
|
|||
|
||||
@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):
|
||||
|
@ -275,9 +275,9 @@ class UniFiBlockClientSwitch(UniFiClient, SwitchDevice):
|
|||
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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue