Skip to content

Commit

Permalink
fix(agent): 🐛 detect more types of "laptop" chassis
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Jan 11, 2025
1 parent 9b316c7 commit f6f32fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions internal/agent/workers_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package agent
import (
"context"
"log/slog"
"slices"

"github.com/joshuar/go-hass-agent/internal/device"
"github.com/joshuar/go-hass-agent/internal/hass/event"
Expand Down Expand Up @@ -139,8 +140,9 @@ func setupOSWorkers(ctx context.Context) ([]Worker[sensor.Entity], []Worker[even

// Get the type of device we are running on.
chassis, _ := device.Chassis() //nolint:errcheck // error is same as any value other than wanted value.
// If running on a laptop, add laptop specific sensor workers.
if chassis == "laptop" {
laptops := []string{"Portable", "Laptop", "Notebook"}
// If running on a laptop chassis, add laptop specific sensor workers.
if slices.Contains(laptops, chassis) {
for _, workerInit := range sensorLaptopWorkersInitFuncs {
worker, err := workerInit(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func Chassis() (string, error) {
return "", fmt.Errorf("could not determine chassis type: %w", err)
}

return chassisInfo.Type, nil
return chassisInfo.TypeDescription, nil
}

// getHostname retrieves the hostname of the device running the agent, or
Expand Down

0 comments on commit f6f32fd

Please sign in to comment.