UniFi - Add unit of measurement to bandwidth sensors (#32114)

This commit is contained in:
Robert Svensson 2020-02-23 19:17:26 +01:00 committed by GitHub
parent 4cc4f070f5
commit 1007283da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
import logging
from homeassistant.components.unifi.config_flow import get_controller_from_config_entry
from homeassistant.const import DATA_BYTES
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -9,9 +10,6 @@ from .unifi_client import UniFiClient
LOGGER = logging.getLogger(__name__)
ATTR_RECEIVING = "receiving"
ATTR_TRANSMITTING = "transmitting"
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Sensor platform doesn't support configuration through configuration.yaml."""
@ -115,6 +113,11 @@ class UniFiRxBandwidthSensor(UniFiClient):
"""Return a unique identifier for this bandwidth sensor."""
return f"rx-{self.client.mac}"
@property
def unit_of_measurement(self):
"""Return the unit of measurement of this entity."""
return DATA_BYTES
class UniFiTxBandwidthSensor(UniFiRxBandwidthSensor):
"""Transmitting bandwidth sensor."""