Add mcutie MQTT client implementation and improve library structure
- Integrated `mcutie` library as a core MQTT client for device communication. - Added support for Home Assistant entities (binary sensor, button) via MQTT. - Implemented buffer management, async operations, and packet encoding/decoding. - Introduced structured error handling and device registration features. - Updated `Cargo.toml` with new dependencies and enabled feature flags for `serde` and `log`. - Enhanced logging macros with configurable options (`defmt` or `log`). - Organized codebase into modules (buffer, components, IO, publish, etc.) for better maintainability. fix legacy dependecencies and compatiblity with mcutie vendored lib fix shit i hate this
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
//! Tools for publishing a [Home Assistant button](https://www.home-assistant.io/integrations/button.mqtt/).
|
||||
use core::ops::Deref;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{homeassistant::Component, Error, Topic};
|
||||
|
||||
/// The type of button.
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[allow(missing_docs)]
|
||||
pub enum ButtonClass {
|
||||
Identify,
|
||||
Restart,
|
||||
Update,
|
||||
}
|
||||
|
||||
/// A button that can be pressed.
|
||||
#[derive(Serialize)]
|
||||
pub struct Button {
|
||||
/// The type of button.
|
||||
pub device_class: Option<ButtonClass>,
|
||||
}
|
||||
|
||||
impl Component for Button {
|
||||
type State = ();
|
||||
|
||||
fn platform() -> &'static str {
|
||||
"button"
|
||||
}
|
||||
|
||||
async fn publish_state<T: Deref<Target = str>>(
|
||||
&self,
|
||||
_topic: &Topic<T>,
|
||||
_state: Self::State,
|
||||
) -> Result<(), Error> {
|
||||
// Buttons don't have a state
|
||||
Err(Error::Invalid)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user