Commit 5acc6ad1d1a5690a3d6e3874ac1161e4a01be37e
Committed by
Moritz Wirger
1 parent
1ebb304b
Add Osram on/off plug support
Showing
2 changed files
with
30 additions
and
0 deletions
src/HueDeviceTypes.cpp
| ... | ... | @@ -58,6 +58,13 @@ const std::set<std::string> getNoColorTypes() |
| 58 | 58 | return c_DIMMABLELIGHT_NO_COLOR_TYPES; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | +const std::set<std::string> getNonDimmableTypes() | |
| 62 | +{ | |
| 63 | + static const std::set<std::string> c_NON_DIMMABLE_TYPES | |
| 64 | + = {"Plug 01"}; | |
| 65 | + return c_NON_DIMMABLE_TYPES; | |
| 66 | +} | |
| 67 | + | |
| 61 | 68 | const std::set<std::string> getTemperatureLightTypes() |
| 62 | 69 | { |
| 63 | 70 | static const std::set<std::string> c_TEMPERATURELIGHT_TYPES |
| ... | ... | @@ -105,6 +112,12 @@ auto MakeHueLight::operator()(std::string type, int id, HueCommandAPI commands, |
| 105 | 112 | return light; |
| 106 | 113 | } |
| 107 | 114 | |
| 115 | + else if (getNonDimmableTypes().count(type)) { | |
| 116 | + auto light = HueLight(id, commands); | |
| 117 | + light.colorType = ColorType::NONE; | |
| 118 | + return light; | |
| 119 | + } | |
| 120 | + | |
| 108 | 121 | else if (getTemperatureLightTypes().count(type)) |
| 109 | 122 | { |
| 110 | 123 | auto light = HueLight(id, commands, simpleBrightnessStrategy, simpleColorTemperatureStrategy, nullptr); | ... | ... |
test/test_Hue.cpp
| ... | ... | @@ -365,6 +365,23 @@ TEST(Hue, getLight) |
| 365 | 365 | EXPECT_EQ(test_light_1.getName(), "Hue ambiance lamp 1"); |
| 366 | 366 | EXPECT_EQ(test_light_1.getColorType(), ColorType::NONE); |
| 367 | 367 | |
| 368 | + hue_bridge_state["lights"]["1"]["modelid"] = "Plug 01"; | |
| 369 | + EXPECT_CALL( | |
| 370 | + *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) | |
| 371 | + .Times(1) | |
| 372 | + .WillOnce(Return(hue_bridge_state)); | |
| 373 | + | |
| 374 | + EXPECT_CALL(*handler, | |
| 375 | + GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), getBridgePort())) | |
| 376 | + .Times(AtLeast(1)) | |
| 377 | + .WillRepeatedly(Return(hue_bridge_state["lights"]["1"])); | |
| 378 | + test_bridge = Hue(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); | |
| 379 | + | |
| 380 | + // Test when correct data is sent | |
| 381 | + test_light_1 = test_bridge.getLight(1); | |
| 382 | + EXPECT_EQ(test_light_1.getName(), "Hue ambiance lamp 1"); | |
| 383 | + EXPECT_EQ(test_light_1.getColorType(), ColorType::NONE); | |
| 384 | + | |
| 368 | 385 | hue_bridge_state["lights"]["1"]["modelid"] = "ABC000"; |
| 369 | 386 | EXPECT_CALL( |
| 370 | 387 | *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) | ... | ... |