Homie Device¶
- class circuitpython_homie.HomieDevice(client: MQTT, name: str, device_id: str)[source]¶
A class to represent an instantiated Homie device.
- Parameters¶
- client: MQTT¶
An instance of an MQTT client object that the device will use to communicate with a MQTT broker.
- name: str¶
The device’s human friendly name.
- device_id: str¶
A unique identifying string for the device. This should adhere to the Homie ID specifications. Meaning only lowercase letters (a-z) or numbers or hyphens (
-) are allowed. This ID is prohibited from starting with a$and cannot begin or end with a-, thus these characters are stripped from the given input.
-
base_topic =
'homie'¶ The base topic used for all
HomieDeviceinstances (class attribute).
- begin(**mqtt_settings)[source]¶
Register this Homie device with the MQTT broker.
- client¶
The MQTT client object.
- enable_broadcast¶
A flag to control interaction with Homie’s
broadcasttopic.
- extensions¶
The supported Homie extensions (not implemented by this library).
-
implementation =
'CircuitPython on Linux'¶ The
implementationattribute used for allHomieDeviceinstances (class attribute). The platform specified by default is taken fromsysname.
- name¶
The device’s
nameattribute.
-
set_property(prop: HomieProperty, value, multi_node: bool =
False)[source]¶ Change a specified property’s value and publish it to the MQTT broker.
- Parameters¶
- prop: HomieProperty¶
the instance object representing the device node’s property.
- value¶
The new value for the property. The data type passed here will depend on the type of
HomieProperty(specified by thepropparameter) for which it is being applied.See also
The Recipes have derivatives of the
HomiePropertyclass with validators implemented accordingly.- multi_node: bool =
False¶ Set this to
Trueif the property is associated with multiple devicenodes. By default, only the first node found in association is updated on the MQTT broker.
- Throws¶
If the property is not associated with one of the device’s
nodes, then aValueErrorexception is raised.
- set_state(state: str)[source]¶
Set the device’s
stateattribute on the MQTT broker.- Parameters¶
- Throws¶
If the specified
statevalue is not a member ofDEVICE_STATES, then aValueErrorexception is raised.