Skip to content

Commit

Permalink
Update homeassistant discovery client in a futile attempt to keep up …
Browse files Browse the repository at this point in the history
…with the ever-changing schema
  • Loading branch information
sidoh committed Jul 13, 2024
1 parent 38799ee commit f320677
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/MQTT/HomeAssistantDiscoveryClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu
}

// Configure supported commands based on the bulb type

// All supported bulbs support brightness and night mode
config[GroupStateFieldNames::BRIGHTNESS] = true;
config[GroupStateFieldNames::EFFECT] = true;

// effect_list
Expand Down Expand Up @@ -114,18 +111,28 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu
break;
}

// supported_color_modes
JsonArray colorModes = config.createNestedArray(F("sup_clrm"));

// Flag RGB support
if (MiLightRemoteTypeHelpers::supportsRgb(bulbId.deviceType)) {
config[F("rgb")] = true;
colorModes.add(F("rgb"));
}

// Flag adjustable color temp support
if (MiLightRemoteTypeHelpers::supportsColorTemp(bulbId.deviceType)) {
config[GroupStateFieldNames::COLOR_TEMP] = true;
colorModes.add(GroupStateFieldNames::COLOR_TEMP);

config[F("max_mirs")] = COLOR_TEMP_MAX_MIREDS;
config[F("min_mirs")] = COLOR_TEMP_MIN_MIREDS;
}

// should only have brightness in this list if there are no other color modes
// https://www.home-assistant.io/integrations/light.mqtt/#supported_color_modes
if (colorModes.size() == 0) {
colorModes.add(F("brightness"));
}

String message;
serializeJson(config, message);

Expand Down

0 comments on commit f320677

Please sign in to comment.