| 296 | sendPutRequest("/config", nlohmann::json {{"battery", percent}}, CURRENT_FILE_INFO); |
| 297 | } |
| 298 | void DaylightSensor::setCoordinates(const std::string& latitude, const std::string& longitude) |
| 299 | { |
| 300 | nlohmann::json request {{"lat", latitude}, {"long", longitude}}; |
| 301 | // Currently, "none" is supposed to be used for reset; may change to null in the future, |
| 302 | // so the functionality is implemented already |
| 303 | if (latitude.empty()) |
| 304 | { |
| 305 | request["lat"] = nullptr; |
| 306 | } |
| 307 | if (longitude.empty()) |
| 308 | { |
| 309 | request["long"] = nullptr; |
| 310 | } |
| 311 | sendPutRequest("/config", request, CURRENT_FILE_INFO); |
| 312 | } |
| 313 | bool DaylightSensor::isConfigured() const |
| 314 | { |
| 315 | return state.getValue().at("config").at("configured").get<bool>(); |