homie_dart library

An implementation of the homie convention version 4.0 in dart. This library does not support the homie broadcast channel. To implement a device extend the Device class and add some Node with Property.

Extensions can be created and added do devices, nodes, or properties. See the subclasses of Extension for more information. Version 4.0 of the convention removes some device attributes, such as stats and mac address. If you want to keep these attributes you can use the LegacyStats and LegacyFirmware extensions found in the homie_legacy_extensions library, which is also part of this package.

The version 3.0.1 of the homie convention requires an ip and a mac address to be liked to a device. These values can be set using the top-level properties defaultIp and defaultMac. The top-level property qos denots the quality of service for mqtt protocoll and can be adjusted.

To connect the device, call its Device.init method. This requries an object of type BrokerConnection, which handels the underlying mqtt connection. This package only declares the abstract class BrokerConnection and does not come with a concret implementation of it. Either implement it yourselfe or use the package homie_dart_on_mqtt_client which exports functionality of this package, and provides an implementation of BrokerConnection.

Classes

BooleanProperty
A property to represent the homie Bool datatype.
BooleanPropertyRetained
A retained version of BooleanProperty. See RetainedMixin and BooleanProperty for more information.
BrokerConnection
Used for connection to a mqtt broker. The homie_dart package does not contain an implementation of this abstract class! Implement the mqtt logic yourselfe or use the homie_dart_on_mqtt package instead (recommended)!
Device
Subclass this class to create a new homie device.
DeviceExtension
Used to extend a Device. The DeviceExtension class contains the versioning and identification infromation for an extension as defined by that extensions speficiation. On the other hand NodeExtensions and PropertyExtenisons do not contain this information and therefor "have to belong to" a DeviceExtension. This means, that for each used NodeExtension or PropertyExtension there must be a matching DeviceExtension added to the Device, even if it does nothing to extend the Device other than provide these information.
EnumProperty
A property to represent the homie Enum datatype, based on a list of possible String values. If you want use a real dart enum as base for this property, and not a List<String> take a look at MappedEnumProperty.
EnumPropertyRetained
A retained version of EnumProperty. See RetainedMixin and EnumProperty for more information.
Extension
Base class of DeviceExtension, NodeExtension and PropertyExtension. Extensions can freely publish to topics and are informed on certian events.
FloatProperty
A property to represent the homie Float datatype.
FloatPropertyRetained
A retained version of FloatProperty. See RetainedMixin and FloatProperty for more information.
HomieTopic<E extends Extension>
Baseclass for Device, Node and Property.
HsvColor
HsvColorProperty
A property to represent the homie Color datatype inf hsv format.
HsvColorPropertyRetained
A retained version of HsvColorProperty. See RetainedMixin and HsvColorProperty for more information.
IntegerProperty
A property to represent the homie Integer datatype.
IntegerPropertyRetained
A retained version of IntegerProperty. See RetainedMixin and IntegerProperty for more information.
MappedEnumProperty<K>
An implementation of the homie enum datatype property that requires to be linked to a dart enum. If you don not want to use a dart enum for the property but rather a List<String> as underyling representaion, take a look at the EnumProperty class. The type argument of this class should be an enum.
MappedEnumPropertyRetained<K>
A retained version of MappedEnumProperty. See RetainedMixin and MappedEnumProperty for more information.
Node
This class represents a homie node. Nodes are added to devices. Each node object must only be part of one device!
NodeExtension
Used to extend a Node.
Property<T, V extends Property<T, V>>
Represents a homie property. Properties can be added to Nodes which then are added to devices. Each property must only be part of one node! There are implementations properties with all datatypes as defined in the homie convention, in a non-retained and in a retained variant. The typeargument T denotes the representation of the value of the property. For most datatypes, homie uses Strings, so the property class is responsible to translate its value to a String and vice versa. The typeargument V is needed so that an EventListener knows, of what type the property is.
PropertyExtension
Used to extend a Property.
RgbColor
RgbColorProperty
A property to represent the homie Color datatype inf rgb format.
RgbColorPropertyRetained
A retained version of RgbColorProperty. See RetainedMixin and RgbColorProperty for more information.
StringProperty
A property to represent the homie String datatype.
StringPropertyRetained
A retained version of StringProperty. See RetainedMixin and StringProperty for more information.
Unit
Used for unit representation. The constantss in this class are units recommended by the the homie convention. Custom units are valid, too.

Mixins

RetainedMixin<T, V extends Property<T, V>>
Mixin this to make a Property retained. In the constructor of your property you have to call the withInitialValue() method with a initial value for the property. A retained property stores the current value of the property. The stored value is updated by a call to publishValue.

Constants

defaultConventionVersion → const String
The homie convention version this library implements.
"4.0"
defaultRoot → const String
The default mqtt topic root as recommended by the homie convention.
"homie/"
emptyPayload → const String
An empty string which will translate to an empty payload for sending through the mqtt broker. Retained topics that receive an empty payload are removed by the broker.
''
homieFloatMax → const double
The biggest value a float can represend according to the homie convention.
3.4028234663852885981170418348451692544e+38
homieFloatMin → const double
The smalles value a float can represend according to the homie convention.
-homieFloatMax
homieIntMax → const int
The biggest value an int can represend according to the homie convention.
9223372036854775807
homieIntMin → const int
The smalles value an int can represend according to the homie convention.
-9223372036854775808

Properties

qos ↔ int
The Quality of Service the library uses. The homie convention recommends 1.
read / write

Functions

isValidId(String id) → bool
Checks if the given String is a valid Id according to the homie convention. A valid id may only contain of lowercase letters from a to z and numbers from 0 to 9. In addition, hyphens (-) are allowed, but not as first or last character in the Id. An id must not be empty.

Enums

DeviceState
A enum for all device states defined by the homie convention.
HomieDatatype
A enum representing all datatypes defined in the homie convention.

Typedefs

EventListener<T, V extends Property<T, V>>(V property, T command) → Future<Null>
Triggered when an settable property receives a set command. If the property is retained, the publishValue method should be executed with the new value of this property, to let the homie controller know, that the set command was processed.

Exceptions / Errors

DisconnectingError
Thrown by the BrokerConnection when trying to publish or to subscribe to a topic while currently disconnecting.