Merge pull request #4450 from emontnemery/hass_send_tele

WIP - Support sending tele/STATUS as state/RESULT
This commit is contained in:
Theo Arends 2018-11-26 12:49:43 +01:00 committed by GitHub
commit eb851a9a90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -72,7 +72,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t use_wifi_scan : 1; // bit 6 (v6.3.0.10) uint32_t use_wifi_scan : 1; // bit 6 (v6.3.0.10)
uint32_t use_wifi_rescan : 1; // bit 7 (v6.3.0.10) uint32_t use_wifi_rescan : 1; // bit 7 (v6.3.0.10)
uint32_t receive_raw : 1; // bit 8 (v6.3.0.11) uint32_t receive_raw : 1; // bit 8 (v6.3.0.11)
uint32_t spare09 : 1; uint32_t hass_tele_as_result : 1; // bit 9
uint32_t spare10 : 1; uint32_t spare10 : 1;
uint32_t spare11 : 1; uint32_t spare11 : 1;
uint32_t spare12 : 1; uint32_t spare12 : 1;

View File

@ -1681,7 +1681,11 @@ void PerformEverySecond(void)
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
MqttShowState(); MqttShowState();
if (Settings.flag3.hass_tele_as_result) {
MqttPublishPrefixTopic_P(STAT, S_RSLT_RESULT, MQTT_TELE_RETAIN);
} else {
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN); MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN);
}
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
if (MqttShowSensor()) { if (MqttShowSensor()) {

View File

@ -426,6 +426,7 @@ void HAssDiscovery(uint8_t mode)
if (Settings.flag.hass_discovery) { if (Settings.flag.hass_discovery) {
Settings.flag.mqtt_response = 0; // Response always as RESULT and not as uppercase command Settings.flag.mqtt_response = 0; // Response always as RESULT and not as uppercase command
Settings.flag.decimal_text = 1; // Respond with decimal color values Settings.flag.decimal_text = 1; // Respond with decimal color values
Settings.flag3.hass_tele_as_result = 1; // send tele/STATE message as stat/RESULT
// Settings.light_scheme = 0; // To just control color it needs to be Scheme 0 // Settings.light_scheme = 0; // To just control color it needs to be Scheme 0
if (!string_ends_with(Settings.mqtt_fulltopic, "%prefix%/")) if (!string_ends_with(Settings.mqtt_fulltopic, "%prefix%/"))
strncpy_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"), sizeof(Settings.mqtt_fulltopic)); strncpy_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"), sizeof(Settings.mqtt_fulltopic));