Skip to content

Bugfix/2.0.1#11

Merged
mplogas merged 6 commits intomainfrom
bugfix/2.0.1
Mar 4, 2026
Merged

Bugfix/2.0.1#11
mplogas merged 6 commits intomainfrom
bugfix/2.0.1

Conversation

@mplogas
Copy link
Owner

@mplogas mplogas commented Mar 3, 2026

No description provided.

mplogas added 6 commits March 3, 2026 21:43
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).
Copilot AI review requested due to automatic review settings March 3, 2026 22:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AutoDiscovery from EcowittOptions/HttpConfig and delete autodiscovery-driven runtime behaviors.
  • Add ecowitt.gateways[].subdevices and 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..json and skipping the conventional appsettings.Production.json (or other env name). Prefer builder.Environment.EnvironmentName (or a Production fallback) 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 branch storedGateway is always null (it’s the condition for entering the branch). This makes the log misleading; serialize/log updatedGateway instead. 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

  • wfc02rssi is marked as SensorType.SignalStrength, but unlike gw_rssi it 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., dBm if 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.

@mplogas mplogas merged commit 4b5dbd0 into main Mar 4, 2026
5 checks passed
@mplogas mplogas deleted the bugfix/2.0.1 branch March 4, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants