Config UI: allow disabling devices (#29455)

Co-authored-by: Michael Geers <michael@geers.tv>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: andig <184815+andig@users.noreply.github.com>
This commit is contained in:
andig 2026-08-11 15:24:40 +02:00 • committed by GitHub
parent ced9ed514b
commit 4465100a65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 1149 additions and 189 deletions

View file

@ -24,6 +24,7 @@ type Config struct {
type Properties struct {
Type string
Disable bool `json:"deviceDisable,omitempty" mapstructure:"deviceDisable"`
Title string `json:"deviceTitle,omitempty" mapstructure:"deviceTitle"`
Icon string `json:"deviceIcon,omitempty" mapstructure:"deviceIcon"`
Product string `json:"deviceProduct,omitempty" mapstructure:"deviceProduct"`

View file

@ -79,7 +79,10 @@ func Tariffs() Handler[api.Tariff] {
func Instances[T any](devices []Device[T]) []T {
res := make([]T, 0, len(devices))
for _, dev := range devices {
res = append(res, dev.Instance())
// skip disabled devices without instance
if inst := dev.Instance(); any(inst) != nil {
res = append(res, inst)
}
}
return res
}