diff options
| -rw-r--r-- | src/constants.rs | 4 | ||||
| -rw-r--r-- | src/entity_sensor.rs | 18 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/constants.rs b/src/constants.rs index 2b1a8bf..30ba4f1 100644 --- a/src/constants.rs +++ b/src/constants.rs | |||
| @@ -12,6 +12,10 @@ pub const HA_NUMBER_MODE_AUTO: &str = "auto"; | |||
| 12 | pub const HA_NUMBER_MODE_BOX: &str = "box"; | 12 | pub const HA_NUMBER_MODE_BOX: &str = "box"; |
| 13 | pub const HA_NUMBER_MODE_SLIDER: &str = "slider"; | 13 | pub const HA_NUMBER_MODE_SLIDER: &str = "slider"; |
| 14 | 14 | ||
| 15 | pub const HA_STATE_CLASS_MEASUREMENT: &str = "measurement"; | ||
| 16 | pub const HA_STATE_CLASS_TOTAL: &str = "total"; | ||
| 17 | pub const HA_STATE_CLASS_TOTAL_INCREASING: &str = "total_increasing"; | ||
| 18 | |||
| 15 | pub const HA_DEVICE_CLASS_SENSOR_APPARENT_POWER: &str = "apparent_power"; | 19 | pub const HA_DEVICE_CLASS_SENSOR_APPARENT_POWER: &str = "apparent_power"; |
| 16 | pub const HA_DEVICE_CLASS_SENSOR_AQI: &str = "aqi"; | 20 | pub const HA_DEVICE_CLASS_SENSOR_AQI: &str = "aqi"; |
| 17 | pub const HA_DEVICE_CLASS_SENSOR_ATMOSPHERIC_PRESSURE: &str = "atmospheric_pressure"; | 21 | pub const HA_DEVICE_CLASS_SENSOR_ATMOSPHERIC_PRESSURE: &str = "atmospheric_pressure"; |
diff --git a/src/entity_sensor.rs b/src/entity_sensor.rs index d70e80e..4b84c66 100644 --- a/src/entity_sensor.rs +++ b/src/entity_sensor.rs | |||
| @@ -2,6 +2,24 @@ use crate::{ | |||
| 2 | Entity, EntityCommonConfig, EntityConfig, NumericSensorState, TemperatureUnit, constants, | 2 | Entity, EntityCommonConfig, EntityConfig, NumericSensorState, TemperatureUnit, constants, |
| 3 | }; | 3 | }; |
| 4 | 4 | ||
| 5 | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] | ||
| 6 | pub enum StateClass { | ||
| 7 | #[default] | ||
| 8 | Measurement, | ||
| 9 | Total, | ||
| 10 | TotalIncreasing, | ||
| 11 | } | ||
| 12 | |||
| 13 | impl StateClass { | ||
| 14 | pub fn as_str(&self) -> &'static str { | ||
| 15 | match self { | ||
| 16 | StateClass::Measurement => constants::HA_STATE_CLASS_MEASUREMENT, | ||
| 17 | StateClass::Total => constants::HA_STATE_CLASS_TOTAL, | ||
| 18 | StateClass::TotalIncreasing => constants::HA_STATE_CLASS_TOTAL_INCREASING, | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 5 | #[derive(Debug, Default)] | 23 | #[derive(Debug, Default)] |
| 6 | pub struct TemperatureSensorConfig { | 24 | pub struct TemperatureSensorConfig { |
| 7 | pub common: EntityCommonConfig, | 25 | pub common: EntityCommonConfig, |
