Don't create a switch for POE device if said device is Cloud key (#18117)
This commit is contained in:
parent
1f290bad94
commit
92c536ec0e
2 changed files with 26 additions and 1 deletions
|
@ -129,7 +129,8 @@ async def async_update_items(controller, async_add_entities,
|
||||||
# Network device with active POE
|
# Network device with active POE
|
||||||
if not client.is_wired or client.sw_mac not in devices or \
|
if not client.is_wired or client.sw_mac not in devices or \
|
||||||
not devices[client.sw_mac].ports[client.sw_port].port_poe or \
|
not devices[client.sw_mac].ports[client.sw_port].port_poe or \
|
||||||
not devices[client.sw_mac].ports[client.sw_port].poe_enable:
|
not devices[client.sw_mac].ports[client.sw_port].poe_enable or \
|
||||||
|
controller.mac == client.mac:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Multiple POE-devices on same port means non UniFi POE driven switch
|
# Multiple POE-devices on same port means non UniFi POE driven switch
|
||||||
|
|
|
@ -64,6 +64,18 @@ CLIENT_4 = {
|
||||||
'wired-rx_bytes': 1234000000,
|
'wired-rx_bytes': 1234000000,
|
||||||
'wired-tx_bytes': 5678000000
|
'wired-tx_bytes': 5678000000
|
||||||
}
|
}
|
||||||
|
CLOUDKEY = {
|
||||||
|
'hostname': 'client_1',
|
||||||
|
'ip': 'mock-host',
|
||||||
|
'is_wired': True,
|
||||||
|
'mac': '10:00:00:00:00:01',
|
||||||
|
'name': 'Cloud key',
|
||||||
|
'oui': 'Producer',
|
||||||
|
'sw_mac': '00:00:00:00:01:01',
|
||||||
|
'sw_port': 1,
|
||||||
|
'wired-rx_bytes': 1234000000,
|
||||||
|
'wired-tx_bytes': 5678000000
|
||||||
|
}
|
||||||
POE_SWITCH_CLIENTS = [
|
POE_SWITCH_CLIENTS = [
|
||||||
{
|
{
|
||||||
'hostname': 'client_1',
|
'hostname': 'client_1',
|
||||||
|
@ -179,6 +191,7 @@ def mock_controller(hass):
|
||||||
api=Mock(),
|
api=Mock(),
|
||||||
spec=unifi.UniFiController
|
spec=unifi.UniFiController
|
||||||
)
|
)
|
||||||
|
controller.mac = '10:00:00:00:00:01'
|
||||||
controller.mock_requests = []
|
controller.mock_requests = []
|
||||||
|
|
||||||
controller.mock_client_responses = deque()
|
controller.mock_client_responses = deque()
|
||||||
|
@ -230,6 +243,17 @@ async def test_no_clients(hass, mock_controller):
|
||||||
assert not hass.states.async_all()
|
assert not hass.states.async_all()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_controller_not_client(hass, mock_controller):
|
||||||
|
"""Test that the controller doesn't become a switch."""
|
||||||
|
mock_controller.mock_client_responses.append([CLOUDKEY])
|
||||||
|
mock_controller.mock_device_responses.append([DEVICE_1])
|
||||||
|
await setup_controller(hass, mock_controller)
|
||||||
|
assert len(mock_controller.mock_requests) == 2
|
||||||
|
assert not hass.states.async_all()
|
||||||
|
cloudkey = hass.states.get('switch.cloud_key')
|
||||||
|
assert cloudkey is None
|
||||||
|
|
||||||
|
|
||||||
async def test_switches(hass, mock_controller):
|
async def test_switches(hass, mock_controller):
|
||||||
"""Test the update_items function with some lights."""
|
"""Test the update_items function with some lights."""
|
||||||
mock_controller.mock_client_responses.append([CLIENT_1, CLIENT_4])
|
mock_controller.mock_client_responses.append([CLIENT_1, CLIENT_4])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue