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