Commit 74017451848c984b85c1a9cddd8e9306e039bd5d

Authored by Moritz Wirger
1 parent 6587a32f

Add new light function for bridges using v1.24

- add getProductname to get the product name of a light
hueplusplus/HueLight.cpp
... ... @@ -92,6 +92,15 @@ std::string HueLight::getManufacturername() const
92 92 return std::string();
93 93 }
94 94  
  95 +std::string HueLight::getProductname() const
  96 +{
  97 + if (state.isMember("productname"))
  98 + {
  99 + return state["productname"].asString();
  100 + }
  101 + return std::string();
  102 +}
  103 +
95 104 std::string HueLight::getLuminaireUId() const
96 105 {
97 106 if (state.isMember("luminaireuniqueid"))
... ...
hueplusplus/include/HueLight.h
... ... @@ -162,6 +162,12 @@ public:
162 162 //! \return String containing the manufacturername or an empty string when the function is not supported
163 163 virtual std::string getManufacturername() const;
164 164  
  165 + //! \brief Const function that returns the productname of the light
  166 + //!
  167 + //! \note Only working on bridges with versions starting at 1.24
  168 + //! \return String containing the productname or an empty string when the function is not supported
  169 + virtual std::string getProductname() const;
  170 +
165 171 //! \brief Const function that returns the luminaireuniqueid of the light
166 172 //!
167 173 //! \note Only working on bridges with versions starting at 1.9
... ...
hueplusplus/test/CMakeLists.txt
... ... @@ -60,7 +60,7 @@ add_custom_target("unittest"
60 60 # Run the executable
61 61 COMMAND test_HuePlusPlus
62 62 # Depends on test_HuePlusPlus
63   - DEPENDS test_HuePlusPlus
  63 + DEPENDS test_HuePlusPlus
64 64 )
65 65  
66 66 # Check for coverage test prerequisites
... ...
hueplusplus/test/test_HueLight.cpp
... ... @@ -35,6 +35,7 @@ protected:
35 35 hue_bridge_state["lights"]["1"]["name"] = "Hue lamp 1";
36 36 hue_bridge_state["lights"]["1"]["modelid"] = "LWB004";
37 37 hue_bridge_state["lights"]["1"]["manufacturername"] = "Philips";
  38 + hue_bridge_state["lights"]["1"]["productname"] = "Hue bloom";
38 39 hue_bridge_state["lights"]["1"]["uniqueid"] = "00:00:00:00:00:00:00:00-00";
39 40 hue_bridge_state["lights"]["1"]["swversion"] = "5.50.1.19085";
40 41 hue_bridge_state["lights"]["1"]["luminaireuniqueid"] = "0000000";
... ... @@ -77,6 +78,7 @@ protected:
77 78 hue_bridge_state["lights"]["3"]["name"] = "Hue lamp 3";
78 79 hue_bridge_state["lights"]["3"]["modelid"] = "LCT010";
79 80 hue_bridge_state["lights"]["3"]["manufacturername"] = "Philips";
  81 + hue_bridge_state["lights"]["3"]["productname"] = "Hue bloom";
80 82 hue_bridge_state["lights"]["3"]["swversion"] = "5.50.1.19085";
81 83  
82 84 EXPECT_CALL(*handler, GETJson("/api/" + bridge_username, Json::Value(Json::objectValue), bridge_ip, 80))
... ... @@ -276,6 +278,23 @@ TEST_F(HueLightTest, getManufacturername)
276 278 EXPECT_EQ("Philips", test_light_3.getManufacturername());
277 279 }
278 280  
  281 +TEST_F(HueLightTest, getProductname)
  282 +{
  283 + const HueLight ctest_light_1 = test_bridge.getLight(1);
  284 + const HueLight ctest_light_2 = test_bridge.getLight(2);
  285 + const HueLight ctest_light_3 = test_bridge.getLight(3);
  286 + HueLight test_light_1 = test_bridge.getLight(1);
  287 + HueLight test_light_2 = test_bridge.getLight(2);
  288 + HueLight test_light_3 = test_bridge.getLight(3);
  289 +
  290 + EXPECT_EQ("Hue bloom", ctest_light_1.getProductname());
  291 + EXPECT_EQ("", ctest_light_2.getProductname());
  292 + EXPECT_EQ("Hue bloom", ctest_light_3.getProductname());
  293 + EXPECT_EQ("Hue bloom", test_light_1.getProductname());
  294 + EXPECT_EQ("", test_light_2.getProductname());
  295 + EXPECT_EQ("Hue bloom", test_light_3.getProductname());
  296 +}
  297 +
279 298 TEST_F(HueLightTest, getLuminaireUId)
280 299 {
281 300 const HueLight ctest_light_1 = test_bridge.getLight(1);
... ...