diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index d03d3f5..819c762 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -377,21 +377,17 @@ api: variables: option: string then: - - if: - condition: - text_sensor.state: - id: disp1_currentpage - state: 'screensaver' - then: - - lambda: id(disp1).send_command_printf("page home"); - else: - - if: - condition: - text_sensor.state: - id: disp1_currentpage - state: 'home' - then: - - lambda: id(disp1).send_command_printf("dim=brightness.val"); + - lambda: |- + DynamicJsonDocument doc(1024); + deserializeJson(doc, id(disp1_nspanel_event).state); + std::string page = doc["page"]; + if (page == "screensaver") { + id(disp1).send_command_printf("page home"); + } else { + if (page == "home"){ + id(disp1).send_command_printf("dim=brightness.val"); + } + } - if: condition: - lambda: 'return option == "keep_wake";'