This commit is contained in:
Yuri Trikoz
2020-06-27 01:21:58 +03:00
parent b51ec4d0e2
commit 00fd9f9bb9
14 changed files with 371 additions and 266 deletions

View File

@@ -2,31 +2,31 @@
namespace Discovery {
static const char* json_is_defined = "is_defined";
static const char* jsonId = "id";
static const char* jsonBatt = "batt";
static const char* jsonLux = "lux";
static const char* jsonPres = "pres";
static const char* jsonFer = "fer";
static const char* jsonMoi = "moi";
static const char* jsonHum = "hum";
static const char* jsonTemp = "tem";
static const char* jsonStep = "steps";
static const char* jsonWeight = "weight";
static const char* jsonPresence = "presence";
static const char* jsonAltim = "altim";
static const char* jsonAltif = "altift";
static const char* jsonTempf = "tempf";
static const char* jsonMsg = "message";
static const char* jsonVal = "value";
static const char* jsonVolt = "volt";
static const char* jsonCurrent = "current";
static const char* jsonPower = "power";
static const char* jsonGpio = "gpio";
static const char* jsonFtcd = "ftcd";
static const char* jsonWm2 = "wattsm2";
static const char* jsonAdc = "adc";
static const char* jsonPa = "pa";
static const char json_is_defined[] = "is_defined";
static const char jsonId[] = "id";
static const char jsonBatt[] = "batt";
static const char jsonLux[] = "lux";
static const char jsonPres[] = "pres";
static const char jsonFer[] = "fer";
static const char jsonMoi[] = "moi";
static const char jsonHum[] = "hum";
static const char jsonTemp[] = "tem";
static const char jsonStep[] = "steps";
static const char jsonWeight[] = "weight";
static const char jsonPresence[] = "presence";
static const char jsonAltim[] = "altim";
static const char jsonAltif[] = "altift";
static const char jsonTempf[] = "tempf";
static const char jsonMsg[] = "message";
static const char jsonVal[] = "value";
static const char jsonVolt[] = "volt";
static const char jsonCurrent[] = "current";
static const char jsonPower[] = "power";
static const char jsonGpio[] = "gpio";
static const char jsonFtcd[] = "ftcd";
static const char jsonWm2[] = "wattsm2";
static const char jsonAdc[] = "adc";
static const char jsonPa[] = "pa";
const String getValueJson(const char* str) {
char buf[32];
@@ -35,16 +35,15 @@ const String getValueJson(const char* str) {
}
void createDiscovery(
char* unique_id,
const char* type, char* name, char* clazz,
char* value_template, char* payload_on, char* payload_off,
char* maasure_unit, int off_delay, char* has_payload, char* no_payload,
char* avail_topi, char* cmd_topic, char* state_topic, bool child) {
const char* type, const char* name, const char* clazz,
const char* value_template, const char* payload_on, const char* payload_off,
const char* maasure_unit, int off_delay, const char* has_payload, const char* no_payload,
const char* avail_topi, const char* cmd_topic, const char* state_topic, bool child) {
//const char* unique_id = getUniqueId(name).c_str();
}
void createADC(const char* name) {
createDiscovery(
(char*)getUniqueId(name).c_str(),
"Type", "Name", "Clazz",
"Value", "Payload", "NoPayload",
"Measure", 0, "HasPayload", "NoPayload",
@@ -53,7 +52,6 @@ void createADC(const char* name) {
void createSwitch(const char* name) {
createDiscovery(
(char*)getUniqueId(name).c_str(),
"Type", "Name", "Clazz",
"Value", "Payload", "NoPayload",
"Measure", 0, "HasPayload", "NoPayload",
@@ -65,14 +63,13 @@ void createSwitch(const char* name) {
// availability topic,
// device class,
// value template, payload on, payload off, unit of measurement
char* BMEsensor[6][8] = {
const char* BMEsensor[6][8] = {
{"sensor", "tempc", "bme", "temperature", "", "", "°C"}, //jsonTemp
{"sensor", "tempf", "bme", "temperature", "", "", "°F"}, //jsonTempf
{"sensor", "pa", "bme", "", "", "", "hPa"}, //jsonPa
{"sensor", "hum", "bme", "humidity", "", "", "%"}, // jsonHum
{"sensor", "altim", "bme", "", "", "", "m"}, //jsonAltim
{"sensor", "altift", "bme", "", "", "", "ft"} // jsonAltif
};
} // namespace Discovery