Add Tags and Attributes to GTU7 Descriptor#33
Conversation
- Added Tags: "gps", "navigation", "location" - Added Attributes: serial port and baud rate information - Added Access: ReadOnly to match other sensor patterns - Store GTU7Config in struct to access serial info in Descriptor - Added comprehensive tests for Descriptor functionality Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
Co-authored-by: rustyeddy <2903425+rustyeddy@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR enhances the GTU7 GPS sensor's Descriptor method to include metadata fields (tags and attributes) similar to other sensors like VH400, improving discoverability and documentation.
Changes:
- Added
cfgfield to GTU7 struct to store configuration - Enhanced Descriptor() method to include tags ("gps", "navigation", "location") and attributes (serial port and baud rate when configured)
- Added comprehensive test coverage for both serial config and no-config scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sensors/gtu7.go | Added cfg field to struct and enhanced Descriptor() to populate tags and attributes from serial configuration |
| sensors/gtu7_test.go | Added TestGTU7_Descriptor with test cases for both with and without serial configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| attrs := make(map[string]string) | ||
| if g.cfg.Serial.Port != "" { | ||
| attrs["port"] = g.cfg.Serial.Port | ||
| } | ||
| if g.cfg.Serial.Baud > 0 { | ||
| attrs["baud"] = strconv.Itoa(g.cfg.Serial.Baud) | ||
| } |
There was a problem hiding this comment.
The g.cfg field will always be zero-valued because it's not initialized in NewGTU7 (line 97-101). This means attrs["port"] and attrs["baud"] will never be populated since g.cfg.Serial.Port will be empty and g.cfg.Serial.Baud will be 0. The NewGTU7 function needs to be updated to include cfg: cfg in the return statement.
The GTU7 sensor's Descriptor was missing metadata fields present in other sensors like VH400, reducing discoverability and documentation quality.
Changes:
"gps","navigation","location"portandbaudrate when configuredReadOnlyGTU7Configin struct to populate Attributes from serial configurationExample:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.