Skip to content

Commit 986fc1a

Browse files
authored
Merge pull request #12 from chrivers/chrivers/z2m-fixes
After initial testing, a number of minor z2m modelling errors were discovered. Thanks to @joeblack2k for reporting this, and testing the fix. Fixes #6 (half here, half in an upcoming PR for supporting group prefixes)
2 parents 0f339be + 0ea2c6d commit 986fc1a

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

src/z2m/api.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ pub struct EndpointLink {
113113
pub ieee_address: IeeeAddress,
114114
}
115115

116+
#[derive(Debug, Serialize, Deserialize, Clone)]
117+
#[serde(deny_unknown_fields)]
118+
pub struct GroupLink {
119+
pub id: u32,
120+
}
121+
116122
#[derive(Debug, Serialize, Deserialize, Clone)]
117123
#[serde(deny_unknown_fields)]
118124
pub struct Scene {
@@ -150,6 +156,7 @@ pub struct BridgeConfigSchema {
150156
#[serde(deny_unknown_fields)]
151157
pub struct Config {
152158
pub advanced: ConfigAdvanced,
159+
pub availability: Value,
153160
pub blocklist: Vec<Option<Value>>,
154161
pub device_options: ConfigDeviceOptions,
155162
pub devices: HashMap<String, Value>,
@@ -175,15 +182,17 @@ pub struct Version {
175182
#[serde(deny_unknown_fields)]
176183
pub struct Network {
177184
pub channel: i64,
178-
pub extended_pan_id: f64,
185+
pub extended_pan_id: String,
179186
pub pan_id: i64,
180187
}
181188

182189
#[derive(Debug, Clone, Serialize, Deserialize)]
183190
#[serde(deny_unknown_fields)]
184191
pub struct Coordinator {
185192
pub ieee_address: IeeeAddress,
186-
pub meta: CoordinatorMeta,
193+
/* stict parsing disabled for now, format too volatile between versions */
194+
/* pub meta: CoordinatorMeta, */
195+
pub meta: Value,
187196
#[serde(rename = "type")]
188197
pub coordinator_type: String,
189198
}
@@ -238,7 +247,7 @@ pub struct CoordinatorMeta {
238247

239248
#[derive(Debug, Clone, Serialize, Deserialize)]
240249
pub struct ConfigSerial {
241-
pub adapter: String,
250+
pub adapter: Option<String>,
242251
pub disable_led: bool,
243252
pub port: String,
244253
}
@@ -303,7 +312,7 @@ pub struct Device {
303312
#[serde(default)]
304313
pub power_source: PowerSource,
305314
pub software_build_id: Option<String>,
306-
pub supported: bool,
315+
pub supported: Option<bool>,
307316
#[serde(rename = "type")]
308317
pub device_type: String,
309318
}
@@ -357,6 +366,7 @@ pub enum Expose {
357366
Enum(ExposeEnum),
358367
Light(ExposeLight),
359368
List(Value),
369+
Lock(ExposeLock),
360370
Numeric(ExposeNumeric),
361371
Switch(ExposeSwitch),
362372
}
@@ -369,7 +379,7 @@ impl Expose {
369379
Self::Composite(obj) => Some(obj.name.as_str()),
370380
Self::Enum(obj) => Some(obj.name.as_str()),
371381
Self::Numeric(obj) => Some(obj.name.as_str()),
372-
Self::Light(_) | Self::List(_) | Self::Switch(_) => None,
382+
Self::Light(_) | Self::List(_) | Self::Switch(_) | Self::Lock(_) => None,
373383
}
374384
}
375385
}
@@ -421,6 +431,12 @@ pub struct ExposeLight {
421431
pub features: Vec<Expose>,
422432
}
423433

434+
#[derive(Debug, Clone, Serialize, Deserialize)]
435+
pub struct ExposeLock {
436+
pub features: Vec<Expose>,
437+
pub label: String,
438+
}
439+
424440
impl ExposeLight {
425441
#[must_use]
426442
pub fn feature(&self, name: &str) -> Option<&Expose> {
@@ -442,8 +458,9 @@ pub struct ExposeNumeric {
442458

443459
pub unit: Option<String>,
444460
pub category: Option<String>,
445-
pub value_max: Option<i32>,
446-
pub value_min: Option<i32>,
461+
pub value_max: Option<f64>,
462+
pub value_min: Option<f64>,
463+
pub value_step: Option<f64>,
447464

448465
#[serde(default)]
449466
pub presets: Vec<Preset>,
@@ -485,7 +502,8 @@ pub struct ConfiguredReporting {
485502
pub cluster: String,
486503
pub maximum_report_interval: i32,
487504
pub minimum_report_interval: i32,
488-
pub reportable_change: i32,
505+
#[serde(default)]
506+
pub reportable_change: Value,
489507
}
490508

491509
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -506,6 +524,7 @@ pub struct Binding {
506524
#[derive(Debug, Clone, Serialize, Deserialize)]
507525
#[serde(tag = "type", rename_all = "lowercase")]
508526
pub enum BindingTarget {
527+
Group(GroupLink),
509528
Endpoint(EndpointLink),
510529
}
511530

src/z2m/update.rs

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ pub enum PowerOnBehavior {
135135

136136
#[serde(rename = "off")]
137137
Off,
138+
139+
#[serde(rename = "previous")]
140+
Previous,
138141
}
139142

140143
#[derive(Copy, Debug, Serialize, Deserialize, Clone)]

0 commit comments

Comments
 (0)