Use enums in octoprint (#62079)

This commit is contained in:
Robert Hillis 2021-12-16 11:07:50 -05:00 committed by GitHub
parent ec3efb4b1a
commit e6956acb4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,14 +6,13 @@ import logging
from pyoctoprintapi import OctoprintJobInfo, OctoprintPrinterInfo from pyoctoprintapi import OctoprintJobInfo, OctoprintPrinterInfo
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry SensorDeviceClass,
from homeassistant.const import ( SensorEntity,
DEVICE_CLASS_TEMPERATURE, SensorStateClass,
DEVICE_CLASS_TIMESTAMP,
PERCENTAGE,
TEMP_CELSIUS,
) )
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -150,7 +149,7 @@ class OctoPrintJobPercentageSensor(OctoPrintSensorBase):
class OctoPrintEstimatedFinishTimeSensor(OctoPrintSensorBase): class OctoPrintEstimatedFinishTimeSensor(OctoPrintSensorBase):
"""Representation of an OctoPrint sensor.""" """Representation of an OctoPrint sensor."""
_attr_device_class = DEVICE_CLASS_TIMESTAMP _attr_device_class = SensorDeviceClass.TIMESTAMP
def __init__( def __init__(
self, coordinator: OctoprintDataUpdateCoordinator, device_id: str self, coordinator: OctoprintDataUpdateCoordinator, device_id: str
@ -177,7 +176,7 @@ class OctoPrintEstimatedFinishTimeSensor(OctoPrintSensorBase):
class OctoPrintStartTimeSensor(OctoPrintSensorBase): class OctoPrintStartTimeSensor(OctoPrintSensorBase):
"""Representation of an OctoPrint sensor.""" """Representation of an OctoPrint sensor."""
_attr_device_class = DEVICE_CLASS_TIMESTAMP _attr_device_class = SensorDeviceClass.TIMESTAMP
def __init__( def __init__(
self, coordinator: OctoprintDataUpdateCoordinator, device_id: str self, coordinator: OctoprintDataUpdateCoordinator, device_id: str
@ -206,8 +205,8 @@ class OctoPrintTemperatureSensor(OctoPrintSensorBase):
"""Representation of an OctoPrint sensor.""" """Representation of an OctoPrint sensor."""
_attr_native_unit_of_measurement = TEMP_CELSIUS _attr_native_unit_of_measurement = TEMP_CELSIUS
_attr_device_class = DEVICE_CLASS_TEMPERATURE _attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_state_class = STATE_CLASS_MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT
def __init__( def __init__(
self, self,