mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-02 23:47:42 +00:00
Prep for template tuning
This commit is contained in:
parent
5026cbd38d
commit
afe83a3460
@ -175,7 +175,7 @@ byte mdns_delayed_start = 0; // mDNS delayed start
|
||||
boolean latest_uptime_flag = true; // Signal latest uptime
|
||||
boolean pwm_present = false; // Any PWM channel configured with SetOption15 0
|
||||
boolean mdns_begun = false; // mDNS active
|
||||
mytmplt my_module; // Active copy of Module name and GPIOs (23 x 8 bits)
|
||||
myio my_module; // Active copy of Module GPIOs (18 x 8 bits)
|
||||
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
|
||||
char my_version[33]; // Composed version string
|
||||
char my_image[33]; // Code image and/or commit
|
||||
@ -856,8 +856,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
}
|
||||
restart_flag = 2;
|
||||
}
|
||||
snprintf_P(stemp1, sizeof(stemp1), kModules[Settings.module].name);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_SVALUE, command, Settings.module +1, stemp1);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_SVALUE, command, Settings.module +1, ModuleName().c_str());
|
||||
}
|
||||
else if (CMND_MODULES == command_code) {
|
||||
for (byte i = 0; i < MAXMODULE; i++) {
|
||||
@ -867,8 +866,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,"), mqtt_data);
|
||||
}
|
||||
jsflg = 1;
|
||||
snprintf_P(stemp1, sizeof(stemp1), kModules[i].name);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"%d (%s)\""), mqtt_data, i +1, stemp1);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"%d (%s)\""), mqtt_data, i +1, AnyModuleName(i).c_str());
|
||||
if ((strlen(mqtt_data) > (LOGSZ - TOPSZ)) || (i == MAXMODULE -1)) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s]}"), mqtt_data);
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, type);
|
||||
@ -879,9 +877,9 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
mqtt_data[0] = '\0';
|
||||
}
|
||||
else if ((CMND_GPIO == command_code) && (index < MAX_GPIO_PIN)) {
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||
if ((GPIO_USER == ValidGPIO(index, cmodule.gp.io[index])) && (payload >= 0) && (payload < GPIO_SENSOR_END)) {
|
||||
myio cmodule;
|
||||
ModuleGpios(&cmodule);
|
||||
if ((GPIO_USER == ValidGPIO(index, cmodule.io[index])) && (payload >= 0) && (payload < GPIO_SENSOR_END)) {
|
||||
bool present = false;
|
||||
for (byte i = 0; i < sizeof(kGpioNiceList); i++) {
|
||||
uint8_t midx = pgm_read_byte(kGpioNiceList + i);
|
||||
@ -889,7 +887,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
}
|
||||
if (present) {
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if ((GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) && (Settings.my_gp.io[i] == payload)) {
|
||||
if ((GPIO_USER == ValidGPIO(i, cmodule.io[i])) && (Settings.my_gp.io[i] == payload)) {
|
||||
Settings.my_gp.io[i] = 0;
|
||||
}
|
||||
}
|
||||
@ -899,7 +897,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{"));
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.io[i])) {
|
||||
if (jsflg) snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,"), mqtt_data);
|
||||
jsflg = 1;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_GPIO "%d\":\"%d (%s)\""),
|
||||
@ -913,12 +911,12 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
}
|
||||
}
|
||||
else if (CMND_GPIOS == command_code) {
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||
myio cmodule;
|
||||
ModuleGpios(&cmodule);
|
||||
uint8_t midx;
|
||||
for (byte i = 0; i < sizeof(kGpioNiceList); i++) {
|
||||
midx = pgm_read_byte(kGpioNiceList + i);
|
||||
if (!GetUsedInModule(midx, cmodule.gp.io)) {
|
||||
if (!GetUsedInModule(midx, cmodule.io)) {
|
||||
|
||||
if (!jsflg) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_GPIOS "%d\":["), lines);
|
||||
@ -2317,7 +2315,6 @@ void GpioInit(void)
|
||||
{
|
||||
uint8_t mpin;
|
||||
uint8_t key_no_pullup = 0;
|
||||
mytmplt def_module;
|
||||
|
||||
if (Settings.module >= MAXMODULE) {
|
||||
Settings.module = MODULE;
|
||||
@ -2327,14 +2324,17 @@ void GpioInit(void)
|
||||
baudrate = APP_BAUDRATE;
|
||||
}
|
||||
|
||||
memcpy_P(&def_module, &kModules[Settings.module], sizeof(def_module));
|
||||
strlcpy(my_module.name, def_module.name, sizeof(my_module.name));
|
||||
myio def_gp;
|
||||
ModuleGpios(&def_gp);
|
||||
|
||||
// AddLogSerial(LOG_LEVEL_DEBUG, (uint8_t *)&def_gp, sizeof(def_gp));
|
||||
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (Settings.my_gp.io[i] > GPIO_NONE) {
|
||||
my_module.gp.io[i] = Settings.my_gp.io[i];
|
||||
my_module.io[i] = Settings.my_gp.io[i];
|
||||
}
|
||||
if ((def_module.gp.io[i] > GPIO_NONE) && (def_module.gp.io[i] < GPIO_USER)) {
|
||||
my_module.gp.io[i] = def_module.gp.io[i];
|
||||
if ((def_gp.io[i] > GPIO_NONE) && (def_gp.io[i] < GPIO_USER)) {
|
||||
my_module.io[i] = def_gp.io[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -2342,7 +2342,7 @@ void GpioInit(void)
|
||||
pin[i] = 99;
|
||||
}
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
mpin = ValidGPIO(i, my_module.gp.io[i]);
|
||||
mpin = ValidGPIO(i, my_module.io[i]);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("DBG: gpio pin %d, mpin %d"), i, mpin);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
@ -2397,11 +2397,11 @@ void GpioInit(void)
|
||||
for (byte i = 0; i < GPIO_MAX; i++) {
|
||||
if ((pin[i] >= 12) && (pin[i] <=14)) pin[i] = 99;
|
||||
}
|
||||
my_module.gp.io[12] = GPIO_SPI_MISO;
|
||||
my_module.io[12] = GPIO_SPI_MISO;
|
||||
pin[GPIO_SPI_MISO] = 12;
|
||||
my_module.gp.io[13] = GPIO_SPI_MOSI;
|
||||
my_module.io[13] = GPIO_SPI_MOSI;
|
||||
pin[GPIO_SPI_MOSI] = 13;
|
||||
my_module.gp.io[14] = GPIO_SPI_CLK;
|
||||
my_module.io[14] = GPIO_SPI_CLK;
|
||||
pin[GPIO_SPI_CLK] = 14;
|
||||
}
|
||||
soft_spi_flg = ((pin[GPIO_SSPI_CS] < 99) && (pin[GPIO_SSPI_SCLK] < 99) && ((pin[GPIO_SSPI_MOSI] < 99) || (pin[GPIO_SSPI_MOSI] < 99)));
|
||||
|
@ -492,6 +492,21 @@ String PressureUnit(void)
|
||||
return (Settings.flag.pressure_conversion) ? String(D_UNIT_MILLIMETER_MERCURY) : String(D_UNIT_PRESSURE);
|
||||
}
|
||||
|
||||
String AnyModuleName(uint8_t index)
|
||||
{
|
||||
return FPSTR(kModules[index].name);
|
||||
}
|
||||
|
||||
String ModuleName()
|
||||
{
|
||||
return FPSTR(kModules[Settings.module].name);
|
||||
}
|
||||
|
||||
void ModuleGpios(myio *gp)
|
||||
{
|
||||
memcpy_P(gp, &kModules[Settings.module].gp, 18);
|
||||
}
|
||||
|
||||
void SetGlobalValues(float temperature, float humidity)
|
||||
{
|
||||
global_update = uptime;
|
||||
|
@ -169,7 +169,7 @@ const char HTTP_SCRIPT_MODULE2[] PROGMEM =
|
||||
"x.send();"
|
||||
"}";
|
||||
const char HTTP_SCRIPT_MODULE3[] PROGMEM =
|
||||
"}1'%d'>%s (%02d)}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name
|
||||
"}1'%d'>%s (%d)}2"; // "}1" and "}2" means do not use "}x" in Module name and Sensor name
|
||||
|
||||
const char HTTP_SCRIPT_INFO_BEGIN[] PROGMEM =
|
||||
"function i(){"
|
||||
@ -492,7 +492,7 @@ void ShowPage(String &page, bool auth)
|
||||
}
|
||||
|
||||
page.replace(F("{a}"), String(Settings.web_refresh));
|
||||
page.replace(F("{ha"), my_module.name);
|
||||
page.replace(F("{ha"), ModuleName());
|
||||
page.replace(F("{h}"), Settings.friendlyname[0]);
|
||||
|
||||
String info = "";
|
||||
@ -798,21 +798,20 @@ void HandleModuleConfiguration(void)
|
||||
|
||||
char stemp[20];
|
||||
uint8_t midx;
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||
myio cmodule;
|
||||
ModuleGpios(&cmodule);
|
||||
|
||||
if (WebServer->hasArg("m")) {
|
||||
String page = "";
|
||||
for (byte i = 0; i < MAXMODULE; i++) {
|
||||
midx = pgm_read_byte(kModuleNiceList + i);
|
||||
snprintf_P(stemp, sizeof(stemp), kModules[midx].name);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, stemp, midx +1);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, AnyModuleName(midx).c_str(), midx +1);
|
||||
page += mqtt_data;
|
||||
}
|
||||
page += "}3"; // String separator means do not use "}3" in Module name and Sensor name
|
||||
for (byte j = 0; j < sizeof(kGpioNiceList); j++) {
|
||||
midx = pgm_read_byte(kGpioNiceList + j);
|
||||
if (!GetUsedInModule(midx, cmodule.gp.io)) {
|
||||
if (!GetUsedInModule(midx, cmodule.io)) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SCRIPT_MODULE3, midx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames), midx);
|
||||
page += mqtt_data;
|
||||
}
|
||||
@ -828,8 +827,8 @@ void HandleModuleConfiguration(void)
|
||||
page += FPSTR(HTTP_SCRIPT_MODULE1);
|
||||
page.replace(F("}4"), String(Settings.module));
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.gp.io[i], i); // g0 - g16
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.io[i])) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("sk(%d,%d);"), my_module.io[i], i); // g0 - g16
|
||||
page += mqtt_data;
|
||||
}
|
||||
}
|
||||
@ -837,11 +836,10 @@ void HandleModuleConfiguration(void)
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page.replace(F("<body>"), F("<body onload='sl()'>"));
|
||||
page += FPSTR(HTTP_FORM_MODULE);
|
||||
snprintf_P(stemp, sizeof(stemp), kModules[MODULE].name);
|
||||
page.replace(F("{mt"), stemp);
|
||||
page.replace(F("{mt"), AnyModuleName(MODULE));
|
||||
page += F("<br/><table>");
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.io[i])) {
|
||||
snprintf_P(stemp, 3, PINS_WEMOS +i*2);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("<tr><td style='width:190px'>%s <b>" D_GPIO "%d</b> %s</td><td style='width:160px'><select id='g%d' name='g%d'></select></td></tr>"),
|
||||
(WEMOS==Settings.module)?stemp:"", i, (0==i)? D_SENSOR_BUTTON "1":(1==i)? D_SERIAL_OUT :(3==i)? D_SERIAL_IN :(9==i)? "<font color='red'>ESP8285</font>" :(10==i)? "<font color='red'>ESP8285</font>" :(12==i)? D_SENSOR_RELAY "1":(13==i)? D_SENSOR_LED "1i":(14==i)? D_SENSOR :"", i, i);
|
||||
@ -863,14 +861,14 @@ void ModuleSaveSettings(void)
|
||||
byte new_module = (!strlen(tmp)) ? MODULE : atoi(tmp);
|
||||
Settings.last_module = Settings.module;
|
||||
Settings.module = new_module;
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||
myio cmodule;
|
||||
ModuleGpios(&cmodule);
|
||||
String gpios = "";
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (Settings.last_module != new_module) {
|
||||
Settings.my_gp.io[i] = 0;
|
||||
} else {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.io[i])) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("g%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
Settings.my_gp.io[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
@ -878,8 +876,7 @@ void ModuleSaveSettings(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
snprintf_P(stemp, sizeof(stemp), kModules[Settings.module].name);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), stemp, gpios.c_str());
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str());
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
|
@ -415,8 +415,7 @@ void MqttConnected(void)
|
||||
|
||||
if (mqtt_initial_connection_state) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_FALLBACKTOPIC "\":\"%s\",\"" D_CMND_GROUPTOPIC "\":\"%s\"}"),
|
||||
my_module.name, my_version, my_image, GetFallbackTopic_P(stopic, CMND, ""), Settings.mqtt_grptopic);
|
||||
// my_module.name, my_version, my_image, mqtt_client, Settings.mqtt_grptopic);
|
||||
ModuleName().c_str(), my_version, my_image, GetFallbackTopic_P(stopic, CMND, ""), Settings.mqtt_grptopic);
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "1"));
|
||||
#ifdef USE_WEBSERVER
|
||||
if (Settings.webserver) {
|
||||
|
@ -373,15 +373,15 @@ void LightInit(void)
|
||||
}
|
||||
}
|
||||
if (SONOFF_LED == Settings.module) { // Fix Sonoff Led instabilities
|
||||
if (!my_module.gp.io[4]) {
|
||||
if (!my_module.io[4]) {
|
||||
pinMode(4, OUTPUT); // Stop floating outputs
|
||||
digitalWrite(4, LOW);
|
||||
}
|
||||
if (!my_module.gp.io[5]) {
|
||||
if (!my_module.io[5]) {
|
||||
pinMode(5, OUTPUT); // Stop floating outputs
|
||||
digitalWrite(5, LOW);
|
||||
}
|
||||
if (!my_module.gp.io[14]) {
|
||||
if (!my_module.io[14]) {
|
||||
pinMode(14, OUTPUT); // Stop floating outputs
|
||||
digitalWrite(14, LOW);
|
||||
}
|
||||
|
@ -465,11 +465,11 @@ void KNX_INIT(void)
|
||||
// and activate options according to the hardware
|
||||
/*for (int i = GPIO_REL1; i < GPIO_REL8 + 1; ++i)
|
||||
{
|
||||
if (GetUsedInModule(i, my_module.gp.io)) { device_param[i - GPIO_REL1].show = true; }
|
||||
if (GetUsedInModule(i, my_module.io)) { device_param[i - GPIO_REL1].show = true; }
|
||||
}
|
||||
for (int i = GPIO_REL1_INV; i < GPIO_REL8_INV + 1; ++i)
|
||||
{
|
||||
if (GetUsedInModule(i, my_module.gp.io)) { device_param[i - GPIO_REL1_INV].show = true; }
|
||||
if (GetUsedInModule(i, my_module.io)) { device_param[i - GPIO_REL1_INV].show = true; }
|
||||
}*/
|
||||
for (int i = 0; i < devices_present; ++i)
|
||||
{
|
||||
@ -477,27 +477,27 @@ void KNX_INIT(void)
|
||||
}
|
||||
for (int i = GPIO_SWT1; i < GPIO_SWT4 + 1; ++i)
|
||||
{
|
||||
if (GetUsedInModule(i, my_module.gp.io)) { device_param[i - GPIO_SWT1 + 8].show = true; }
|
||||
if (GetUsedInModule(i, my_module.io)) { device_param[i - GPIO_SWT1 + 8].show = true; }
|
||||
}
|
||||
for (int i = GPIO_KEY1; i < GPIO_KEY4 + 1; ++i)
|
||||
{
|
||||
if (GetUsedInModule(i, my_module.gp.io)) { device_param[i - GPIO_KEY1 + 8].show = true; }
|
||||
if (GetUsedInModule(i, my_module.io)) { device_param[i - GPIO_KEY1 + 8].show = true; }
|
||||
}
|
||||
for (int i = GPIO_SWT1_NP; i < GPIO_SWT4_NP + 1; ++i)
|
||||
{
|
||||
if (GetUsedInModule(i, my_module.gp.io)) { device_param[i - GPIO_SWT1_NP + 8].show = true; }
|
||||
if (GetUsedInModule(i, my_module.io)) { device_param[i - GPIO_SWT1_NP + 8].show = true; }
|
||||
}
|
||||
for (int i = GPIO_KEY1_NP; i < GPIO_KEY4_NP + 1; ++i)
|
||||
{
|
||||
if (GetUsedInModule(i, my_module.gp.io)) { device_param[i - GPIO_KEY1_NP + 8].show = true; }
|
||||
if (GetUsedInModule(i, my_module.io)) { device_param[i - GPIO_KEY1_NP + 8].show = true; }
|
||||
}
|
||||
if (GetUsedInModule(GPIO_DHT11, my_module.gp.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT22, my_module.gp.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_SI7021, my_module.gp.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DSB, my_module.gp.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT11, my_module.gp.io)) { device_param[KNX_HUMIDITY-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT22, my_module.gp.io)) { device_param[KNX_HUMIDITY-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_SI7021, my_module.gp.io)) { device_param[KNX_HUMIDITY-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT11, my_module.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT22, my_module.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_SI7021, my_module.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DSB, my_module.io)) { device_param[KNX_TEMPERATURE-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT11, my_module.io)) { device_param[KNX_HUMIDITY-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_DHT22, my_module.io)) { device_param[KNX_HUMIDITY-1].show = true; }
|
||||
if (GetUsedInModule(GPIO_SI7021, my_module.io)) { device_param[KNX_HUMIDITY-1].show = true; }
|
||||
|
||||
// Sonoff 31 or Sonoff Pow or any HLW8012 based device or Sonoff POW R2 or Any device with a Pzem004T
|
||||
if ( ( SONOFF_S31 == Settings.module ) || ( SONOFF_POW_R2 == Settings.module ) || ( energy_flg != ENERGY_NONE ) ) {
|
||||
|
@ -237,10 +237,9 @@ void HAssAnnounceRelayLight(void)
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_LIGHT_CT, mqtt_data, color_temp_command_topic, state_topic);
|
||||
}
|
||||
}
|
||||
snprintf_P(stemp1, sizeof(stemp1), kModules[Settings.module].name);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_DEVICE_INFO, mqtt_data,
|
||||
unique_id, ESP.getChipId(),
|
||||
Settings.friendlyname[0], stemp1, my_version, my_image, "Tasmota");
|
||||
Settings.friendlyname[0], ModuleName().c_str(), my_version, my_image, "Tasmota");
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||
}
|
||||
@ -287,10 +286,9 @@ void HAssAnnounceButtonSwitch(byte device, char* topic, byte present, byte key,
|
||||
if (toggle) snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_BUTTON_SWITCH_TOGGLE, mqtt_data);
|
||||
else snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_BUTTON_SWITCH_ONOFF, mqtt_data, Settings.state_text[0]);
|
||||
|
||||
snprintf_P(stemp1, sizeof(stemp1), kModules[Settings.module].name);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_DEVICE_INFO, mqtt_data,
|
||||
unique_id, ESP.getChipId(),
|
||||
Settings.friendlyname[0], stemp1, my_version, my_image, "Tasmota");
|
||||
Settings.friendlyname[0], ModuleName().c_str(), my_version, my_image, "Tasmota");
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||
}
|
||||
@ -413,10 +411,9 @@ void HAssAnnounceSensor(const char* sensorname, const char* subsensortype)
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_SENSOR_ANY,
|
||||
mqtt_data, sensorname, subsensortype);
|
||||
}
|
||||
snprintf_P(stemp1, sizeof(stemp1), kModules[Settings.module].name);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_DEVICE_INFO, mqtt_data,
|
||||
unique_id, ESP.getChipId(),
|
||||
Settings.friendlyname[0], stemp1, my_version, my_image, "Tasmota");
|
||||
Settings.friendlyname[0], ModuleName().c_str(), my_version, my_image, "Tasmota");
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user