diff --git a/hueplusplus/HueLight.cpp b/hueplusplus/HueLight.cpp index 36f92d3..f155d83 100755 --- a/hueplusplus/HueLight.cpp +++ b/hueplusplus/HueLight.cpp @@ -92,6 +92,15 @@ std::string HueLight::getManufacturername() const return std::string(); } +std::string HueLight::getProductname() const +{ + if (state.isMember("productname")) + { + return state["productname"].asString(); + } + return std::string(); +} + std::string HueLight::getLuminaireUId() const { if (state.isMember("luminaireuniqueid")) diff --git a/hueplusplus/include/HueLight.h b/hueplusplus/include/HueLight.h index df21946..440f319 100755 --- a/hueplusplus/include/HueLight.h +++ b/hueplusplus/include/HueLight.h @@ -162,6 +162,12 @@ public: //! \return String containing the manufacturername or an empty string when the function is not supported virtual std::string getManufacturername() const; + //! \brief Const function that returns the productname of the light + //! + //! \note Only working on bridges with versions starting at 1.24 + //! \return String containing the productname or an empty string when the function is not supported + virtual std::string getProductname() const; + //! \brief Const function that returns the luminaireuniqueid of the light //! //! \note Only working on bridges with versions starting at 1.9 diff --git a/hueplusplus/test/CMakeLists.txt b/hueplusplus/test/CMakeLists.txt index b7908a4..89cab3b 100755 --- a/hueplusplus/test/CMakeLists.txt +++ b/hueplusplus/test/CMakeLists.txt @@ -60,7 +60,7 @@ add_custom_target("unittest" # Run the executable COMMAND test_HuePlusPlus # Depends on test_HuePlusPlus - DEPENDS test_HuePlusPlus + DEPENDS test_HuePlusPlus ) # Check for coverage test prerequisites diff --git a/hueplusplus/test/test_HueLight.cpp b/hueplusplus/test/test_HueLight.cpp index afe3853..d771e91 100755 --- a/hueplusplus/test/test_HueLight.cpp +++ b/hueplusplus/test/test_HueLight.cpp @@ -35,6 +35,7 @@ protected: hue_bridge_state["lights"]["1"]["name"] = "Hue lamp 1"; hue_bridge_state["lights"]["1"]["modelid"] = "LWB004"; hue_bridge_state["lights"]["1"]["manufacturername"] = "Philips"; + hue_bridge_state["lights"]["1"]["productname"] = "Hue bloom"; hue_bridge_state["lights"]["1"]["uniqueid"] = "00:00:00:00:00:00:00:00-00"; hue_bridge_state["lights"]["1"]["swversion"] = "5.50.1.19085"; hue_bridge_state["lights"]["1"]["luminaireuniqueid"] = "0000000"; @@ -77,6 +78,7 @@ protected: hue_bridge_state["lights"]["3"]["name"] = "Hue lamp 3"; hue_bridge_state["lights"]["3"]["modelid"] = "LCT010"; hue_bridge_state["lights"]["3"]["manufacturername"] = "Philips"; + hue_bridge_state["lights"]["3"]["productname"] = "Hue bloom"; hue_bridge_state["lights"]["3"]["swversion"] = "5.50.1.19085"; EXPECT_CALL(*handler, GETJson("/api/" + bridge_username, Json::Value(Json::objectValue), bridge_ip, 80)) @@ -276,6 +278,23 @@ TEST_F(HueLightTest, getManufacturername) EXPECT_EQ("Philips", test_light_3.getManufacturername()); } +TEST_F(HueLightTest, getProductname) +{ + const HueLight ctest_light_1 = test_bridge.getLight(1); + const HueLight ctest_light_2 = test_bridge.getLight(2); + const HueLight ctest_light_3 = test_bridge.getLight(3); + HueLight test_light_1 = test_bridge.getLight(1); + HueLight test_light_2 = test_bridge.getLight(2); + HueLight test_light_3 = test_bridge.getLight(3); + + EXPECT_EQ("Hue bloom", ctest_light_1.getProductname()); + EXPECT_EQ("", ctest_light_2.getProductname()); + EXPECT_EQ("Hue bloom", ctest_light_3.getProductname()); + EXPECT_EQ("Hue bloom", test_light_1.getProductname()); + EXPECT_EQ("", test_light_2.getProductname()); + EXPECT_EQ("Hue bloom", test_light_3.getProductname()); +} + TEST_F(HueLightTest, getLuminaireUId) { const HueLight ctest_light_1 = test_bridge.getLight(1);