Make UniFi bandwidth sensors be about current transfer rather than total transfer (#64701)
parent
11fa86cc83
commit
597fca9072
|
@ -115,8 +115,8 @@ class UniFiRxBandwidthSensor(UniFiBandwidthSensor):
|
|||
def native_value(self) -> int:
|
||||
"""Return the state of the sensor."""
|
||||
if self._is_wired:
|
||||
return self.client.wired_rx_bytes / 1000000
|
||||
return self.client.rx_bytes / 1000000
|
||||
return self.client.wired_rx_bytes_r / 1000000
|
||||
return self.client.rx_bytes_r / 1000000
|
||||
|
||||
|
||||
class UniFiTxBandwidthSensor(UniFiBandwidthSensor):
|
||||
|
@ -128,8 +128,8 @@ class UniFiTxBandwidthSensor(UniFiBandwidthSensor):
|
|||
def native_value(self) -> int:
|
||||
"""Return the state of the sensor."""
|
||||
if self._is_wired:
|
||||
return self.client.wired_tx_bytes / 1000000
|
||||
return self.client.tx_bytes / 1000000
|
||||
return self.client.wired_tx_bytes_r / 1000000
|
||||
return self.client.tx_bytes_r / 1000000
|
||||
|
||||
|
||||
class UniFiUpTimeSensor(UniFiClient, SensorEntity):
|
||||
|
|
|
@ -44,16 +44,16 @@ async def test_bandwidth_sensors(hass, aioclient_mock, mock_unifi_websocket):
|
|||
"is_wired": True,
|
||||
"mac": "00:00:00:00:00:01",
|
||||
"oui": "Producer",
|
||||
"wired-rx_bytes": 1234000000,
|
||||
"wired-tx_bytes": 5678000000,
|
||||
"wired-rx_bytes-r": 1234000000,
|
||||
"wired-tx_bytes-r": 5678000000,
|
||||
}
|
||||
wireless_client = {
|
||||
"is_wired": False,
|
||||
"mac": "00:00:00:00:00:02",
|
||||
"name": "Wireless client",
|
||||
"oui": "Producer",
|
||||
"rx_bytes": 2345000000,
|
||||
"tx_bytes": 6789000000,
|
||||
"rx_bytes-r": 2345000000,
|
||||
"tx_bytes-r": 6789000000,
|
||||
}
|
||||
options = {
|
||||
CONF_ALLOW_BANDWIDTH_SENSORS: True,
|
||||
|
@ -84,8 +84,8 @@ async def test_bandwidth_sensors(hass, aioclient_mock, mock_unifi_websocket):
|
|||
|
||||
# Verify state update
|
||||
|
||||
wireless_client["rx_bytes"] = 3456000000
|
||||
wireless_client["tx_bytes"] = 7891000000
|
||||
wireless_client["rx_bytes-r"] = 3456000000
|
||||
wireless_client["tx_bytes-r"] = 7891000000
|
||||
|
||||
mock_unifi_websocket(
|
||||
data={
|
||||
|
|
Loading…
Reference in New Issue