Merged
Conversation
Gateways without IoT subdevice support (e.g. GW1100) were being polled for subdevices, causing errors. Added a `subdevices` boolean to GatewayOptions (default false) so only capable gateways (GW1200, GW2000, GW3000) get polled when explicitly opted in.
Gateways must now be explicitly configured via the gateways list in appsettings.json. The auto-discovery path was half-broken (discovered gateways never got added to subdevice polling) and redundant now that each gateway entry carries a subdevices flag.
Prevents a race condition where subdevice polling creates a stub gateway (no model, wrong name) before weather data arrives, causing duplicate devices in Home Assistant. Subdevices are now picked up on the next polling cycle after the gateway is properly initialized.
Load appsettings.{ASPNETCORE_ENVIRONMENT}.json in the custom config
builder so Development overrides (gateway config, log levels) work
without polluting the base appsettings.json.
Remove invalid '/5' unit of measurement that HA rejects for signal_strength. The value is unitless (0-5 scale).
There was a problem hiding this comment.
Pull request overview
This PR updates Ecowitt subdevice polling configuration by removing the global autodiscovery flag and introducing a per-gateway subdevices toggle, along with related orchestrator/config message adjustments and documentation updates.
Changes:
- Remove
AutoDiscoveryfromEcowittOptions/HttpConfigand delete autodiscovery-driven runtime behaviors. - Add
ecowitt.gateways[].subdevicesand filter HTTP polling hosts to only those gateways. - Improve local development configuration/docs and add environment-specific config loading in
Program.cs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Ecowitt.Controller/appsettings.json | Removes autodiscovery; adds per-gateway subdevices flag. |
| src/Ecowitt.Controller/appsettings.Development.json | Updates dev defaults (Serilog + mqtt + ecowitt gateway example incl. subdevices). |
| src/Ecowitt.Controller/Service/Orchestrator/Dispatcher.cs | Emits HTTP polling config only for gateways with Subdevices == true; removes AutoDiscovery from message. |
| src/Ecowitt.Controller/Service/Orchestrator/Dispatcher.ConsumerHttp.cs | Removes autodiscovery behaviors; changes handling when subdevice data arrives before gateway exists. |
| src/Ecowitt.Controller/Program.cs | Adds loading of appsettings.{Environment}.json. |
| src/Ecowitt.Controller/Model/Message/Config/HttpConfig.cs | Removes AutoDiscovery from the published config message. |
| src/Ecowitt.Controller/Model/Mapping/SensorBuilder.cs | Adjusts WFC02 RSSI sensor construction parameters. |
| src/Ecowitt.Controller/Model/Configuration/EcowittOptions.cs | Removes AutoDiscovery; adds GatewayOptions.Subdevices. |
| README.md | Updates configuration docs for subdevices and adds behavioral note on discovery timing. |
| CLAUDE.md | Updates options documentation to reflect removal of autodiscovery. |
Comments suppressed due to low confidence (3)
src/Ecowitt.Controller/Program.cs:43
- Environment-specific config file loading uses a manually-read ASPNETCORE_ENVIRONMENT value, which can be null/empty (common outside dev). That results in attempting to load
appsettings..jsonand skipping the conventionalappsettings.Production.json(or other env name). Preferbuilder.Environment.EnvironmentName(or aProductionfallback) and only add the env-specific file when the name is non-empty.
var configuration = new ConfigurationBuilder()
.SetBasePath(File.Exists("/config/appsettings.json") ? "/config" : builder.Environment.ContentRootPath)
.AddJsonFile("appsettings.json", false, true)
.AddJsonFile($"appsettings.{myEnv}.json", true, true)
.AddEnvironmentVariables()
src/Ecowitt.Controller/Service/Orchestrator/Dispatcher.ConsumerHttp.cs:66
- This log statement serializes
storedGateway, but in this branchstoredGatewayis always null (it’s the condition for entering the branch). This makes the log misleading; serialize/logupdatedGatewayinstead. Also the message template has an extra closing parenthesis ({Serialize})).
if (_deviceStore.UpsertGateway(updatedGateway))
{
_logger.LogDebug("gateway added: {Serialize})", JsonSerializer.Serialize(storedGateway));
await EmitHomeAssistantDiscovery(updatedGateway);
src/Ecowitt.Controller/Model/Mapping/SensorBuilder.cs:289
wfc02rssiis marked asSensorType.SignalStrength, but unlikegw_rssiit no longer provides any unit (previously it used a non-empty unit). This can make HA/UI display ambiguous; consider restoring the appropriate unit (e.g.,dBmif that’s the raw value, or a clearer scale indicator if it’s 0–5).
case "wfc02rssi":
return BuildIntSensor(propertyName, "WFC02 RSSI", propertyValue, type: SensorType.SignalStrength, isDiag: true);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
No description provided.