mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Fix HASS button discovery
This commit is contained in:
parent
74f1ad8a1b
commit
0006d44e63
@ -424,6 +424,7 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
|
|||||||
char scommand[CMDSZ];
|
char scommand[CMDSZ];
|
||||||
char key_topic[TOPSZ];
|
char key_topic[TOPSZ];
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
uint32_t device_save = device;
|
||||||
|
|
||||||
char *tmp = (key) ? SettingsText(SET_MQTT_SWITCH_TOPIC) : SettingsText(SET_MQTT_BUTTON_TOPIC);
|
char *tmp = (key) ? SettingsText(SET_MQTT_SWITCH_TOPIC) : SettingsText(SET_MQTT_BUTTON_TOPIC);
|
||||||
Format(key_topic, tmp, sizeof(key_topic));
|
Format(key_topic, tmp, sizeof(key_topic));
|
||||||
@ -459,7 +460,7 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
|
|||||||
result = XdrvRulesProcess();
|
result = XdrvRulesProcess();
|
||||||
}
|
}
|
||||||
int32_t payload_save = XdrvMailbox.payload;
|
int32_t payload_save = XdrvMailbox.payload;
|
||||||
XdrvMailbox.payload = key << 16 | state << 8 | device;
|
XdrvMailbox.payload = device_save << 24 | key << 16 | state << 8 | device;
|
||||||
XdrvCall(FUNC_ANY_KEY);
|
XdrvCall(FUNC_ANY_KEY);
|
||||||
XdrvMailbox.payload = payload_save;
|
XdrvMailbox.payload = payload_save;
|
||||||
return result;
|
return result;
|
||||||
@ -922,6 +923,7 @@ void Every250mSeconds(void)
|
|||||||
// Replace tasmota.bin.gz with tasmota-minimal.bin.gz
|
// Replace tasmota.bin.gz with tasmota-minimal.bin.gz
|
||||||
// Replace tasmota.xyz.gz with tasmota-minimal.xyz.gz
|
// Replace tasmota.xyz.gz with tasmota-minimal.xyz.gz
|
||||||
// Replace tasmota.ino.bin with tasmota-minimal.ino.bin
|
// Replace tasmota.ino.bin with tasmota-minimal.ino.bin
|
||||||
|
// Replace tasmota.ino.bin.gz with tasmota-minimal.ino.bin.gz
|
||||||
// Replace http://domus1:80/api/arduino/tasmota.bin with http://domus1:80/api/arduino/tasmota-minimal.bin
|
// Replace http://domus1:80/api/arduino/tasmota.bin with http://domus1:80/api/arduino/tasmota-minimal.bin
|
||||||
// Replace http://domus1:80/api/arduino/tasmota.bin.gz with http://domus1:80/api/arduino/tasmota-minimal.bin.gz
|
// Replace http://domus1:80/api/arduino/tasmota.bin.gz with http://domus1:80/api/arduino/tasmota-minimal.bin.gz
|
||||||
// Replace http://domus1:80/api/arduino/tasmota-DE.bin.gz with http://domus1:80/api/arduino/tasmota-minimal.bin.gz
|
// Replace http://domus1:80/api/arduino/tasmota-DE.bin.gz with http://domus1:80/api/arduino/tasmota-minimal.bin.gz
|
||||||
@ -941,7 +943,7 @@ void Every250mSeconds(void)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz)
|
char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz)
|
||||||
if (ech == nullptr) { ech = mqtt_data + strlen(mqtt_data); }
|
if (ech == nullptr) { ech = mqtt_data + strlen(mqtt_data); } // Point to '/0' at end of mqtt_data becoming an empty string
|
||||||
|
|
||||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech);
|
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech);
|
||||||
|
|
||||||
|
@ -712,6 +712,13 @@ void MqttCheck(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ButtonTopicActive(void)
|
||||||
|
{
|
||||||
|
char key_topic[TOPSZ];
|
||||||
|
Format(key_topic, SettingsText(SET_MQTT_BUTTON_TOPIC), sizeof(key_topic));
|
||||||
|
return ((strlen(key_topic) != 0) && strcmp(key_topic, "0"));
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Commands
|
* Commands
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -568,9 +568,13 @@ void HAssAnyKey(void)
|
|||||||
return;
|
return;
|
||||||
} // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
|
} // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
|
||||||
|
|
||||||
uint32_t key = (XdrvMailbox.payload >> 16) & 0xFF;
|
uint32_t key = (XdrvMailbox.payload >> 16) & 0xFF; // 0 = Button, 1 = Switch
|
||||||
uint32_t device = XdrvMailbox.payload & 0xFF;
|
uint32_t device = XdrvMailbox.payload & 0xFF; // Device number or 1 if more Buttons than Devices
|
||||||
uint32_t state = (XdrvMailbox.payload >> 8) & 0xFF;
|
uint32_t state = (XdrvMailbox.payload >> 8) & 0xFF; // 0 = Off, 1 = On, 2 = Toggle
|
||||||
|
|
||||||
|
if (!key && ButtonTopicActive()) { // Button and ButtonTopic is active
|
||||||
|
device = (XdrvMailbox.payload >> 24) & 0xFF; // Button number
|
||||||
|
}
|
||||||
|
|
||||||
char scommand[CMDSZ];
|
char scommand[CMDSZ];
|
||||||
snprintf_P(scommand, sizeof(scommand), PSTR("%s%d"), (key) ? "SWITCH" : "BUTTON", device);
|
snprintf_P(scommand, sizeof(scommand), PSTR("%s%d"), (key) ? "SWITCH" : "BUTTON", device);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user