Repository: home-assistant/core
File: homeassistant/components/airos/sensor.py (Python)

Code before:
    ),
    AirOS8SensorEntityDescription(
        key="wireless_throughput_rx",
        translation_key="wireless_throughput_rx",
        native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
        device_class=SensorDeviceClass.DATA_RATE,
        state_class=SensorStateClass.MEASUREMENT,
        suggested_display_precision=0,
        suggested_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
        value_fn=lambda data: data.wireless.throughput.rx,
    ),
)


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: AirOSConfigEntry,
    async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
    """Set up the AirOS sensors from a config entry."""
    coordinator = config_entry.runtime_data

    entities: list[SensorEntity] = []
    entities.extend(
        AirOSSensor(coordinator, description) for description in COMMON_SENSORS
    )

    if coordinator.device_data["fw_major"] == 8:
        entities.extend(
            AirOSSensor(coordinator, description) for description in AIROS8_SENSORS
        )

    async_add_entities(entities)


class AirOSSensor(AirOSEntity, SensorEntity):
    """Representation of a Sensor."""

    entity_description: AirOSSensorEntityDescription

    def __init__(
        self,
        coordinator: AirOSDataUpdateCoordinator,
        description: AirOSSensorEntityDescription,
    ) -> None:
        """Initialize the sensor."""
        super().__init__(coordinator)

        self.entity_description = description
        self._attr_unique_id = f"{coordinator.data.derived.mac}_{description.key}"


Review comment (suggestion):
```suggestion
    entities = [
        AirOSSensor(coordinator, description) for description in COMMON_SENSORS
    ]
```

Code after:
    ),
    AirOS8SensorEntityDescription(
        key="wireless_throughput_rx",
        translation_key="wireless_throughput_rx",
        native_unit_of_measurement=UnitOfDataRate.KILOBITS_PER_SECOND,
        device_class=SensorDeviceClass.DATA_RATE,
        state_class=SensorStateClass.MEASUREMENT,
        suggested_display_precision=0,
        suggested_unit_of_measurement=UnitOfDataRate.MEGABITS_PER_SECOND,
        value_fn=lambda data: data.wireless.throughput.rx,
    ),
)


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: AirOSConfigEntry,
    async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
    """Set up the AirOS sensors from a config entry."""
    coordinator = config_entry.runtime_data

    entities = [AirOSSensor(coordinator, description) for description in COMMON_SENSORS]

    if coordinator.device_data["fw_major"] == 8:
        entities.extend(
            AirOSSensor(coordinator, description) for description in AIROS8_SENSORS
        )

    async_add_entities(entities)


class AirOSSensor(AirOSEntity, SensorEntity):
    """Representation of a Sensor."""

    entity_description: AirOSSensorEntityDescription

    def __init__(
        self,
        coordinator: AirOSDataUpdateCoordinator,
        description: AirOSSensorEntityDescription,
    ) -> None:
        """Initialize the sensor."""
        super().__init__(coordinator)

        self.entity_description = description
        self._attr_unique_id = f"{coordinator.data.derived.mac}_{description.key}"

    @property
    def native_value(self) -> StateType:
        """Return the state of the sensor."""