Cleanup restart for non-HAss users

Cleanup restart for non-HAss users
This commit is contained in:
Theo Arends 2018-03-29 14:01:38 +02:00
parent a935f92998
commit dabb4deefc
2 changed files with 17 additions and 11 deletions

View File

@ -572,7 +572,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
switch (index) {
case 3: // mqtt
case 15: // pwm_control
case 19: // hass_discovery
// case 19: // hass_discovery
restart_flag = 2;
case 0: // save_state
case 1: // button_restrict
@ -587,6 +587,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
case 16: // ws_clock_reverse
case 17: // decimal_text
case 18: // light_signal
case 19: // hass_discovery
case 20: // not_power_linked
case 21: // no_power_on_check
bitWrite(Settings.flag.data, index, payload);
@ -595,6 +596,11 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
stop_flash_rotate = payload;
SettingsSave(2);
}
#ifdef USE_HOME_ASSISTANT
if (19 == index) { // hass_discovery
HAssDiscovery(1);
}
#endif // USE_HOME_ASSISTANT
}
}
else { // SetOption32 ..

View File

@ -183,7 +183,7 @@ void HAssDiscoverButton()
}
}
void HAssDiscovery()
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) {
@ -193,15 +193,15 @@ void HAssDiscovery()
// strncpy_P(Settings.mqtt_fulltopic, PSTR("%prefix%/%topic%/"), sizeof(Settings.mqtt_fulltopic)); // Make MQTT topic as short as possible to make this process posible within MQTT_MAX_PACKET_SIZE
}
// Send info about relays and lights
HAssDiscoverRelay();
if (Settings.flag.hass_discovery || (1 == mode)) {
// Send info about relays and lights
HAssDiscoverRelay();
// Send info about buttons
HAssDiscoverButton();
// TODO: Send info about switches
// Send info about buttons
HAssDiscoverButton();
// TODO: Send info about switches
// TODO: Send info about sensors
// TODO: Send info about sensors
}
}
/*********************************************************************************************\
@ -217,7 +217,7 @@ boolean Xdrv07(byte function)
if (Settings.flag.mqtt_enabled) {
switch (function) {
case FUNC_MQTT_INIT:
HAssDiscovery();
HAssDiscovery(0);
break;
}
}