mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use enums in Powerwall (#62072)
This commit is contained in:
parent
31bef18e9a
commit
619529b40c
@ -2,11 +2,9 @@
|
|||||||
from tesla_powerwall import GridStatus, MeterType
|
from tesla_powerwall import GridStatus, MeterType
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_BATTERY_CHARGING,
|
BinarySensorDeviceClass,
|
||||||
DEVICE_CLASS_CONNECTIVITY,
|
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import DEVICE_CLASS_POWER
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -61,7 +59,7 @@ class PowerWallRunningSensor(PowerWallEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device Class."""
|
"""Device Class."""
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -85,7 +83,7 @@ class PowerWallConnectedSensor(PowerWallEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device Class."""
|
"""Device Class."""
|
||||||
return DEVICE_CLASS_CONNECTIVITY
|
return BinarySensorDeviceClass.CONNECTIVITY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -109,7 +107,7 @@ class PowerWallGridServicesActiveSensor(PowerWallEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device Class."""
|
"""Device Class."""
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -133,7 +131,7 @@ class PowerWallGridStatusSensor(PowerWallEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device Class."""
|
"""Device Class."""
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -157,7 +155,7 @@ class PowerWallChargingStatusSensor(PowerWallEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Device Class."""
|
"""Device Class."""
|
||||||
return DEVICE_CLASS_BATTERY_CHARGING
|
return BinarySensorDeviceClass.BATTERY_CHARGING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
@ -4,18 +4,11 @@ import logging
|
|||||||
from tesla_powerwall import MeterType
|
from tesla_powerwall import MeterType
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_KILO_WATT
|
||||||
DEVICE_CLASS_BATTERY,
|
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
|
||||||
PERCENTAGE,
|
|
||||||
POWER_KILO_WATT,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_FREQUENCY,
|
ATTR_FREQUENCY,
|
||||||
@ -92,7 +85,7 @@ class PowerWallChargeSensor(PowerWallEntity, SensorEntity):
|
|||||||
|
|
||||||
_attr_name = "Powerwall Charge"
|
_attr_name = "Powerwall Charge"
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
_attr_device_class = DEVICE_CLASS_BATTERY
|
_attr_device_class = SensorDeviceClass.BATTERY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -108,9 +101,9 @@ class PowerWallChargeSensor(PowerWallEntity, SensorEntity):
|
|||||||
class PowerWallEnergySensor(PowerWallEntity, SensorEntity):
|
class PowerWallEnergySensor(PowerWallEntity, SensorEntity):
|
||||||
"""Representation of an Powerwall Energy sensor."""
|
"""Representation of an Powerwall Energy sensor."""
|
||||||
|
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_native_unit_of_measurement = POWER_KILO_WATT
|
_attr_native_unit_of_measurement = POWER_KILO_WATT
|
||||||
_attr_device_class = DEVICE_CLASS_POWER
|
_attr_device_class = SensorDeviceClass.POWER
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -155,9 +148,9 @@ class PowerWallEnergySensor(PowerWallEntity, SensorEntity):
|
|||||||
class PowerWallEnergyDirectionSensor(PowerWallEntity, SensorEntity):
|
class PowerWallEnergyDirectionSensor(PowerWallEntity, SensorEntity):
|
||||||
"""Representation of an Powerwall Direction Energy sensor."""
|
"""Representation of an Powerwall Direction Energy sensor."""
|
||||||
|
|
||||||
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
_attr_device_class = DEVICE_CLASS_ENERGY
|
_attr_device_class = SensorDeviceClass.ENERGY
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user