Upgrade WLED.NET JSON API coverage and ergonomics#15
Merged
Conversation
- Add intent methods (TurnOn/TurnOff/Toggle/SetBrightness/SetColor/SetEffect/SetPalette/Reboot) - Add CancellationToken to every client method - Add typed exception hierarchy (WledException + connection/response/version) - Add HttpClient constructor and Kevsoft.WLED.DependencyInjection AddWledClient - Add intent, exception and DI tests
… sample - Rewrite README around intent methods, fluent builders, DI and error handling - Add a supported-features capability matrix and document target frameworks - Add CHANGELOG.md (Keep a Changelog format) - Rewrite BasicConsole sample to showcase the ergonomic API
…cked escape hatch
Model the state 'seg' field as a union (SegmentPayload) that serializes as either an object (selected segments) or an array (id-targeted), matching the WLED API. No-id SetColor/SetEffect/SetPalette now emit the object form instead of an array that WLED would infer as id:0.
Model id.mdns, if.mqtt (en/broker/port/user/cid) and def (on/bri/ps) as typed properties while keeping JsonExtensionData as an escape hatch for everything else.
Add root AGENTS.md with project conventions, commands and gotchas. Add EffectCatalog/PaletteCatalog with id/name lookup, reserved-entry filtering (RSVD/-), and SetEffect/SetPalette catalog-entry overloads.
StateUpdate.SelectedSegments(...) targets the selected segments via the seg object form and accumulates across calls. Mixing it with Segment(id, ...) in one update throws, since WLED's seg field is one form or the other.
GetDevice() issues a single GET /json and exposes state, info and typed effect/palette catalogs as one snapshot, with per-segment effect/palette resolution and derived helpers (SelectedSegments, ActiveSegments, SupportsWhiteChannel, etc). Effect metadata is opt-in to avoid extra requests.
Add lookup helpers (FindById/FindByName/Try*) over effect metadata collections, plus SegmentUpdate.Effect(EffectMetadata) and ApplyEffectDefaults(EffectMetadata) to set speed/intensity/custom sliders from metadata defaults (c3 clamped to 0-31).
Introduce SegmentId, EffectId, PaletteId, PresetId, PlaylistId, LedMapId, SegmentBounds and MatrixBounds readonly structs with range validation, equality and netstandard2.0-safe hashing. Wire SegmentBounds and MatrixBounds into SegmentUpdate.Range/Range2D and LedMapId into StateUpdate.LoadLedMap as non-ambiguous overloads.
Introduce ConfigUpdate and an UpdateConfig(Action<ConfigUpdate>) client overload exposing Identity, Mqtt and BootDefaults helpers. Only touched sections and fields are serialised, reusing the existing network opt-in guard.
Add README sections and feature-matrix rows for the device snapshot, catalogs, selected-segment updates, strong value types and the fluent config builder; expand the CHANGELOG and BasicConsole sample to match.
Copy the Kevsoft.WLED.DependencyInjection csproj and sources so dotnet restore (which reads the solution) and the build/pack stages succeed. Build the DI project (transitively building the main library) instead of globbing multiple csproj into a single dotnet build, and pack each packable library explicitly. Also align FROM..AS keyword casing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a foundational overhaul to modernize the WLED.NET library, focusing on updating target frameworks, improving documentation, and laying out a clear development roadmap. The main goals are to support modern .NET versions, improve developer experience with strong typing and fluent APIs, and provide clear documentation and plans for future enhancements.
Key changes include:
Target Framework Modernization
net8.0,net9.0,net10.0, andnetstandard2.0inDirectory.Build.props, ensuring compatibility with both modern and legacy consumers. Test and sample projects are also updated to target modern frameworks.Documentation & Roadmap
CHANGELOG.mdis introduced, documenting the breaking changes, new features (such as strong value types, fluent builders, intent methods, DI integration, and a typed exception hierarchy), and removals of legacy APIs.README.mdis rewritten to reflect the new API design, usage patterns, supported frameworks, error handling, and feature matrix, making it easier for developers to get started and understand the library's capabilities.Solution Structure
WLED.NET.sln) is updated to include the newKevsoft.WLED.DependencyInjectionproject and ensure correct build configurations across all target frameworks. [1] [2] [3]Most important changes:
1. Target Framework and Build Modernization
net8.0,net9.0,net10.0, andnetstandard2.0inDirectory.Build.propsto support both legacy and modern consumers.2. Documentation and Developer Guidance
CHANGELOG.mddocumenting all notable changes, breaking updates, and new features in the overhaul.README.mdto reflect the new API surface, usage patterns, dependency injection, error handling, and supported features.3. Roadmap and Planning
4. Solution Structure Updates
WLED.NET.slnto include the new dependency injection project and ensure correct build matrix for all frameworks. [1] [2] [3]