diff --git a/src/HueDeviceTypes.cpp b/src/HueDeviceTypes.cpp index 63abdac..362f177 100644 --- a/src/HueDeviceTypes.cpp +++ b/src/HueDeviceTypes.cpp @@ -58,6 +58,13 @@ const std::set getNoColorTypes() return c_DIMMABLELIGHT_NO_COLOR_TYPES; } +const std::set getNonDimmableTypes() +{ + static const std::set c_NON_DIMMABLE_TYPES + = {"Plug 01"}; + return c_NON_DIMMABLE_TYPES; +} + const std::set getTemperatureLightTypes() { static const std::set c_TEMPERATURELIGHT_TYPES @@ -105,6 +112,12 @@ auto MakeHueLight::operator()(std::string type, int id, HueCommandAPI commands, return light; } + else if (getNonDimmableTypes().count(type)) { + auto light = HueLight(id, commands); + light.colorType = ColorType::NONE; + return light; + } + else if (getTemperatureLightTypes().count(type)) { auto light = HueLight(id, commands, simpleBrightnessStrategy, simpleColorTemperatureStrategy, nullptr); diff --git a/test/test_Hue.cpp b/test/test_Hue.cpp index ae10dc1..e519a3c 100644 --- a/test/test_Hue.cpp +++ b/test/test_Hue.cpp @@ -365,6 +365,23 @@ TEST(Hue, getLight) EXPECT_EQ(test_light_1.getName(), "Hue ambiance lamp 1"); EXPECT_EQ(test_light_1.getColorType(), ColorType::NONE); + hue_bridge_state["lights"]["1"]["modelid"] = "Plug 01"; + EXPECT_CALL( + *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) + .Times(1) + .WillOnce(Return(hue_bridge_state)); + + EXPECT_CALL(*handler, + GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), getBridgePort())) + .Times(AtLeast(1)) + .WillRepeatedly(Return(hue_bridge_state["lights"]["1"])); + test_bridge = Hue(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); + + // Test when correct data is sent + test_light_1 = test_bridge.getLight(1); + EXPECT_EQ(test_light_1.getName(), "Hue ambiance lamp 1"); + EXPECT_EQ(test_light_1.getColorType(), ColorType::NONE); + hue_bridge_state["lights"]["1"]["modelid"] = "ABC000"; EXPECT_CALL( *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort()))