diff options
| author | diogo464 <[email protected]> | 2025-12-06 08:39:53 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-06 08:39:53 +0000 |
| commit | 1bdeab31af0154fd3e66ae46ae510669be25b272 (patch) | |
| tree | 090bdcb28b702348860b737059f066f24d8db8bb /src/entity_sensor.rs | |
| parent | f64200686f402157e525158f6133763bdfdc2b58 (diff) | |
added state class constants/enum
Diffstat (limited to 'src/entity_sensor.rs')
| -rw-r--r-- | src/entity_sensor.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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, |
