Commit 4ae8d997707f1f58776463e552971c7f9c000bb9
Committed by
Moritz Wirger
1 parent
cf1bda91
Move model pictures out of Hue class.
Showing
6 changed files
with
191 additions
and
186 deletions
include/hueplusplus/Hue.h
| ... | ... | @@ -346,25 +346,6 @@ public: |
| 346 | 346 | |
| 347 | 347 | ///@} |
| 348 | 348 | |
| 349 | - //! \brief Const function that returns the picture name of a given light id | |
| 350 | - //! | |
| 351 | - //! \note This will not update the local state of the bridge. | |
| 352 | - //! \note This function will only return the filename without extension, | |
| 353 | - //! because Philips provides different file types. \param id Id of a light to | |
| 354 | - //! get the picture of \return String that either contains the filename of the | |
| 355 | - //! picture of the light or if it was not found an empty string | |
| 356 | - std::string getPictureOfLight(int id); | |
| 357 | - | |
| 358 | - //! \brief Const function that returns the picture name of a given model id | |
| 359 | - //! | |
| 360 | - //! \note This will not update the local state of the bridge. | |
| 361 | - //! \note This function will only return the filename without extension, | |
| 362 | - //! because Philips provides different file types. \param model_id Model Id of | |
| 363 | - //! a device to get the picture of \return String that either contains the | |
| 364 | - //! filename of the picture of the device or if it was not found an empty | |
| 365 | - //! string | |
| 366 | - std::string getPictureOfModel(const std::string& model_id) const; | |
| 367 | - | |
| 368 | 349 | private: |
| 369 | 350 | std::string ip; //!< IP-Address of the hue bridge in dotted decimal notation |
| 370 | 351 | //!< like "192.168.2.1" | ... | ... |
include/hueplusplus/ModelPictures.h
0 → 100644
| 1 | +/** | |
| 2 | + \file ModelPictures.h | |
| 3 | + Copyright Notice\n | |
| 4 | + Copyright (C) 2020 Jan Rogall - developer\n | |
| 5 | + | |
| 6 | + This file is part of hueplusplus. | |
| 7 | + | |
| 8 | + hueplusplus is free software: you can redistribute it and/or modify | |
| 9 | + it under the terms of the GNU Lesser General Public License as published by | |
| 10 | + the Free Software Foundation, either version 3 of the License, or | |
| 11 | + (at your option) any later version. | |
| 12 | + | |
| 13 | + hueplusplus is distributed in the hope that it will be useful, | |
| 14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + GNU Lesser General Public License for more details. | |
| 17 | + | |
| 18 | + You should have received a copy of the GNU Lesser General Public License | |
| 19 | + along with hueplusplus. If not, see <http://www.gnu.org/licenses/>. | |
| 20 | +**/ | |
| 21 | + | |
| 22 | +#ifndef INCLUDE_HUEPLUSPLUS_MODEL_PICTURES_H | |
| 23 | +#define INCLUDE_HUEPLUSPLUS_MODEL_PICTURES_H | |
| 24 | + | |
| 25 | +#include <string> | |
| 26 | + | |
| 27 | +namespace hueplusplus | |
| 28 | +{ | |
| 29 | + //! \brief Get the picture name of a given model id | |
| 30 | + //! | |
| 31 | + //! \note This function will only return the filename without extension, | |
| 32 | + //! because Philips provides different file types. | |
| 33 | + //! \param model_id Model Id of a device to get the picture of | |
| 34 | + //! \returns String that either contains the filename of the picture of the device | |
| 35 | + //! or an empty string if it was not found. | |
| 36 | + std::string getPictureOfModel(const std::string& modelId); | |
| 37 | +} | |
| 38 | + | |
| 39 | + | |
| 40 | +#endif | |
| 0 | 41 | \ No newline at end of file | ... | ... |
src/CMakeLists.txt
| 1 | 1 | set(hueplusplus_SOURCES |
| 2 | 2 | APICache.cpp |
| 3 | 3 | BaseHttpHandler.cpp |
| 4 | + ColorUnits.cpp | |
| 4 | 5 | ExtendedColorHueStrategy.cpp |
| 5 | 6 | ExtendedColorTemperatureStrategy.cpp |
| 6 | 7 | Group.cpp |
| ... | ... | @@ -9,6 +10,7 @@ set(hueplusplus_SOURCES |
| 9 | 10 | HueDeviceTypes.cpp |
| 10 | 11 | HueException.cpp |
| 11 | 12 | HueLight.cpp |
| 13 | + ModelPictures.cpp | |
| 12 | 14 | Scene.cpp |
| 13 | 15 | Schedule.cpp |
| 14 | 16 | SimpleBrightnessStrategy.cpp |
| ... | ... | @@ -16,9 +18,8 @@ set(hueplusplus_SOURCES |
| 16 | 18 | SimpleColorTemperatureStrategy.cpp |
| 17 | 19 | StateTransaction.cpp |
| 18 | 20 | TimePattern.cpp |
| 19 | - "ColorUnits.cpp" | |
| 20 | 21 | UPnP.cpp |
| 21 | - Utils.cpp ) | |
| 22 | + Utils.cpp) | |
| 22 | 23 | |
| 23 | 24 | # on windows we want to compile the WinHttpHandler |
| 24 | 25 | if(WIN32) | ... | ... |
src/Hue.cpp
| ... | ... | @@ -305,140 +305,6 @@ std::string Hue::createScene(const CreateScene& params) |
| 305 | 305 | return scenes.create(params); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | -std::string Hue::getPictureOfLight(int id) | |
| 309 | -{ | |
| 310 | - std::string ret = ""; | |
| 311 | - if (lights.exists(id)) | |
| 312 | - { | |
| 313 | - ret = getPictureOfModel(lights.get(id).getModelId()); | |
| 314 | - } | |
| 315 | - return ret; | |
| 316 | -} | |
| 317 | - | |
| 318 | -std::string Hue::getPictureOfModel(const std::string& model_id) const | |
| 319 | -{ | |
| 320 | - std::string ret = ""; | |
| 321 | - if (model_id == "LCT001" || model_id == "LCT007" || model_id == "LCT010" || model_id == "LCT014" | |
| 322 | - || model_id == "LTW010" || model_id == "LTW001" || model_id == "LTW004" || model_id == "LTW015" | |
| 323 | - || model_id == "LWB004" || model_id == "LWB006") | |
| 324 | - { | |
| 325 | - ret.append("e27_waca"); | |
| 326 | - } | |
| 327 | - else if (model_id == "LWB010" || model_id == "LWB014") | |
| 328 | - { | |
| 329 | - ret.append("e27_white"); | |
| 330 | - } | |
| 331 | - else if (model_id == "LCT012" || model_id == "LTW012") | |
| 332 | - { | |
| 333 | - ret.append("e14"); | |
| 334 | - } | |
| 335 | - else if (model_id == "LCT002") | |
| 336 | - { | |
| 337 | - ret.append("br30"); | |
| 338 | - } | |
| 339 | - else if (model_id == "LCT011" || model_id == "LTW011") | |
| 340 | - { | |
| 341 | - ret.append("br30_slim"); | |
| 342 | - } | |
| 343 | - else if (model_id == "LCT003") | |
| 344 | - { | |
| 345 | - ret.append("gu10"); | |
| 346 | - } | |
| 347 | - else if (model_id == "LTW013") | |
| 348 | - { | |
| 349 | - ret.append("gu10_perfectfit"); | |
| 350 | - } | |
| 351 | - else if (model_id == "LST001" || model_id == "LST002") | |
| 352 | - { | |
| 353 | - ret.append("lightstrip"); | |
| 354 | - } | |
| 355 | - else if (model_id == "LLC006 " || model_id == "LLC010") | |
| 356 | - { | |
| 357 | - ret.append("iris"); | |
| 358 | - } | |
| 359 | - else if (model_id == "LLC005" || model_id == "LLC011" || model_id == "LLC012" || model_id == "LLC007") | |
| 360 | - { | |
| 361 | - ret.append("bloom"); | |
| 362 | - } | |
| 363 | - else if (model_id == "LLC014") | |
| 364 | - { | |
| 365 | - ret.append("aura"); | |
| 366 | - } | |
| 367 | - else if (model_id == "LLC013") | |
| 368 | - { | |
| 369 | - ret.append("storylight"); | |
| 370 | - } | |
| 371 | - else if (model_id == "LLC020") | |
| 372 | - { | |
| 373 | - ret.append("go"); | |
| 374 | - } | |
| 375 | - else if (model_id == "HBL001" || model_id == "HBL002" || model_id == "HBL003") | |
| 376 | - { | |
| 377 | - ret.append("beyond_ceiling_pendant_table"); | |
| 378 | - } | |
| 379 | - else if (model_id == "HIL001 " || model_id == "HIL002") | |
| 380 | - { | |
| 381 | - ret.append("impulse"); | |
| 382 | - } | |
| 383 | - else if (model_id == "HEL001 " || model_id == "HEL002") | |
| 384 | - { | |
| 385 | - ret.append("entity"); | |
| 386 | - } | |
| 387 | - else if (model_id == "HML001" || model_id == "HML002" || model_id == "HML003" || model_id == "HML004" | |
| 388 | - || model_id == "HML005") | |
| 389 | - { | |
| 390 | - ret.append("phoenix_ceiling_pendant_table_wall"); | |
| 391 | - } | |
| 392 | - else if (model_id == "HML006") | |
| 393 | - { | |
| 394 | - ret.append("phoenix_down"); | |
| 395 | - } | |
| 396 | - else if (model_id == "LTP001" || model_id == "LTP002" || model_id == "LTP003" || model_id == "LTP004" | |
| 397 | - || model_id == "LTP005" || model_id == "LTD003") | |
| 398 | - { | |
| 399 | - ret.append("pendant"); | |
| 400 | - } | |
| 401 | - else if (model_id == "LDF002" || model_id == "LTF001" || model_id == "LTF002" || model_id == "LTC001" | |
| 402 | - || model_id == "LTC002" || model_id == "LTC003" || model_id == "LTC004" || model_id == "LTD001" | |
| 403 | - || model_id == "LTD002" || model_id == "LDF001") | |
| 404 | - { | |
| 405 | - ret.append("ceiling"); | |
| 406 | - } | |
| 407 | - else if (model_id == "LDD002 " || model_id == "LFF001") | |
| 408 | - { | |
| 409 | - ret.append("floor"); | |
| 410 | - } | |
| 411 | - else if (model_id == "LDD001 " || model_id == "LTT001") | |
| 412 | - { | |
| 413 | - ret.append("table"); | |
| 414 | - } | |
| 415 | - else if (model_id == "LDT001 " || model_id == "MWM001") | |
| 416 | - { | |
| 417 | - ret.append("recessed"); | |
| 418 | - } | |
| 419 | - else if (model_id == "BSB001") | |
| 420 | - { | |
| 421 | - ret.append("bridge_v1"); | |
| 422 | - } | |
| 423 | - else if (model_id == "BSB002") | |
| 424 | - { | |
| 425 | - ret.append("bridge_v2"); | |
| 426 | - } | |
| 427 | - else if (model_id == "SWT001") | |
| 428 | - { | |
| 429 | - ret.append("tap"); | |
| 430 | - } | |
| 431 | - else if (model_id == "RWL021") | |
| 432 | - { | |
| 433 | - ret.append("hds"); | |
| 434 | - } | |
| 435 | - else if (model_id == "SML001") | |
| 436 | - { | |
| 437 | - ret.append("motion_sensor"); | |
| 438 | - } | |
| 439 | - return ret; | |
| 440 | -} | |
| 441 | - | |
| 442 | 308 | void Hue::setHttpHandler(std::shared_ptr<const IHttpHandler> handler) |
| 443 | 309 | { |
| 444 | 310 | http_handler = handler; | ... | ... |
src/ModelPictures.cpp
0 → 100644
| 1 | +/** | |
| 2 | + \file ModelPictures.cpp | |
| 3 | + Copyright Notice\n | |
| 4 | + Copyright (C) 2020 Jan Rogall - developer\n | |
| 5 | + | |
| 6 | + This file is part of hueplusplus. | |
| 7 | + | |
| 8 | + hueplusplus is free software: you can redistribute it and/or modify | |
| 9 | + it under the terms of the GNU Lesser General Public License as published by | |
| 10 | + the Free Software Foundation, either version 3 of the License, or | |
| 11 | + (at your option) any later version. | |
| 12 | + | |
| 13 | + hueplusplus is distributed in the hope that it will be useful, | |
| 14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | + GNU Lesser General Public License for more details. | |
| 17 | + | |
| 18 | + You should have received a copy of the GNU Lesser General Public License | |
| 19 | + along with hueplusplus. If not, see <http://www.gnu.org/licenses/>. | |
| 20 | +**/ | |
| 21 | + | |
| 22 | +#include <hueplusplus/ModelPictures.h> | |
| 23 | + | |
| 24 | +namespace hueplusplus | |
| 25 | +{ | |
| 26 | +std::string getPictureOfModel(const std::string& modelId) | |
| 27 | +{ | |
| 28 | + if (modelId == "LCT001" || modelId == "LCT007" || modelId == "LCT010" || modelId == "LCT014" || modelId == "LTW010" | |
| 29 | + || modelId == "LTW001" || modelId == "LTW004" || modelId == "LTW015" || modelId == "LWB004" | |
| 30 | + || modelId == "LWB006") | |
| 31 | + { | |
| 32 | + return "e27_waca"; | |
| 33 | + } | |
| 34 | + else if (modelId == "LWB010" || modelId == "LWB014") | |
| 35 | + { | |
| 36 | + return "e27_white"; | |
| 37 | + } | |
| 38 | + else if (modelId == "LCT012" || modelId == "LTW012") | |
| 39 | + { | |
| 40 | + return "e14"; | |
| 41 | + } | |
| 42 | + else if (modelId == "LCT002") | |
| 43 | + { | |
| 44 | + return "br30"; | |
| 45 | + } | |
| 46 | + else if (modelId == "LCT011" || modelId == "LTW011") | |
| 47 | + { | |
| 48 | + return "br30_slim"; | |
| 49 | + } | |
| 50 | + else if (modelId == "LCT003") | |
| 51 | + { | |
| 52 | + return "gu10"; | |
| 53 | + } | |
| 54 | + else if (modelId == "LTW013") | |
| 55 | + { | |
| 56 | + return "gu10_perfectfit"; | |
| 57 | + } | |
| 58 | + else if (modelId == "LST001" || modelId == "LST002") | |
| 59 | + { | |
| 60 | + return "lightstrip"; | |
| 61 | + } | |
| 62 | + else if (modelId == "LLC006 " || modelId == "LLC010") | |
| 63 | + { | |
| 64 | + return "iris"; | |
| 65 | + } | |
| 66 | + else if (modelId == "LLC005" || modelId == "LLC011" || modelId == "LLC012" || modelId == "LLC007") | |
| 67 | + { | |
| 68 | + return "bloom"; | |
| 69 | + } | |
| 70 | + else if (modelId == "LLC014") | |
| 71 | + { | |
| 72 | + return "aura"; | |
| 73 | + } | |
| 74 | + else if (modelId == "LLC013") | |
| 75 | + { | |
| 76 | + return "storylight"; | |
| 77 | + } | |
| 78 | + else if (modelId == "LLC020") | |
| 79 | + { | |
| 80 | + return "go"; | |
| 81 | + } | |
| 82 | + else if (modelId == "HBL001" || modelId == "HBL002" || modelId == "HBL003") | |
| 83 | + { | |
| 84 | + return "beyond_ceiling_pendant_table"; | |
| 85 | + } | |
| 86 | + else if (modelId == "HIL001 " || modelId == "HIL002") | |
| 87 | + { | |
| 88 | + return "impulse"; | |
| 89 | + } | |
| 90 | + else if (modelId == "HEL001 " || modelId == "HEL002") | |
| 91 | + { | |
| 92 | + return "entity"; | |
| 93 | + } | |
| 94 | + else if (modelId == "HML001" || modelId == "HML002" || modelId == "HML003" || modelId == "HML004" | |
| 95 | + || modelId == "HML005") | |
| 96 | + { | |
| 97 | + return "phoenix_ceiling_pendant_table_wall"; | |
| 98 | + } | |
| 99 | + else if (modelId == "HML006") | |
| 100 | + { | |
| 101 | + return "phoenix_down"; | |
| 102 | + } | |
| 103 | + else if (modelId == "LTP001" || modelId == "LTP002" || modelId == "LTP003" || modelId == "LTP004" | |
| 104 | + || modelId == "LTP005" || modelId == "LTD003") | |
| 105 | + { | |
| 106 | + return "pendant"; | |
| 107 | + } | |
| 108 | + else if (modelId == "LDF002" || modelId == "LTF001" || modelId == "LTF002" || modelId == "LTC001" | |
| 109 | + || modelId == "LTC002" || modelId == "LTC003" || modelId == "LTC004" || modelId == "LTD001" | |
| 110 | + || modelId == "LTD002" || modelId == "LDF001") | |
| 111 | + { | |
| 112 | + return "ceiling"; | |
| 113 | + } | |
| 114 | + else if (modelId == "LDD002 " || modelId == "LFF001") | |
| 115 | + { | |
| 116 | + return "floor"; | |
| 117 | + } | |
| 118 | + else if (modelId == "LDD001 " || modelId == "LTT001") | |
| 119 | + { | |
| 120 | + return "table"; | |
| 121 | + } | |
| 122 | + else if (modelId == "LDT001 " || modelId == "MWM001") | |
| 123 | + { | |
| 124 | + return "recessed"; | |
| 125 | + } | |
| 126 | + else if (modelId == "BSB001") | |
| 127 | + { | |
| 128 | + return "bridge_v1"; | |
| 129 | + } | |
| 130 | + else if (modelId == "BSB002") | |
| 131 | + { | |
| 132 | + return "bridge_v2"; | |
| 133 | + } | |
| 134 | + else if (modelId == "SWT001") | |
| 135 | + { | |
| 136 | + return "tap"; | |
| 137 | + } | |
| 138 | + else if (modelId == "RWL021") | |
| 139 | + { | |
| 140 | + return "hds"; | |
| 141 | + } | |
| 142 | + else if (modelId == "SML001") | |
| 143 | + { | |
| 144 | + return "motion_sensor"; | |
| 145 | + } | |
| 146 | + return ""; | |
| 147 | +} | |
| 148 | +} // namespace hueplusplus | |
| 0 | 149 | \ No newline at end of file | ... | ... |
test/test_Hue.cpp
| ... | ... | @@ -551,34 +551,3 @@ TEST(Hue, createGroup) |
| 551 | 551 | .WillOnce(Return(response)); |
| 552 | 552 | EXPECT_EQ(0, test_bridge.createGroup(create)); |
| 553 | 553 | } |
| 554 | - | |
| 555 | -TEST(Hue, getPictureOfLight) | |
| 556 | -{ | |
| 557 | - using namespace ::testing; | |
| 558 | - std::shared_ptr<MockHttpHandler> handler = std::make_shared<MockHttpHandler>(); | |
| 559 | - nlohmann::json hue_bridge_state {{"lights", | |
| 560 | - {{"1", | |
| 561 | - {{"state", | |
| 562 | - {{"on", true}, {"bri", 254}, {"ct", 366}, {"alert", "none"}, {"colormode", "ct"}, | |
| 563 | - {"reachable", true}}}, | |
| 564 | - {"swupdate", {{"state", "noupdates"}, {"lastinstall", nullptr}}}, {"type", "Color temperature light"}, | |
| 565 | - {"name", "Hue ambiance lamp 1"}, {"modelid", "LTW001"}, {"manufacturername", "Philips"}, | |
| 566 | - {"uniqueid", "00:00:00:00:00:00:00:00-00"}, {"swversion", "5.50.1.19085"}}}}}}; | |
| 567 | - | |
| 568 | - EXPECT_CALL( | |
| 569 | - *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) | |
| 570 | - .Times(AtLeast(1)) | |
| 571 | - .WillRepeatedly(Return(hue_bridge_state)); | |
| 572 | - EXPECT_CALL(*handler, | |
| 573 | - GETJson("/api/" + getBridgeUsername() + "/lights/1", nlohmann::json::object(), getBridgeIp(), getBridgePort())) | |
| 574 | - .Times(AtLeast(1)) | |
| 575 | - .WillRepeatedly(Return(hue_bridge_state["lights"]["1"])); | |
| 576 | - | |
| 577 | - Hue test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler); | |
| 578 | - | |
| 579 | - test_bridge.getLight(1); | |
| 580 | - | |
| 581 | - EXPECT_EQ("", test_bridge.getPictureOfLight(2)); | |
| 582 | - | |
| 583 | - EXPECT_EQ("e27_waca", test_bridge.getPictureOfLight(1)); | |
| 584 | -} | ... | ... |