diff options
| author | diogo464 <[email protected]> | 2025-12-04 12:43:29 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-04 12:43:29 +0000 |
| commit | 98fd2306503a3ca80b9dfbdf4744547c836151c2 (patch) | |
| tree | d71edea00132cb349a431118716a284d90a8484d /src | |
| parent | 3289c2d9f6257f68cbdd37b78e5e79a41e9e33a1 (diff) | |
fixed temperature units
Diffstat (limited to 'src')
| -rw-r--r-- | src/constants.rs | 4 | ||||
| -rw-r--r-- | src/unit.rs | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/constants.rs b/src/constants.rs index a67b6fe..ca4e53c 100644 --- a/src/constants.rs +++ b/src/constants.rs | |||
| @@ -95,3 +95,7 @@ pub const HA_DEVICE_CLASS_BUTTON_UPDATE: &str = "update"; | |||
| 95 | 95 | ||
| 96 | pub const HA_DEVICE_CLASS_SWITCH_OUTLET: &str = "outlet"; | 96 | pub const HA_DEVICE_CLASS_SWITCH_OUTLET: &str = "outlet"; |
| 97 | pub const HA_DEVICE_CLASS_SWITCH_SWITCH: &str = "switch"; | 97 | pub const HA_DEVICE_CLASS_SWITCH_SWITCH: &str = "switch"; |
| 98 | |||
| 99 | pub const HA_UNIT_TEMPERATURE_CELSIUS: &str = "°C"; | ||
| 100 | pub const HA_UNIT_TEMPERATURE_KELVIN: &str = "K"; | ||
| 101 | pub const HA_UNIT_TEMPERATURE_FAHRENHEIT: &str = "°F"; | ||
diff --git a/src/unit.rs b/src/unit.rs index 4f3ca19..f0557da 100644 --- a/src/unit.rs +++ b/src/unit.rs | |||
| @@ -8,11 +8,10 @@ pub enum TemperatureUnit { | |||
| 8 | 8 | ||
| 9 | impl TemperatureUnit { | 9 | impl TemperatureUnit { |
| 10 | pub fn as_str(&self) -> &'static str { | 10 | pub fn as_str(&self) -> &'static str { |
| 11 | // TODO: improve | ||
| 12 | match self { | 11 | match self { |
| 13 | TemperatureUnit::Celcius => "C", | 12 | TemperatureUnit::Celcius => crate::constants::HA_UNIT_TEMPERATURE_CELSIUS, |
| 14 | TemperatureUnit::Kelvin => "k", | 13 | TemperatureUnit::Kelvin => crate::constants::HA_UNIT_TEMPERATURE_KELVIN, |
| 15 | TemperatureUnit::Fahrenheit => "F", | 14 | TemperatureUnit::Fahrenheit => crate::constants::HA_UNIT_TEMPERATURE_FAHRENHEIT, |
| 16 | TemperatureUnit::Other(other) => other, | 15 | TemperatureUnit::Other(other) => other, |
| 17 | } | 16 | } |
| 18 | } | 17 | } |
