mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
UniFi - reverse connectivity logic (#25691)
* Make connectivity control in line with other implementations
This commit is contained in:
parent
5a90b49e27
commit
576291779e
@ -266,8 +266,8 @@ class UniFiBlockClientSwitch(UniFiClient, SwitchDevice):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if client is blocked."""
|
"""Return true if client is allowed to connect."""
|
||||||
return self.client.blocked
|
return not self.client.blocked
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
@ -275,9 +275,9 @@ class UniFiBlockClientSwitch(UniFiClient, SwitchDevice):
|
|||||||
return self.controller.available
|
return self.controller.available
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
async def async_turn_on(self, **kwargs):
|
||||||
"""Block client."""
|
"""Turn on connectivity for client."""
|
||||||
await self.controller.api.clients.async_block(self.client.mac)
|
await self.controller.api.clients.async_unblock(self.client.mac)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
"""Unblock client."""
|
"""Turn off connectivity for client."""
|
||||||
await self.controller.api.clients.async_unblock(self.client.mac)
|
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")
|
blocked = hass.states.get("switch.block_client_1")
|
||||||
assert blocked is not None
|
assert blocked is not None
|
||||||
assert blocked.state == "on"
|
assert blocked.state == "off"
|
||||||
|
|
||||||
unblocked = hass.states.get("switch.block_client_2")
|
unblocked = hass.states.get("switch.block_client_2")
|
||||||
assert unblocked is not None
|
assert unblocked is not None
|
||||||
assert unblocked.state == "off"
|
assert unblocked.state == "on"
|
||||||
|
|
||||||
|
|
||||||
async def test_new_client_discovered(hass, mock_controller):
|
async def test_new_client_discovered(hass, mock_controller):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user