Expand description
this is a very low level implemenation of the homie5 protocol in rust. it aims to be as flexible and unopinionated as possible. there is no direct dependency to a mqtt library. homie5 provides a basic support for a protocol implementation for homie v5 with a clearly defined interface point to a mqtt library. the library provides fully typed support for all homie5 datatypes.
due to this, the usage of the library is a bit more involved as with a completly ready to use homie library. benefit is however that you can use the library basically everywhere from a simple esp32, raspberrypi to a x86 machine.
you can find working examples for both device and controller use case in the examples/ folder:
- controller_example.rs: implements a homie5 controller that will discover all homie5 devices on a mqtt broker and print out the devices and their property updates (more information).
- device_example.rs: implements a simple lightdevice with state and brightness control properties (more information).
both examples use rumqttc as a mqtt client implementation and provide a best practice in homie5 usage and in how to integrate the 2 libraries.
Modules§
- client
- This module provides MQTT primitives for library-agnostic message handling.
- device_
description - This module provides all types and tools to create (builders) and manage homie device, node and property descriptions.
- extensions
Structs§
- Custom
Domain - Device
Ref - Identifies a device via homie-domain and the device id
- Device
Subscription Iterator - Homie5
Controller Protocol - The
Homie5ControllerProtocol
struct provides the core functionality for generating MQTT subscription and publish commands required for interacting with Homie 5 devices. - Homie5
Device Protocol - Represents the Homie v5 protocol implementation for a device, providing methods for publishing state, logging, and handling properties.
- HomieID
- Represents a validated Homie ID.
- Invalid
Homie Domain Error - Error type returned when a string fails to validate as a custom homie-domain.
- Invalid
HomieID Error - Error type returned when a string fails to validate as a Homie ID.
- NodeRef
- Identifies a node of a device via its DeviceRef and its node id
- Property
Pointer - Property
Ref - Identifies a property of a node via its NodeRef and the property id
- Topic
Builder
Enums§
- Device
Disconnect Step - Represents the steps required to disconnect a Homie device.
- Device
LogLevel - Device
Publish Step - Represents the steps required to publish a Homie device.
- Device
Reconfigure Step - Represents the steps required to reconfigure a Homie device.
- Homie5
Message - Represents all possible MQTT message types according to the Homie 5 protocol. These messages define the interactions between devices, their attributes, and the broker.
- Homie5
Protocol Error - Represents various errors that can occur while handling the Homie v5 protocol.
- Homie5
Value Conversion Error - Homie
Color Value - Represents color values supported by the Homie protocol.
- Homie
Data Type - Datatypes in the homie protocol
- Homie
Device Status - Reflects the current state of the device.
- Homie
Domain - Homie
Value - Represents the various data types supported by the Homie protocol.
Constants§
- DEFAULT_
HOMIE_ DOMAIN - The default mqtt root topic: “homie”
- DEVICE_
ATTRIBUTES - A list of all the device attributes to be published or subscribed to
- DEVICE_
ATTRIBUTE_ ALERT - Device alert attribute topic: “$state”
- DEVICE_
ATTRIBUTE_ DESCRIPTION - Device description attribute topic: “$description”
- DEVICE_
ATTRIBUTE_ LOG - Device log attribute topic: “$log”
- DEVICE_
ATTRIBUTE_ STATE - Device state attribute topic: “$state”
- HOMIE_
TOPIC_ BROADCAST - Broadcast topic: “$broadcast”
- HOMIE_
UNIT_ AMPERE - unit for electric current in amperes
- HOMIE_
UNIT_ COUNT_ AMOUNT - unit for countable amounts
- HOMIE_
UNIT_ CUBIC_ METER - unit for volume in cubic meters
- HOMIE_
UNIT_ DEGREE - unit for generic degrees
- HOMIE_
UNIT_ DEGREE_ CELSIUS - unit for degrees in Celsius
- HOMIE_
UNIT_ DEGREE_ FAHRENHEIT - unit for degrees in Fahrenheit
- HOMIE_
UNIT_ FEET - unit for length in feet
- HOMIE_
UNIT_ GALLON - unit for volume in gallons
- HOMIE_
UNIT_ HERTZ - unit for frequency in hertz
- HOMIE_
UNIT_ HOURS - unit for time in hours
- HOMIE_
UNIT_ KELVIN - unit for temperature in kelvin
- HOMIE_
UNIT_ KILOPASCAL - unit for pressure in kilopascals
- HOMIE_
UNIT_ KILOWATT - unit for power in kilowatts
- HOMIE_
UNIT_ KILOWATTHOUR - unit for energy in kilowatt-hours
- HOMIE_
UNIT_ LITER - unit for volume in liters
- HOMIE_
UNIT_ LUX - unit for illuminance in lux
- HOMIE_
UNIT_ METER - unit for length in meters
- HOMIE_
UNIT_ MILI_ AMPERE - unit for electric current in milliamperes
- HOMIE_
UNIT_ MINUTES - unit for time in minutes
- HOMIE_
UNIT_ MIRED - unit for color temperature in mireds (reciprocal megakelvin)
- HOMIE_
UNIT_ PASCAL - unit for pressure in pascals
- HOMIE_
UNIT_ PERCENT - unit for percentage
- HOMIE_
UNIT_ PSI - unit for pressure in pounds per square inch
- HOMIE_
UNIT_ SECONDS - unit for time in seconds
- HOMIE_
UNIT_ VOLT - unit for voltage in volts
- HOMIE_
UNIT_ WATT - unit for power in watts
- HOMIE_
VERSION - Homie major version used in the mqtt topic creation: “5”
- HOMIE_
VERSION_ FULL - Homie protocol verison used in the device description: “5.0”
- PROPERTY_
ATTRIBUTE_ TARGET - Property $target attribute topic under which the device can publish the desired target state
- PROPERTY_
SET_ TOPIC - Property set attribute topic under which a set action is published to alter the devices state: “set”
Traits§
- AsNode
Id - AsProp
Pointer - ToTopic
- This trait provides the capability to provide a mqtt topic for an object defining where it is published on the broker
Functions§
- homie_
device_ disconnect_ steps - Provides an iterator that yields all the necessary steps for disconnecting a device in order.
- homie_
device_ publish_ steps - Provides an iterator that yields all the necessary steps for publishing a device in order.
- homie_
device_ reconfigure_ steps - Provides an iterator that yields all the necessary steps for reconfiguring a device in order.
- homie_
str_ to_ vecu8 - parse_
mqtt_ message - Parses an incoming MQTT message into a
Homie5Message
.