Skip to content

Commit

Permalink
Merge pull request arendst#4450 from emontnemery/hass_send_tele
Browse files Browse the repository at this point in the history
WIP - Support sending tele/STATUS as state/RESULT
  • Loading branch information
arendst committed Nov 26, 2018
2 parents c13c312 + b26fbb8 commit 72be0ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sonoff/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_rescan : 1; // bit 7 (v6.3.0.10)
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 spare11 : 1;
uint32_t spare12 : 1;
Expand Down
6 changes: 5 additions & 1 deletion sonoff/sonoff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,11 @@ void PerformEverySecond(void)

mqtt_data[0] = '\0';
MqttShowState();
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN);
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);
}

mqtt_data[0] = '\0';
if (MqttShowSensor()) {
Expand Down
5 changes: 3 additions & 2 deletions sonoff/xdrv_12_home_assistant.ino
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,9 @@ void HAssDiscovery(uint8_t mode)
{
// Configure Tasmota for default Home Assistant parameters to keep discovery message as short as possible
if (Settings.flag.hass_discovery) {
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.mqtt_response = 0; // Response always as RESULT and not as uppercase command
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
if (!string_ends_with(Settings.mqtt_fulltopic, "%prefix%/"))
strncpy_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"), sizeof(Settings.mqtt_fulltopic));
Expand Down

0 comments on commit 72be0ca

Please sign in to comment.