Commit a3900e59d99fd472f28f9fc72232ee08d1610d7b
1 parent
0cc3f77c
Fix issue #8
- also remove uneeded std::cout
Showing
1 changed file
with
12 additions
and
12 deletions
hueplusplus/HueLight.cpp
| ... | ... | @@ -27,14 +27,12 @@ |
| 27 | 27 | |
| 28 | 28 | bool HueLight::On(uint8_t transition) |
| 29 | 29 | { |
| 30 | - std::cout << "Turning lamp with id: " << id << " on\n"; | |
| 31 | 30 | refreshState(); |
| 32 | 31 | return OnNoRefresh(transition); |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | 34 | bool HueLight::Off(uint8_t transition) |
| 36 | 35 | { |
| 37 | - std::cout << "Turning lamp with id: " << id << " off\n"; | |
| 38 | 36 | refreshState(); |
| 39 | 37 | return OffNoRefresh(transition); |
| 40 | 38 | } |
| ... | ... | @@ -141,8 +139,6 @@ unsigned int HueLight::MiredToKelvin(unsigned int mired) const |
| 141 | 139 | |
| 142 | 140 | bool HueLight::alert() |
| 143 | 141 | { |
| 144 | - std::cout << "alert()\n"; | |
| 145 | - | |
| 146 | 142 | Json::Value request; |
| 147 | 143 | request["alert"] = "select"; |
| 148 | 144 | |
| ... | ... | @@ -175,7 +171,6 @@ HueLight::HueLight(const std::string& ip, const std::string& username, int id, s |
| 175 | 171 | |
| 176 | 172 | bool HueLight::OnNoRefresh(uint8_t transition) |
| 177 | 173 | { |
| 178 | - std::cout << "\tOnNoRefresh()\n"; | |
| 179 | 174 | Json::Value request(Json::objectValue); |
| 180 | 175 | if (transition != 4) |
| 181 | 176 | { |
| ... | ... | @@ -214,7 +209,6 @@ bool HueLight::OnNoRefresh(uint8_t transition) |
| 214 | 209 | |
| 215 | 210 | bool HueLight::OffNoRefresh(uint8_t transition) |
| 216 | 211 | { |
| 217 | - std::cout << "\tOffNoRefresh()\n"; | |
| 218 | 212 | Json::Value request(Json::objectValue); |
| 219 | 213 | if (transition != 4) |
| 220 | 214 | { |
| ... | ... | @@ -258,10 +252,16 @@ Json::Value HueLight::SendPutRequest(const Json::Value& request, const std::stri |
| 258 | 252 | |
| 259 | 253 | void HueLight::refreshState() |
| 260 | 254 | { |
| 261 | - std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); | |
| 262 | - std::cout << "\tRefreshing lampstate of lamp with id: " << id << ", ip: " << ip << "\n"; | |
| 263 | - | |
| 264 | - state = http_handler->GETJson("/api/"+username+"/lights/"+std::to_string(id), Json::objectValue, ip); | |
| 265 | - | |
| 266 | - std::cout << "\tRefresh state took: " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count() << "ms" << std::endl; | |
| 255 | + //std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); | |
| 256 | + //std::cout << "\tRefreshing lampstate of lamp with id: " << id << ", ip: " << ip << "\n"; | |
| 257 | + Json::Value answer = http_handler->GETJson("/api/"+username+"/lights/"+std::to_string(id), Json::objectValue, ip); | |
| 258 | + if (answer.isObject() && answer.isMember("state")) | |
| 259 | + { | |
| 260 | + state = answer; | |
| 261 | + } | |
| 262 | + else | |
| 263 | + { | |
| 264 | + std::cout << "Answer in HueLight::refreshState of http_handler->GETJson(...) is not expected!\nAnswer:\n\t" << answer.toStyledString() << std::endl; | |
| 265 | + } | |
| 266 | + //std::cout << "\tRefresh state took: " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count() << "ms" << std::endl; | |
| 267 | 267 | } | ... | ... |