pub struct HomieController { /* private fields */ }
Expand description
A Homie controller, which connects to an MQTT broker and interacts with Homie devices.
Implementations§
Source§impl HomieController
impl HomieController
Sourcepub fn new(
mqtt_options: MqttOptions,
base_topic: &str,
) -> (HomieController, HomieEventLoop)
pub fn new( mqtt_options: MqttOptions, base_topic: &str, ) -> (HomieController, HomieEventLoop)
Create a new HomieController
connected to an MQTT broker.
§Arguments
base_topic
: The Homie base topic under which to look for Homie devices. “homie” is the recommended default.mqtt_options
: Options for the MQTT connection, including which broker to connect to.
Sourcepub fn devices(&self) -> Arc<HashMap<String, Device>>
pub fn devices(&self) -> Arc<HashMap<String, Device>>
Get a snapshot of the set of Homie devices which have been discovered so far, keyed by their IDs.
Sourcepub fn base_topic(&self) -> &str
pub fn base_topic(&self) -> &str
Get the Homie base topic which the controller was configured to use.
Sourcepub async fn poll(
&self,
event_loop: &mut HomieEventLoop,
) -> Result<Vec<Event>, PollError>
pub async fn poll( &self, event_loop: &mut HomieEventLoop, ) -> Result<Vec<Event>, PollError>
Poll the EventLoop
, and maybe return a Homie event.
Sourcepub async fn set(
&self,
device_id: &str,
node_id: &str,
property_id: &str,
value: impl Value,
) -> Result<(), ClientError>
pub async fn set( &self, device_id: &str, node_id: &str, property_id: &str, value: impl Value, ) -> Result<(), ClientError>
Attempt to set the state of a settable property of a device. If this succeeds the device will update the value of the property.
Sourcepub async fn disconnect(&self) -> Result<(), ClientError>
pub async fn disconnect(&self) -> Result<(), ClientError>
Disconnect from the MQTT broker.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HomieController
impl RefUnwindSafe for HomieController
impl Send for HomieController
impl Sync for HomieController
impl Unpin for HomieController
impl UnwindSafe for HomieController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more