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

Code before:
        issue_domain=DOMAIN,
        severity=ir.IssueSeverity.WARNING,
        translation_key="deprecated_yaml",
        translation_placeholders={
            "domain": DOMAIN,
            "integration_title": INTEGRATION_TITLE,
        },
    )


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
    """Add sensors for passed config_entry in HA."""
    async_add_entities(
        [
            OpenEVSESensor(
                config_entry.data[CONF_HOST],
                config_entry.runtime_data,
                config_entry.entry_id,
                description,
            )
            for description in SENSOR_TYPES
        ]
    )


class OpenEVSESensor(SensorEntity):
    """Implementation of an OpenEVSE sensor."""

    def __init__(
        self,
        host: str,
        charger: openevsewifi.Charger,
        entry_id: str,
        description: SensorEntityDescription,
    ) -> None:
        """Initialize the sensor."""
        self._attr_unique_id = entry_id
        self.entity_description = description
        self.host = host
        self.charger = charger
        self.entity_registry_enabled_default = self.entity_description.key not in (
            "ir_temp",
            "rtc_temp",
        )

    def update(self) -> None:
        """Get the monitored data from the charger."""

Review comment (suggestion):
```suggestion
    async_add_entities(
        (
            OpenEVSESensor(
                config_entry.data[CONF_HOST],
                config_entry.runtime_data,
                config_entry.entry_id,
                description,
            )
            for description in SENSOR_TYPES
        ),
        True
    )
```

Code after:
        severity=ir.IssueSeverity.WARNING,
        translation_key="deprecated_yaml",
        translation_placeholders={
            "domain": DOMAIN,
            "integration_title": INTEGRATION_TITLE,
        },
    )


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
    """Add sensors for passed config_entry in HA."""
    async_add_entities(
        (
            OpenEVSESensor(
                config_entry.data[CONF_HOST],
                config_entry.runtime_data,
                description,
            )
            for description in SENSOR_TYPES
        ),
        True,
    )


class OpenEVSESensor(SensorEntity):
    """Implementation of an OpenEVSE sensor."""

    def __init__(
        self,
        host: str,
        charger: openevsewifi.Charger,
        description: SensorEntityDescription,
    ) -> None:
        """Initialize the sensor."""
        self.entity_description = description
        self.host = host
        self.charger = charger

    def update(self) -> None:
        """Get the monitored data from the charger."""
        try:
            sensor_type = self.entity_description.key
            if sensor_type == "status":
                self._attr_native_value = self.charger.getStatus()
            elif sensor_type == "charge_time":
                self._attr_native_value = self.charger.getChargeTimeElapsed() / 60
            elif sensor_type == "ambient_temp":