aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-12-09 22:58:31 +0000
committerdiogo464 <[email protected]>2025-12-09 22:58:31 +0000
commit4687daaf620e0d0951e4657d052eaa713d18fa71 (patch)
tree969d8f67a9af7e0b5b7488478cb329a1185923c2
parent9aed552c491aaabc84e3141bc70e4d26c03efa85 (diff)
small visibility fixesv0.1.0
-rw-r--r--README.md1
-rw-r--r--src/entity.rs2
-rw-r--r--src/lib.rs38
-rw-r--r--src/log.rs2
4 files changed, 27 insertions, 16 deletions
diff --git a/README.md b/README.md
index 7c773cb..4b8f818 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
3Home Assistant MQTT device library for embassy. 3Home Assistant MQTT device library for embassy.
4 4
5To create a device use the [`new`] function. 5To create a device use the [`new`] function.
6
6After the device is created you should create one or more entities using functions such as 7After the device is created you should create one or more entities using functions such as
7[`create_button`]/[`create_sensor`]/... 8[`create_button`]/[`create_sensor`]/...
8 9
diff --git a/src/entity.rs b/src/entity.rs
index ef2b9ad..e7aa895 100644
--- a/src/entity.rs
+++ b/src/entity.rs
@@ -18,7 +18,7 @@ impl EntityCommonConfig {
18} 18}
19 19
20#[derive(Default)] 20#[derive(Default)]
21pub struct EntityConfig { 21pub(crate) struct EntityConfig {
22 pub id: &'static str, 22 pub id: &'static str,
23 pub name: Option<&'static str>, 23 pub name: Option<&'static str>,
24 pub domain: &'static str, 24 pub domain: &'static str,
diff --git a/src/lib.rs b/src/lib.rs
index 50c6308..234d0e9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,7 @@
1//! Home Assistant MQTT device library for embassy. 1//! Home Assistant MQTT device library for embassy.
2//! 2//!
3//! To create a device use the [`new`] function. 3//! To create a device use the [`new`] function.
4//!
4//! After the device is created you should create one or more entities using functions such as 5//! After the device is created you should create one or more entities using functions such as
5//! [`create_button`]/[`create_sensor`]/... 6//! [`create_button`]/[`create_sensor`]/...
6//! 7//!
@@ -30,8 +31,9 @@ use serde::Serialize;
30 31
31mod mqtt; 32mod mqtt;
32 33
33pub mod log; 34mod log;
34pub use log::Format; 35#[allow(unused)]
36use log::Format;
35 37
36pub mod constants; 38pub mod constants;
37 39
@@ -250,73 +252,79 @@ impl Default for DeviceResources {
250} 252}
251 253
252#[derive(Debug, Default)] 254#[derive(Debug, Default)]
253pub struct ButtonStorage { 255pub(crate) struct ButtonStorage {
254 pub timestamp: Option<embassy_time::Instant>, 256 pub timestamp: Option<embassy_time::Instant>,
255 pub consumed: bool, 257 pub consumed: bool,
256} 258}
257 259
258#[derive(Debug)] 260#[derive(Debug)]
259pub struct SwitchCommand { 261pub(crate) struct SwitchCommand {
260 pub value: BinaryState, 262 pub value: BinaryState,
263 #[allow(unused)]
261 pub timestamp: embassy_time::Instant, 264 pub timestamp: embassy_time::Instant,
262} 265}
263 266
264#[derive(Debug)] 267#[derive(Debug)]
265pub struct SwitchState { 268pub(crate) struct SwitchState {
266 pub value: BinaryState, 269 pub value: BinaryState,
270 #[allow(unused)]
267 pub timestamp: embassy_time::Instant, 271 pub timestamp: embassy_time::Instant,
268} 272}
269 273
270#[derive(Debug, Default)] 274#[derive(Debug, Default)]
271pub struct SwitchStorage { 275pub(crate) struct SwitchStorage {
272 pub state: Option<SwitchState>, 276 pub state: Option<SwitchState>,
273 pub command: Option<SwitchCommand>, 277 pub command: Option<SwitchCommand>,
274 pub publish_on_command: bool, 278 pub publish_on_command: bool,
275} 279}
276 280
277#[derive(Debug)] 281#[derive(Debug)]
278pub struct BinarySensorState { 282pub(crate) struct BinarySensorState {
279 pub value: BinaryState, 283 pub value: BinaryState,
284 #[allow(unused)]
280 pub timestamp: embassy_time::Instant, 285 pub timestamp: embassy_time::Instant,
281} 286}
282 287
283#[derive(Debug, Default)] 288#[derive(Debug, Default)]
284pub struct BinarySensorStorage { 289pub(crate) struct BinarySensorStorage {
285 pub state: Option<BinarySensorState>, 290 pub state: Option<BinarySensorState>,
286} 291}
287 292
288#[derive(Debug)] 293#[derive(Debug)]
289pub struct NumericSensorState { 294pub(crate) struct NumericSensorState {
290 pub value: f32, 295 pub value: f32,
296 #[allow(unused)]
291 pub timestamp: embassy_time::Instant, 297 pub timestamp: embassy_time::Instant,
292} 298}
293 299
294#[derive(Debug, Default)] 300#[derive(Debug, Default)]
295pub struct NumericSensorStorage { 301pub(crate) struct NumericSensorStorage {
296 pub state: Option<NumericSensorState>, 302 pub state: Option<NumericSensorState>,
297} 303}
298 304
299#[derive(Debug)] 305#[derive(Debug)]
300pub struct NumberState { 306pub(crate) struct NumberState {
301 pub value: f32, 307 pub value: f32,
308 #[allow(unused)]
302 pub timestamp: embassy_time::Instant, 309 pub timestamp: embassy_time::Instant,
303} 310}
304 311
305#[derive(Debug)] 312#[derive(Debug)]
306pub struct NumberCommand { 313pub(crate) struct NumberCommand {
307 pub value: f32, 314 pub value: f32,
315 #[allow(unused)]
308 pub timestamp: embassy_time::Instant, 316 pub timestamp: embassy_time::Instant,
309} 317}
310 318
311#[derive(Debug, Default)] 319#[derive(Debug, Default)]
312pub struct NumberStorage { 320pub(crate) struct NumberStorage {
313 pub state: Option<NumberState>, 321 pub state: Option<NumberState>,
314 pub command: Option<NumberCommand>, 322 pub command: Option<NumberCommand>,
315 pub publish_on_command: bool, 323 pub publish_on_command: bool,
316} 324}
317 325
318#[derive(Debug)] 326#[derive(Debug)]
319pub enum EntityStorage { 327pub(crate) enum EntityStorage {
320 Button(ButtonStorage), 328 Button(ButtonStorage),
321 Switch(SwitchStorage), 329 Switch(SwitchStorage),
322 BinarySensor(BinarySensorStorage), 330 BinarySensor(BinarySensorStorage),
@@ -369,7 +377,7 @@ struct EntityData {
369 command_waker: Option<Waker>, 377 command_waker: Option<Waker>,
370} 378}
371 379
372pub struct Entity<'a> { 380pub(crate) struct Entity<'a> {
373 pub(crate) data: &'a RefCell<Option<EntityData>>, 381 pub(crate) data: &'a RefCell<Option<EntityData>>,
374 pub(crate) waker: &'a AtomicWaker, 382 pub(crate) waker: &'a AtomicWaker,
375} 383}
diff --git a/src/log.rs b/src/log.rs
index 5b67001..b86f522 100644
--- a/src/log.rs
+++ b/src/log.rs
@@ -24,6 +24,7 @@
24pub use defmt::Format; 24pub use defmt::Format;
25 25
26// For tracing or no logging, we provide a stub Format trait 26// For tracing or no logging, we provide a stub Format trait
27#[allow(unused)]
27#[cfg(not(feature = "defmt"))] 28#[cfg(not(feature = "defmt"))]
28pub trait Format {} 29pub trait Format {}
29 30
@@ -113,4 +114,5 @@ macro_rules! error {
113} 114}
114 115
115// Re-export the macros at the module level for easier use 116// Re-export the macros at the module level for easier use
117#[allow(unused)]
116pub use crate::{debug, error, info, trace, warn}; 118pub use crate::{debug, error, info, trace, warn};