mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Differentiate between LED-Device Enable/Disable and Switch On/Off (#960)
* Switch Off devices, when no input source * Realign Enable/SwitchOn, Disable/SwitchOff * Align to updated LedDevice-Flow * Remove debug statements slipped in * Send last color update after enabling again * Fix WLED getProperties API call * Remove unused signals * LedDevice process flow documentation * LedDevice process flow documentation Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -116,11 +116,12 @@ LedDeviceNanoleaf::~LedDeviceNanoleaf()
|
||||
bool LedDeviceNanoleaf::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
// Overwrite non supported/required features
|
||||
_devConfig["latchTime"] = 0;
|
||||
setLatchTime(0);
|
||||
setRewriteTime(0);
|
||||
|
||||
if (deviceConfig["rewriteTime"].toInt(0) > 0)
|
||||
{
|
||||
Info (_log, "Device Nanoleaf does not require rewrites. Refresh time is ignored.");
|
||||
_devConfig["rewriteTime"] = 0;
|
||||
}
|
||||
|
||||
DebugIf(verbose, _log, "deviceConfig: [%s]", QString(QJsonDocument(_devConfig).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||
@@ -133,7 +134,7 @@ bool LedDeviceNanoleaf::init(const QJsonObject &deviceConfig)
|
||||
Debug(_log, "DeviceType : %s", QSTRING_CSTR( this->getActiveDeviceType() ));
|
||||
Debug(_log, "LedCount : %u", configuredLedCount);
|
||||
Debug(_log, "ColorOrder : %s", QSTRING_CSTR( this->getColorOrder() ));
|
||||
Debug(_log, "RefreshTime : %d", _refreshTimerInterval_ms);
|
||||
Debug(_log, "RewriteTime : %d", this->getRewriteTime());
|
||||
Debug(_log, "LatchTime : %d", this->getLatchTime());
|
||||
|
||||
// Read panel organisation configuration
|
||||
@@ -356,8 +357,6 @@ int LedDeviceNanoleaf::open()
|
||||
int retval = -1;
|
||||
_isDeviceReady = false;
|
||||
|
||||
// Set Nanoleaf to External Control (UDP) mode
|
||||
Debug(_log, "Set Nanoleaf to External Control (UDP) streaming mode");
|
||||
QJsonDocument responseDoc = changeToExternalControlMode();
|
||||
// Resolve port for Light Panels
|
||||
QJsonObject jsonStreamControllInfo = responseDoc.object();
|
||||
@@ -488,6 +487,8 @@ bool LedDeviceNanoleaf::powerOn()
|
||||
{
|
||||
if ( _isDeviceReady)
|
||||
{
|
||||
changeToExternalControlMode();
|
||||
|
||||
//Power-on Nanoleaf device
|
||||
_restApi->setPath(API_STATE);
|
||||
_restApi->put( getOnOffRequest(true) );
|
||||
@@ -514,6 +515,7 @@ QString LedDeviceNanoleaf::getOnOffRequest(bool isOn) const
|
||||
|
||||
QJsonDocument LedDeviceNanoleaf::changeToExternalControlMode()
|
||||
{
|
||||
Debug(_log, "Set Nanoleaf to External Control (UDP) streaming mode");
|
||||
_extControlVersion = EXTCTRLVER_V2;
|
||||
//Enable UDP Mode v2
|
||||
|
||||
|
@@ -215,15 +215,10 @@ QJsonObject LedDeviceWled::getProperties(const QJsonObject& params)
|
||||
apiPort = API_DEFAULT_PORT;
|
||||
}
|
||||
|
||||
if ( filter.startsWith("/") )
|
||||
filter.remove(0,1);
|
||||
|
||||
initRestAPI(apiHost, apiPort);
|
||||
_restApi->setPath(API_PATH_INFO);
|
||||
_restApi->setPath(filter);
|
||||
|
||||
// Perform request
|
||||
// TODO: WLED::getProperties - Check, if filter is supported
|
||||
httpResponse response = _restApi->put(filter);
|
||||
httpResponse response = _restApi->get();
|
||||
if ( response.error() )
|
||||
{
|
||||
Warning (_log, "%s get properties failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
||||
|
@@ -997,10 +997,11 @@ LedDevice* LedDeviceYeelight::construct(const QJsonObject &deviceConfig)
|
||||
bool LedDeviceYeelight::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
// Overwrite non supported/required features
|
||||
setRewriteTime(0);
|
||||
|
||||
if (deviceConfig["rewriteTime"].toInt(0) > 0)
|
||||
{
|
||||
Info (_log, "Yeelights do not require rewrites. Refresh time is ignored.");
|
||||
_devConfig["rewriteTime"] = 0;
|
||||
}
|
||||
|
||||
DebugIf(verbose, _log, "deviceConfig: [%s]", QString(QJsonDocument(_devConfig).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||
@@ -1012,7 +1013,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig)
|
||||
Debug(_log, "DeviceType : %s", QSTRING_CSTR( this->getActiveDeviceType() ));
|
||||
Debug(_log, "LedCount : %u", this->getLedCount());
|
||||
Debug(_log, "ColorOrder : %s", QSTRING_CSTR( this->getColorOrder() ));
|
||||
Debug(_log, "RefreshTime : %d", _refreshTimerInterval_ms);
|
||||
Debug(_log, "RewriteTime : %d", this->getRewriteTime());
|
||||
Debug(_log, "LatchTime : %d", this->getLatchTime());
|
||||
|
||||
//Get device specific configuration
|
||||
|
Reference in New Issue
Block a user