EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
haSensor.h
Go to the documentation of this file.
1 
9 #ifndef _HA_SENSOR_h
10 #define _HA_SENSOR_h
11 
12 #include "haEntity.h"
13 
14 #if SUPPORT_HA_DISCOVERY
15 
81 class HASensor : public HAEntity {
82 
83 public:
87  HASensor () {
88  capacity = 1024; //JSON_OBJECT_SIZE (15) + 512;
89  entityConfig = new DynamicJsonDocument (capacity);
91  (*entityConfig)[ha_device_type] = deviceType;
92  };
93 
99  void setDeviceClass (haSensorClass_t devClass);
100 
106  void setExpireTime (uint payload);
107 
113  void setUnitOfMeasurement (const char* payload);
114 
120  void setValueField (const char* payload);
121 
127  void setValueTemplate (const char* payload);
128 
129 
139  static size_t getDiscoveryJson (char* buffer, size_t buflen, const char* nodeName, const char* networkName, DynamicJsonDocument* inputJSON);
140 
146  static String deviceClassStr (haSensorClass_t sensorClass);
147 
148 };
149 
150 #endif // SUPPORT_HA_DISCOVERY
151 
152 #endif // _HA_COVER_h
HAEntity::entityConfig
DynamicJsonDocument * entityConfig
JSON object to be sent to gateway.
Definition: haEntity.h:138
haEntity.h
Defines an entity for Home Assistant autodiscovery.
HASensor::setValueField
void setValueField(const char *payload)
Defines a json key that defines sensor value. When setting this, setValueTemplate () should not be ca...
Definition: haSensor.cpp:32
HASensor::setDeviceClass
void setDeviceClass(haSensorClass_t devClass)
Define sensor class as haSensorClass_t https://www.home-assistant.io/integrations/sensor....
Definition: haSensor.cpp:13
HASensor::deviceClassStr
static String deviceClassStr(haSensorClass_t sensorClass)
Gets sensor class name from haSensorClass_t https://www.home-assistant.io/integrations/sensor....
Definition: haSensor.cpp:123
HAEntity::capacity
size_t capacity
JSON object memory reservation length.
Definition: haEntity.h:134
HASensor::setUnitOfMeasurement
void setUnitOfMeasurement(const char *payload)
Set unit of measure https://www.home-assistant.io/integrations/sensor.mqtt/#unit_of_measurement.
Definition: haSensor.cpp:26
ha_device_type
constexpr auto ha_device_type
Definition: haEntity.h:23
HAEntity::deviceType
haDeviceType_t deviceType
HomeAssistant entity device type.
Definition: haEntity.h:135
SENSOR
@ SENSOR
Definition: haEntity.h:66
HASensor::getDiscoveryJson
static size_t getDiscoveryJson(char *buffer, size_t buflen, const char *nodeName, const char *networkName, DynamicJsonDocument *inputJSON)
Allows Gateway to get Home Assistant discovery message using Sensor template.
Definition: haSensor.cpp:65
haSensorClass_t
haSensorClass_t
Definition: haEntity.h:116
HASensor
Definition: haSensor.h:81
HASensor::HASensor
HASensor()
Sensor constructor.
Definition: haSensor.h:87
HAEntity
Definition: haEntity.h:132
HASensor::setExpireTime
void setExpireTime(uint payload)
Defines the number of seconds after the sensor’s state expires, if it’s not updated....
Definition: haSensor.cpp:20
HASensor::setValueTemplate
void setValueTemplate(const char *payload)
Defines a template that defines sensor value. When setting this you should not call setValueField () ...
Definition: haSensor.cpp:38