diff --git a/cmd/generate/main.go b/cmd/generate/main.go index 1a75723..3cb27cb 100644 --- a/cmd/generate/main.go +++ b/cmd/generate/main.go @@ -14,9 +14,11 @@ import ( ) type Config struct { - URL string `yaml:"url"` - HAAuthToken string `yaml:"ha_auth_token"` - HomeZoneEntityId string `yaml:"home_zone_entity_id,omitempty"` // Now optional + URL string `yaml:"url"` + HAAuthToken string `yaml:"ha_auth_token"` + HomeZoneEntityId string `yaml:"home_zone_entity_id,omitempty"` // Now optional + IncludeDomains []string `yaml:"include_domains,omitempty"` // Optional list of domains to include + ExcludeDomains []string `yaml:"exclude_domains,omitempty"` // Optional list of domains to exclude } type Domain struct { @@ -129,6 +131,35 @@ func generate(config Config) error { } domain := parts[0] + + // Filter domains based on include/exclude lists + if len(config.IncludeDomains) > 0 { + // If include list is specified, only process listed domains + found := false + for _, includeDomain := range config.IncludeDomains { + if domain == includeDomain { + found = true + break + } + } + if !found { + continue + } + } else { + // If only exclude list is specified, skip excluded domains + excluded := false + for _, excludeDomain := range config.ExcludeDomains { + if domain == excludeDomain { + println("skipping excluded domain:", domain) + excluded = true + break + } + } + if excluded { + continue + } + } + if _, exists := domainMap[domain]; !exists { domainMap[domain] = &Domain{ Name: toCamelCase(domain), diff --git a/example/gen.yaml b/example/gen.yaml index a15dad2..8c02d9a 100644 --- a/example/gen.yaml +++ b/example/gen.yaml @@ -1,3 +1,13 @@ url: "http://192.168.4.67:8123" # Replace with your Home Assistant URL ha_auth_token: "" # Your auth token or set HA_AUTH_TOKEN env var home_zone_entity_id: "zone.home" # Optional: defaults to zone.home + +# Optional: List of domains to include when generating constants +# If provided, only these domains will be processed +# Example: ["light", "switch", "climate"] +include_domains: [] + +# Optional: List of domains to exclude when generating constants +# Only used if include_domains is empty +# Example: ["device_tracker", "person"] +exclude_domains: []