mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Clean-up and Fixes
This commit is contained in:
parent
661f222d28
commit
00085410f3
@ -193,10 +193,7 @@ const uint8_t PAYLOAD_PER_CHANNEL_V2[] =
|
||||
|
||||
bool operator ==(const CiColor& p1, const CiColor& p2)
|
||||
{
|
||||
return ((fabs(p1.x - p2.x) > std::numeric_limits<double>::epsilon()) &&
|
||||
(fabs(p1.y - p2.y) > std::numeric_limits<double>::epsilon()) &&
|
||||
(fabs(p1.bri - p2.bri) > std::numeric_limits<double>::epsilon())
|
||||
);
|
||||
return ((p1.x == p2.x) && (p1.y == p2.y) && (p1.bri == p2.bri));
|
||||
}
|
||||
|
||||
bool operator != (const CiColor& p1, const CiColor& p2)
|
||||
@ -281,7 +278,6 @@ CiColor CiColor::rgbToCiColor(double red, double green, double blue, const CiCol
|
||||
}
|
||||
if (dBC < lowest)
|
||||
{
|
||||
//lowest = dBC;
|
||||
closestPoint = pBC;
|
||||
}
|
||||
// Change the xy value to a value which is within the reach of the lamp.
|
||||
@ -1759,8 +1755,6 @@ LedDevicePhilipsHue::LedDevicePhilipsHue(const QJsonObject& deviceConfig)
|
||||
, _onBlackTimeToPowerOff(100)
|
||||
, _onBlackTimeToPowerOn(100)
|
||||
, _candyGamma(true)
|
||||
, _lastConfirm(0)
|
||||
, _lastId(-1)
|
||||
, _groupStreamState(false)
|
||||
{
|
||||
}
|
||||
@ -1825,7 +1819,7 @@ bool LedDevicePhilipsHue::init(const QJsonObject &deviceConfig)
|
||||
|
||||
if( _groupId.isEmpty() )
|
||||
{
|
||||
Error(_log, "Disabling usage of HueEntertainmentAPI: Group-ID is invalid", "%s", QSTRING_CSTR(_groupId) );
|
||||
Error(_log, "Disabling usage of Entertainment API - Group-ID is invalid [%s]", QSTRING_CSTR(_groupId) );
|
||||
_useEntertainmentAPI = false;
|
||||
}
|
||||
}
|
||||
@ -2528,7 +2522,20 @@ void LedDevicePhilipsHue::setState(PhilipsHueLight& light, bool on, const CiColo
|
||||
QJsonObject cmd;
|
||||
bool forceCmd {false};
|
||||
|
||||
if (light.getOnOffState())
|
||||
if (light.getOnOffState() != on)
|
||||
{
|
||||
forceCmd = true;
|
||||
if (_useApiV2)
|
||||
{
|
||||
cmd.insert(API_STATE_ON, QJsonObject {{API_STATE_ON, on }});
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.insert(API_STATE_ON, on);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_useEntertainmentAPI && light.getOnOffState())
|
||||
{
|
||||
if (light.getTransitionTime() != _transitionTime)
|
||||
{
|
||||
@ -2543,6 +2550,8 @@ void LedDevicePhilipsHue::setState(PhilipsHueLight& light, bool on, const CiColo
|
||||
}
|
||||
|
||||
if (!light.hasColor() || light.getColor() != color)
|
||||
{
|
||||
if (!light.isBusy() || forceCmd)
|
||||
{
|
||||
if (_useApiV2)
|
||||
{
|
||||
@ -2566,21 +2575,9 @@ void LedDevicePhilipsHue::setState(PhilipsHueLight& light, bool on, const CiColo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (light.getOnOffState() != on)
|
||||
{
|
||||
forceCmd = true;
|
||||
if (_useApiV2)
|
||||
{
|
||||
cmd.insert(API_STATE_ON, QJsonObject {{API_STATE_ON, on }});
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.insert(API_STATE_ON, on);
|
||||
}
|
||||
}
|
||||
|
||||
if (!light.isBusy() || forceCmd)
|
||||
if (!cmd.isEmpty())
|
||||
{
|
||||
if (_useApiV2)
|
||||
{
|
||||
@ -2592,15 +2589,6 @@ void LedDevicePhilipsHue::setState(PhilipsHueLight& light, bool on, const CiColo
|
||||
}
|
||||
put(resourcePath, cmd);
|
||||
|
||||
qint64 _currentTime = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
if ((_currentTime - _lastConfirm > 1500 && light.getId() != _lastId) ||
|
||||
(_currentTime - _lastConfirm > 3000))
|
||||
{
|
||||
_lastId = light.getId();
|
||||
_lastConfirm = _currentTime;
|
||||
}
|
||||
|
||||
if (!isInError())
|
||||
{
|
||||
light.setTransitionTime( _transitionTime );
|
||||
@ -2704,8 +2692,6 @@ bool LedDevicePhilipsHue::switchOff()
|
||||
}
|
||||
else
|
||||
{
|
||||
writeBlack();
|
||||
|
||||
_isOn = false;
|
||||
rc = stopStream();
|
||||
|
||||
|
@ -638,7 +638,5 @@ private:
|
||||
int _onBlackTimeToPowerOn;
|
||||
bool _candyGamma;
|
||||
|
||||
qint64 _lastConfirm;
|
||||
QString _lastId;
|
||||
bool _groupStreamState;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user