Skip to content
Prev Previous commit
Next Next commit
Fix Yeelight
  • Loading branch information
ratawhisk authored and awawa-dev committed Jan 28, 2024
commit f13b3e17e490469fe1930e288c157fb036d29234
23 changes: 18 additions & 5 deletions sources/leddevice/dev_net/LedDeviceYeelight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ bool YeelightLight::setPower(bool on, YeelightLight::API_EFFECT effect, int dura
static_cast<int>(_isOn), static_cast<int>(_isInMusicMode));

// Disable music mode to get power-off command executed
setMusicMode(false);
if (!on && _isInMusicMode)
{
if (_tcpStreamSocket != nullptr)
Expand All @@ -709,7 +710,7 @@ bool YeelightLight::setPower(bool on, YeelightLight::API_EFFECT effect, int dura
}
log(2,
"setPower() rc",
"%d, isON[%d], isInMusicMode[)%d]",
"%d, isON[%d], isInMusicMode[%d]",
static_cast<int>(rc), static_cast<int>(_isOn), static_cast<int>(_isInMusicMode));

return rc;
Expand Down Expand Up @@ -928,12 +929,24 @@ bool YeelightLight::setMusicMode(bool on, const QHostAddress& hostAddress, int p
if (on)
{
paramlist << hostAddress.toString() << port;

// Music Mode is only on, if write did not fail nor quota was exceeded
if ( writeCommand( getCommand( API_METHOD_MUSIC_MODE, paramlist ) ) > -1 )
{
_isInMusicMode = on;
rc = true;
}
}

// Music Mode is only on, if write did not fail nor quota was exceeded
if (writeCommand(getCommand(API_METHOD_MUSIC_MODE, paramlist)) > -1)
else
{
_isInMusicMode = on;
auto wasInError = _isInError;
writeCommand( getCommand( API_METHOD_MUSIC_MODE, paramlist ));
if (_isInError && !wasInError)
{
Warning(_log, "Ignoring Yeelight error when turning off music mode");
_isInError = false;
}
_isInMusicMode = false;
rc = true;
}

Expand Down
2 changes: 1 addition & 1 deletion www/js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ async function discover_yeelight_lights()

function assign_yeelight_lights()
{
var models = ['color', 'color1', 'color2', 'color4', 'stripe', 'strip1'];
var models = ['color', 'color1', 'YLDP02YL', 'YLDP02YL', 'color2', 'YLDP06YL', 'color4', 'YLDP13YL', 'color6', 'YLDP13AYL', 'colorc', "YLDP004-A", 'stripe', 'YLDD04YL', 'strip1', 'YLDD01YL', 'YLDD02YL', 'strip4', 'YLDD05YL', 'strip6', 'YLDD05YL'];

// If records are left for configuration
if (Object.keys(lights).length > 0)
Expand Down