aboutsummaryrefslogtreecommitdiff
path: root/src/entity.rs
blob: ac159217eb775fd58f0d95e9c69bb6a63cb8a742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::EntityCategory;

#[derive(Debug, Default)]
pub struct EntityCommonConfig {
    pub name: Option<&'static str>,
    pub icon: Option<&'static str>,
    pub category: Option<EntityCategory>,
    pub picture: Option<&'static str>,
}

impl EntityCommonConfig {
    pub(crate) fn populate(&self, config: &mut EntityConfig) {
        config.name = self.name;
        config.icon = self.icon;
        config.category = self.category.map(|c| c.as_str());
        config.picture = self.picture;
    }
}

#[derive(Default)]
pub struct EntityConfig {
    pub id: &'static str,
    pub name: Option<&'static str>,
    pub domain: &'static str,
    pub device_class: Option<&'static str>,
    pub measurement_unit: Option<&'static str>,
    pub icon: Option<&'static str>,
    pub picture: Option<&'static str>,
    pub category: Option<&'static str>,
    pub state_class: Option<&'static str>,
    pub schema: Option<&'static str>,
    pub min: Option<f32>,
    pub max: Option<f32>,
    pub step: Option<f32>,
    pub mode: Option<&'static str>,
}