Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several EnvironmentMetrics enhancements #1037

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

jake-b
Copy link
Contributor

@jake-b jake-b commented Dec 30, 2024

What changed?

  1. Added additional metrics to available columns/chart series -- Lux, Radiation, Distance, etc.
  2. Better Y-axis scaling for the Environment Metrics chart (Temperature now has a 50-degree range, and Humidity 0-100%)
  3. Save the user's preferences for the columns/chart series per-node. Added two attributes to the NodeInfoEntity that hold an array of metrics (one for the chart, and one for the table)
  4. Better support for nil values in Environment Metrics - This is a pretty big refactor, so you might not want to do this, but took the approach mentioned in 🚀 [Feature Request]: Better handling of null values in Telemetry Data #1027 (manual code generation)
  5. A few new CompactWidgets for Distance/Radiation (Closes 🚀 [Feature Request]: Display water level (distance) sensors in node details - environment telemetry #991)

How was it implemented:

  1. Additional metrics are straightforward to add to the Environment Metrics Log view by adding implementations to the EnvironmentDefaultColumns and EnvironmentDefaultSeries files.
  2. The API for MetricsChartSeries was extended to provide a minumumYAxisSpan and initialYAxisRange. The forces the chart to a 0-100 scale when humidity is added, and keeps the temperature scale to be a 50-degree spread. If the data requires larger scales, these ranges will be expanded as necessary.
  3. MeshtasticDataModelV 48.xcdatamodel was created with changes to NodeInfoEntity:
  • telemetryColumns and telemetrySeries were added as [String] arrays. These will hold the list of chart series and the list of table columns that the user has active per-node.
  1. The ability to differentiate nil values from zeros in Metrics was implemented as follows:
  • Codegen for TelemetryEntity was disabled (Manual/none). Manual implementations were provided in TelemetryEntity+CoreDataClassand TelemetryEntity+CoreDataProperties
  • A ManagedAttribute property wrapper was created to handle the translation of NSNumbers to scalar optionals.
  • TelemetryEntity+CoreDataClass is the manual NSManagedObject class implementation that uses the before metioned @ManagedAttribute to implement scalar optional accessors for various metrics attributes.
  • TelemetryEntity+CoreDataProperties is the manual NSManagedObject extension that contains standard @NSManaged implementations
  • MeshPackets.swift was updated to load nil values into the database when the hasXXXX is false, and the actual value with it is true.
  • Various updates across the app to handle nil metrics.
  1. Radiation and Distance compact widgets were added to expose these values (when not nil) on the NodeInfo view.
  2. Minor fixes, typo corrections

Why did it change?

Continued evolution of the Environment Metrics Log view.

How is this tested?

Testing is ongoing. he change to optional scalars touches a bunch of places in the app. Wouldn't mind more eyes on this to see if it works as expected.

Screenshots/Videos (when applicable)

Checklist

  • My code adheres to the project's coding and style guidelines.
  • I have conducted a self-review of my code.
  • I have commented my code, particularly in complex areas.
  • I have made corresponding changes to the documentation.
  • I have tested the change to ensure that it works as intended.

@jake-b
Copy link
Contributor Author

jake-b commented Jan 1, 2025

Some screenshots from this pull request.
IMG_2748
IMG_2747

@jake-b jake-b force-pushed the metrics-db-update branch from 1049409 to cd10961 Compare January 1, 2025 03:22
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.

🚀 [Feature Request]: Display water level (distance) sensors in node details - environment telemetry
1 participant