EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HAEntity Class Reference

#include <haEntity.h>

Inheritance diagram for HAEntity:
HABinarySensor HACover HASensor HASwitch HATrigger

Public Member Functions

size_t getAnounceMessage (int bufferlen, uint8_t *buffer)
 Gets entity anounce message to be sent over EnigmaIOT message. More...
 
void setNameSufix (const char *payload)
 Sets name suffix. Used for multi entity nodes. More...
 
void allowSendAttributes ()
 Enables registering entity attributes as a json object. More...
 
size_t measureMessage ()
 Gets needed buffer size for discovery message. More...
 

Static Public Member Functions

static String deviceTypeStr (haDeviceType_t entityType)
 Gets entity type string from haDeviceType_t value https://www.home-assistant.io/docs/mqtt/discovery/. More...
 
static String getDiscoveryTopic (const char *hassPrefix, const char *nodeName, haDeviceType_t entityType, const char *nameSuffix=NULL)
 Allows Gateway to get discovery message MQTT topic. More...
 

Protected Member Functions

 HAEntity ()
 Default constructor. Needed for inheritance. More...
 

Protected Attributes

size_t capacity
 JSON object memory reservation length. More...
 
haDeviceType_t deviceType = UNDEFINED
 HomeAssistant entity device type. More...
 
DynamicJsonDocument * entityConfig
 JSON object to be sent to gateway. More...
 

Detailed Description

Definition at line 132 of file haEntity.h.

Constructor & Destructor Documentation

◆ HAEntity()

HAEntity::HAEntity ( )
inlineprotected

Default constructor. Needed for inheritance.

Definition at line 143 of file haEntity.h.

Member Function Documentation

◆ allowSendAttributes()

void HAEntity::allowSendAttributes ( )
inline

Enables registering entity attributes as a json object.

Definition at line 209 of file haEntity.h.

◆ deviceTypeStr()

static String HAEntity::deviceTypeStr ( haDeviceType_t  entityType)
inlinestatic

Gets entity type string from haDeviceType_t value https://www.home-assistant.io/docs/mqtt/discovery/.

Parameters
entityTypeEntity code
Returns
Entity string

Definition at line 227 of file haEntity.h.

◆ getAnounceMessage()

size_t HAEntity::getAnounceMessage ( int  bufferlen,
uint8_t *  buffer 
)
inline

Gets entity anounce message to be sent over EnigmaIOT message.

Parameters
bufferlenBuffer length. Needed legth can be got using measureMessage ()
bufferBuffer to put the payload in
Returns
Amount of data written to buffer

Definition at line 153 of file haEntity.h.

◆ getDiscoveryTopic()

static String HAEntity::getDiscoveryTopic ( const char *  hassPrefix,
const char *  nodeName,
haDeviceType_t  entityType,
const char *  nameSuffix = NULL 
)
inlinestatic

Allows Gateway to get discovery message MQTT topic.

Parameters
hassPrefixHomeAssistant topic prefix. Usually it is "homeassistant"
nodeNameName of the node
entityTypeEntity type. Used to differentiate discovery message template
nameSuffixThis is used to allow a single node to have different HomeAssistant entities. For instance, a smart switch may behave as a power, voltage and current sensor too.
Returns
MQTT topic

Definition at line 277 of file haEntity.h.

◆ measureMessage()

size_t HAEntity::measureMessage ( )
inline

Gets needed buffer size for discovery message.

Returns
Minimum buffer size

Definition at line 217 of file haEntity.h.

◆ setNameSufix()

void HAEntity::setNameSufix ( const char *  payload)
inline

Sets name suffix. Used for multi entity nodes.

Parameters
payloadName suffix

Definition at line 200 of file haEntity.h.

Member Data Documentation

◆ capacity

size_t HAEntity::capacity
protected

JSON object memory reservation length.

Definition at line 134 of file haEntity.h.

◆ deviceType

haDeviceType_t HAEntity::deviceType = UNDEFINED
protected

HomeAssistant entity device type.

Definition at line 135 of file haEntity.h.

◆ entityConfig

DynamicJsonDocument* HAEntity::entityConfig
protected

JSON object to be sent to gateway.

Definition at line 138 of file haEntity.h.


The documentation for this class was generated from the following file: