Use new enums in saj (#62205)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
1d1c91a4eb
commit
19fc15c3ac
1 changed files with 7 additions and 10 deletions
|
@ -9,9 +9,9 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -19,9 +19,6 @@ from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
@ -178,9 +175,9 @@ class SAJsensor(SensorEntity):
|
||||||
self._state = self._sensor.value
|
self._state = self._sensor.value
|
||||||
|
|
||||||
if pysaj_sensor.name in ("current_power", "temperature"):
|
if pysaj_sensor.name in ("current_power", "temperature"):
|
||||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
if pysaj_sensor.name == "total_yield":
|
if pysaj_sensor.name == "total_yield":
|
||||||
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -204,14 +201,14 @@ class SAJsensor(SensorEntity):
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the device class the sensor belongs to."""
|
"""Return the device class the sensor belongs to."""
|
||||||
if self.unit_of_measurement == POWER_WATT:
|
if self.unit_of_measurement == POWER_WATT:
|
||||||
return DEVICE_CLASS_POWER
|
return SensorDeviceClass.POWER
|
||||||
if self.unit_of_measurement == ENERGY_KILO_WATT_HOUR:
|
if self.unit_of_measurement == ENERGY_KILO_WATT_HOUR:
|
||||||
return DEVICE_CLASS_ENERGY
|
return SensorDeviceClass.ENERGY
|
||||||
if (
|
if (
|
||||||
self.unit_of_measurement == TEMP_CELSIUS
|
self.unit_of_measurement == TEMP_CELSIUS
|
||||||
or self._sensor.unit == TEMP_FAHRENHEIT
|
or self._sensor.unit == TEMP_FAHRENHEIT
|
||||||
):
|
):
|
||||||
return DEVICE_CLASS_TEMPERATURE
|
return SensorDeviceClass.TEMPERATURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self) -> bool:
|
def should_poll(self) -> bool:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue