Get current WLED state as JSON object.
- Returns
- JSON object with "on" and "bri" fields
Example: fl::json state = remote.getState(); // Returns: {"on":true,"bri":128}
Definition at line 405 of file wled.cpp.hpp.
405 {
414
415
422
423
427 state.set(
"udpn", udpn);
428
429
432 }
433
434
439
440 segJson.
set(
"id",
static_cast<i64>(seg.mId));
441 segJson.
set(
"start",
static_cast<i64>(seg.mStart));
442 segJson.
set(
"stop",
static_cast<i64>(seg.mStop));
443 segJson.
set(
"len",
static_cast<i64>(seg.mLen));
444 segJson.
set(
"grp",
static_cast<i64>(seg.mGrp));
445 segJson.
set(
"spc",
static_cast<i64>(seg.mSpc));
446 segJson.
set(
"of",
static_cast<i64>(seg.mOf));
447 segJson.
set(
"on", seg.mOn);
448 segJson.
set(
"bri",
static_cast<i64>(seg.mBri));
449 segJson.
set(
"cct",
static_cast<i64>(seg.mCct));
450
451
452 segJson.
set(
"fx",
static_cast<i64>(seg.mFx));
453 segJson.
set(
"sx",
static_cast<i64>(seg.mSx));
454 segJson.
set(
"ix",
static_cast<i64>(seg.mIx));
455 segJson.
set(
"pal",
static_cast<i64>(seg.mPal));
456 segJson.
set(
"c1",
static_cast<i64>(seg.mC1));
457 segJson.
set(
"c2",
static_cast<i64>(seg.mC2));
458 segJson.
set(
"c3",
static_cast<i64>(seg.mC3));
459
460
461 segJson.
set(
"sel", seg.mSel);
462 segJson.
set(
"rev", seg.mRev);
463 segJson.
set(
"mi", seg.mMi);
464 segJson.
set(
"o1", seg.mO1);
465 segJson.
set(
"o2", seg.mO2);
466 segJson.
set(
"o3", seg.mO3);
467 segJson.
set(
"si",
static_cast<i64>(seg.mSi));
468 segJson.
set(
"m12",
static_cast<i64>(seg.mM12));
469 segJson.
set(
"rpt", seg.mRpt);
470
471 if (!seg.mName.empty()) {
472 segJson.
set(
"n", seg.mName);
473 }
474
475
476 if (!seg.mColors.empty()) {
478 for (const auto& color : seg.mColors) {
479 if (color.size() >= 3) {
481 for (size_t i = 0; i < color.size(); i++) {
482 colorArray.
push_back(fl::json(
static_cast<i64>(color[i])));
483 }
485 }
486 }
487 segJson.
set(
"col", colors);
488 }
489
490
491 if (!seg.mIndividualLeds.empty()) {
493 for (const auto& led : seg.mIndividualLeds) {
494 if (led.size() >= 3) {
496 leds.push_back(fl::json(hexColor.
c_str()));
497 }
498 }
500 }
501
503 }
504 state.set(
"seg", segments);
505 }
506
508}
fl::json getPlaylistConfig() const
Get playlist configuration.
u8 mNightlightTargetBrightness
fl::vector< WLEDSegment > mSegments
bool hasPlaylistConfig() const
Check if playlist is active.
const char * c_str() const FL_NOEXCEPT
void push_back(const json &value) FL_NOEXCEPT
void set(const fl::string &key, const json &value) FL_NOEXCEPT
static json object() FL_NOEXCEPT
static json array() FL_NOEXCEPT
fl::string rgbToHex(u8 r, u8 g, u8 b)
Convert RGB components to hex string.
References fl::json::array(), fl::basic_string::c_str(), getPlaylistConfig(), hasPlaylistConfig(), leds, mLiveOverride, mMainSegment, mNightlightDuration, mNightlightMode, mNightlightOn, mNightlightTargetBrightness, mPlaylist, mPreset, mSegments, mTransition, mUdpReceive, mUdpSend, mWledBri, mWledOn, fl::json::object(), fl::json::push_back(), fl::wled::rgbToHex(), fl::json::set(), and state.