Added HASS_STATE to command STATE

The command STATE has a secondary mqtt message in the case that SETOPTION59 is 1
This adds a HASS_STATE mqtt message if HomeAssistant discovery is enabled.

This is useful for syncing HomeAssistant with all the states of a Tasmota device when HA is restarted.
The actual automation for HA explained in the wiki will also make use of this new message.
This commit is contained in:
Adrian Scillato 2019-03-20 00:57:26 -03:00 committed by GitHub
parent 83188c926c
commit f4da1d1d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -615,6 +615,11 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if (Settings.flag3.hass_tele_on_power) {
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN);
}
#ifdef USE_HOME_ASSISTANT
if (Settings.flag.hass_discovery) {
HAssPublishStatus();
}
#endif // USE_HOME_ASSISTANT
}
else if (CMND_SLEEP == command_code) {
if ((payload >= 0) && (payload < 251)) {