Fix assumed_state switch webserver (#4259)

This commit is contained in:
RoboMagus 2023-04-30 21:28:21 +02:00 committed by GitHub
parent 59d6b3afa0
commit 568e65a6ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -428,6 +428,9 @@ void WebServer::on_switch_update(switch_::Switch *obj, bool state) {
std::string WebServer::switch_json(switch_::Switch *obj, bool value, JsonDetail start_config) {
return json::build_json([obj, value, start_config](JsonObject root) {
set_json_icon_state_value(root, obj, "switch-" + obj->get_object_id(), value ? "ON" : "OFF", value, start_config);
if (start_config == DETAIL_ALL) {
root["assumed_state"] = obj->assumed_state();
}
});
}
void WebServer::handle_switch_request(AsyncWebServerRequest *request, const UrlMatch &match) {