Skip to content

Commit f320677

Browse files
committed
Update homeassistant discovery client in a futile attempt to keep up with the ever-changing schema
1 parent 38799ee commit f320677

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

lib/MQTT/HomeAssistantDiscoveryClient.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu
8282
}
8383

8484
// Configure supported commands based on the bulb type
85-
86-
// All supported bulbs support brightness and night mode
87-
config[GroupStateFieldNames::BRIGHTNESS] = true;
8885
config[GroupStateFieldNames::EFFECT] = true;
8986

9087
// effect_list
@@ -114,18 +111,28 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu
114111
break;
115112
}
116113

114+
// supported_color_modes
115+
JsonArray colorModes = config.createNestedArray(F("sup_clrm"));
116+
117117
// Flag RGB support
118118
if (MiLightRemoteTypeHelpers::supportsRgb(bulbId.deviceType)) {
119-
config[F("rgb")] = true;
119+
colorModes.add(F("rgb"));
120120
}
121121

122122
// Flag adjustable color temp support
123123
if (MiLightRemoteTypeHelpers::supportsColorTemp(bulbId.deviceType)) {
124-
config[GroupStateFieldNames::COLOR_TEMP] = true;
124+
colorModes.add(GroupStateFieldNames::COLOR_TEMP);
125+
125126
config[F("max_mirs")] = COLOR_TEMP_MAX_MIREDS;
126127
config[F("min_mirs")] = COLOR_TEMP_MIN_MIREDS;
127128
}
128129

130+
// should only have brightness in this list if there are no other color modes
131+
// https://www.home-assistant.io/integrations/light.mqtt/#supported_color_modes
132+
if (colorModes.size() == 0) {
133+
colorModes.add(F("brightness"));
134+
}
135+
129136
String message;
130137
serializeJson(config, message);
131138

0 commit comments

Comments
 (0)