HAss force [is_topic_light] for Dimmer module

This commit is contained in:
Federico Leoni 2020-05-21 12:33:57 -03:00
parent 5e6010d1d0
commit a068010edf
1 changed files with 3 additions and 3 deletions

View File

@ -218,7 +218,7 @@ void HAssAnnounceRelayLight(void)
for (uint32_t i = 1; i <= MAX_RELAYS; i++) for (uint32_t i = 1; i <= MAX_RELAYS; i++)
{ {
bool RelayX = PinUsed(GPIO_REL1 +i-1); bool RelayX = PinUsed(GPIO_REL1 +i-1);
is_topic_light = Settings.flag.hass_light && RelayX || light_type && !RelayX; // SetOption30 - Enforce HAss autodiscovery as light is_topic_light = Settings.flag.hass_light && RelayX || light_type && !RelayX || PwmMod; // SetOption30 - Enforce HAss autodiscovery as light
mqtt_data[0] = '\0'; // Clear retained message mqtt_data[0] = '\0'; // Clear retained message
@ -237,7 +237,7 @@ void HAssAnnounceRelayLight(void)
AddLog_P2(LOG_LEVEL_ERROR, PSTR("%s"), kHAssError2); AddLog_P2(LOG_LEVEL_ERROR, PSTR("%s"), kHAssError2);
} else { } else {
if (Settings.flag.hass_discovery && (RelayX || (Light.device > 0) && (max_lights > 0)) && !err_flag ) if (Settings.flag.hass_discovery && (RelayX || (Light.device > 0) && (max_lights > 0)) && !err_flag )
{ // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59) { // SetOption19 - Control Home Assistant automatic discovery (See SetOption59)
char name[TOPSZ]; // friendlyname(33) + " " + index char name[TOPSZ]; // friendlyname(33) + " " + index
char value_template[33]; char value_template[33];
char prefix[TOPSZ]; char prefix[TOPSZ];
@ -260,7 +260,7 @@ void HAssAnnounceRelayLight(void)
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId()); TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId());
#ifdef USE_LIGHT #ifdef USE_LIGHT
if ((i >= Light.device)) { if (i >= Light.device) {
if (!RelayX || PwmMod) { if (!RelayX || PwmMod) {
char *brightness_command_topic = stemp1; char *brightness_command_topic = stemp1;
strncpy_P(stemp3, Settings.flag.not_power_linked ? PSTR("last") : PSTR("brightness"), sizeof(stemp3)); // SetOption20 - Control power in relation to Dimmer/Color/Ct changes strncpy_P(stemp3, Settings.flag.not_power_linked ? PSTR("last") : PSTR("brightness"), sizeof(stemp3)); // SetOption20 - Control power in relation to Dimmer/Color/Ct changes