You don't have to instantiate an Homie
instance, it is done internally.
Setup Homie. Must be called once in setup()
.
Handle Homie work. Must be called in loop()
.
Enable or disable Homie Serial logging.
If logging is enabled, Serial.begin(115200)
will be called internally.
enable
: Whether or not to enable logging. By default, logging is enabled
Enable or disable the built-in LED to indicate the Homie state.
enable
: Whether or not to enable built-in LED. By default, it is enabled
Set pin of the LED to control.
pin
: LED to controlon
: state when the light is on (HIGH or LOW)
Set the brand of the device, used in the configuration AP, the device hostname and the MQTT client ID.
name
: Name of the brand. Default value isHomie
Set the name and version of the firmware. This is useful for OTA, as Homie will check against the server if there is a newer version.
name
: Name of the firmware. Default value isundefined
version
: Version of the firmware. Default value isundefined
Register a node.
node
: node to register
void Homie.setGlobalInputHandler (std::function<bool(String nodeId, String property, String value)> handler
)
Set input handler for subscribed properties.
handler
: Global input handlernode
: Name of the node getting updatedproperty
: Property of the node getting updatedvalue
: Value of the new property
Set the event handler. Useful if you want to hook to Homie events.
callback
: Event handler
Set the reset trigger. By default, the device will reset when pin 0
is LOW
for 5000
ms.
pin
: Pin of the reset triggerstate
: Reset when the pin reaches this state for the given timetime
: Time necessary to reset
Disable the reset trigger.
Set the reset function. This is a function that is going to be called at each loop iteration, which can trigger a device reset. If the function returns true, the device resets. Else, it does not.
callback
: Reset function
You can provide the function that will be called when operating in normal
mode.
callback
: Setup function
You can provide the function that will be looped in normal mode.
callback
: Loop function
Using this function, you can set the value of a node property, like a temperature for example.
node
: HomieNode instance on which to set the property onproperty
: Property to sendvalue
: Payloadretained
: Optional. Should the MQTT broker retain this value, or is it a one-shot value?
Is the device resettable? This is useful at runtime, because you might want the device not to be resettable when you have another library that is doing some unfinished work, like moving shutters for example.
resettable
: Is the device resettable? Default value istrue
Is the device in normal mode, configured and connected? You should not need this function. But maybe you will.
void HomieNode (const char* id
, const char* type
, std::function<bool(String property, String value)> handler
= , bool subscribeToAll
= false)
Constructor of a HomieNode object.
id
: ID of the nodetype
: Type of the nodehandler
: Optional. Input handler of the nodesubscribeToAll
: Optional. Whether or not to call the handler for every properties, even the ones not registered
Subscribes the node to the given property.
property
: Property to subscribe tohandler
: Optional. Input handler of the property of the node