diff --git a/include/hueplusplus/Bridge.h b/include/hueplusplus/Bridge.h index e208f3e..04797a0 100644 --- a/include/hueplusplus/Bridge.h +++ b/include/hueplusplus/Bridge.h @@ -180,6 +180,11 @@ public: //! \return string containing ip std::string getBridgeIP() const; + //! \brief Function to set stream mode to active for entertainment mode + //! + //! \return bool - whether stream request was successful + bool StartStreaming(std::string group_identifier); + //! \brief Function to get the port of the hue bridge //! //! \return integer containing port diff --git a/src/Bridge.cpp b/src/Bridge.cpp index 8af6ede..05652cf 100644 --- a/src/Bridge.cpp +++ b/src/Bridge.cpp @@ -248,6 +248,34 @@ std::string Bridge::requestUsername() return username; } +bool Bridge::StartStreaming(std::string group_identifier) +{ + nlohmann::json request; + + request["stream"]["active"] = true; + + nlohmann::json answer; + + std::string uri = "/api/" + username + "/groups/" + group_identifier; + + answer = http_handler->PUTJson(uri, request, ip, port); + + if(answer[0].contains("success")) + { + std::string key = "/groups/" + group_identifier + "/stream/active"; + + if(answer[0]["success"].contains(key)) + { + if(answer[0]["success"][key] == true) + { + return true; + } + } + } + + return false; +} + std::string Bridge::getUsername() const { return username;