diff options
| author | diogo464 <[email protected]> | 2025-12-05 12:17:01 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-05 12:17:01 +0000 |
| commit | 0c86da392af50c7588b087c3f72602e8368af65e (patch) | |
| tree | 894cd2f353298b83a56cde06eafd7b1e366aa6b3 /src/entity.rs | |
| parent | 1d2ee64d0ec917a2c2b66f8d58e1f37dd174a89d (diff) | |
reworked entity creation
Diffstat (limited to 'src/entity.rs')
| -rw-r--r-- | src/entity.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/entity.rs b/src/entity.rs new file mode 100644 index 0000000..ac15921 --- /dev/null +++ b/src/entity.rs | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | use crate::EntityCategory; | ||
| 2 | |||
| 3 | #[derive(Debug, Default)] | ||
| 4 | pub struct EntityCommonConfig { | ||
| 5 | pub name: Option<&'static str>, | ||
| 6 | pub icon: Option<&'static str>, | ||
| 7 | pub category: Option<EntityCategory>, | ||
| 8 | pub picture: Option<&'static str>, | ||
| 9 | } | ||
| 10 | |||
| 11 | impl EntityCommonConfig { | ||
| 12 | pub(crate) fn populate(&self, config: &mut EntityConfig) { | ||
| 13 | config.name = self.name; | ||
| 14 | config.icon = self.icon; | ||
| 15 | config.category = self.category.map(|c| c.as_str()); | ||
| 16 | config.picture = self.picture; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | #[derive(Default)] | ||
| 21 | pub struct EntityConfig { | ||
| 22 | pub id: &'static str, | ||
| 23 | pub name: Option<&'static str>, | ||
| 24 | pub domain: &'static str, | ||
| 25 | pub device_class: Option<&'static str>, | ||
| 26 | pub measurement_unit: Option<&'static str>, | ||
| 27 | pub icon: Option<&'static str>, | ||
| 28 | pub picture: Option<&'static str>, | ||
| 29 | pub category: Option<&'static str>, | ||
| 30 | pub state_class: Option<&'static str>, | ||
| 31 | pub schema: Option<&'static str>, | ||
| 32 | pub min: Option<f32>, | ||
| 33 | pub max: Option<f32>, | ||
| 34 | pub step: Option<f32>, | ||
| 35 | pub mode: Option<&'static str>, | ||
| 36 | } | ||
