From c23d117bbb82614d89455768ed424639298b6c28 Mon Sep 17 00:00:00 2001 From: Jasem Mutlaq Date: Sat, 8 Jun 2024 20:33:21 +0300 Subject: [PATCH] WHen changing brightness, only set value if enabled already. For zero, disable it --- drivers/auxiliary/wanderer_cover_v4_ec.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/auxiliary/wanderer_cover_v4_ec.cpp b/drivers/auxiliary/wanderer_cover_v4_ec.cpp index b8e6a085ff..cae79d4a14 100644 --- a/drivers/auxiliary/wanderer_cover_v4_ec.cpp +++ b/drivers/auxiliary/wanderer_cover_v4_ec.cpp @@ -68,6 +68,7 @@ bool WandererCoverV4EC::initProperties() DataNP.fill(getDeviceName(), "STATUS", "Real Time Status", MAIN_CONTROL_TAB, IP_RO, 60, IPS_IDLE); LightIntensityNP.np[0].max = 255; + LightIntensityNP.np[0].value = 100; // Heater SetHeaterNP[Heat].fill( "Heater", "PWM", "%.2f", 0, 150, 50, 0); @@ -404,11 +405,21 @@ IPState WandererCoverV4EC::UnParkCap() //////////////////////////////////////////////////////////////////////////////////////////////////////// bool WandererCoverV4EC::SetLightBoxBrightness(uint16_t value) { - auto rc = false; + auto rc = true; if(value > 0) - rc = sendCommand(std::to_string(value)); + { + // Only change if already enabled. + if (LightS[INDI_ENABLED].s == ISS_ON) + rc = sendCommand(std::to_string(value)); + } else - rc = sendCommand("9999"); + { + EnableLightBox(false); + LightS[INDI_ENABLED].s = ISS_OFF; + LightS[INDI_DISABLED].s = ISS_OFF; + LightSP.s = IPS_IDLE; + IDSetSwitch(&LightSP, nullptr); + } return rc; }