@@ -51,10 +51,12 @@ func main() {
51
51
var hassHost string
52
52
var deviceName string
53
53
var configFlag string
54
+ var quiet bool
54
55
flag .StringVar (& configFlag , "config" , "~/.config/hacompanion.toml" , "Path to the config file" )
55
56
flag .StringVar (& hassHost , "host" , "" , "Home Assistant host" )
56
57
flag .StringVar (& hassToken , "token" , "" , "Long-lived access token" )
57
58
flag .StringVar (& deviceName , "device-name" , "" , "Device name" )
59
+ flag .BoolVar (& quiet , "quiet" , false , "Disable verbose logging" )
58
60
flag .Parse ()
59
61
60
62
configFile , err := util .NewHomePath (configFlag )
@@ -136,12 +138,12 @@ func main() {
136
138
// Build the application kernel.
137
139
k := Kernel {
138
140
config : & config ,
139
- api : api .NewAPI (hassHost , hassToken , deviceName ),
141
+ api : api .NewAPI (hassHost , hassToken , deviceName , quiet ),
140
142
}
141
143
142
144
// Start the main process.
143
145
go func () {
144
- err = k .Run (context .Background ())
146
+ err = k .Run (context .Background (), quiet )
145
147
if err != nil {
146
148
log .Fatalf ("failed to start application: %s" , err )
147
149
}
@@ -166,7 +168,7 @@ func main() {
166
168
}
167
169
168
170
// Run runs the application.
169
- func (k * Kernel ) Run (appCtx context.Context ) error {
171
+ func (k * Kernel ) Run (appCtx context.Context , quiet bool ) error {
170
172
log .Printf ("Starting Desktop Companion version %s" , Version )
171
173
// Create a global application context that is later used for proper shutdowns.
172
174
ctx , cancel := context .WithCancel (appCtx )
@@ -190,7 +192,7 @@ func (k *Kernel) Run(appCtx context.Context) error {
190
192
}
191
193
192
194
// Parse out all sensors from the config file and register them in Home Assistant.
193
- sensors , err := k .buildSensors (k .config )
195
+ sensors , err := k .buildSensors (k .config , quiet )
194
196
if err != nil {
195
197
return fmt .Errorf ("failed to build sensors from config: %w" , err )
196
198
}
@@ -259,7 +261,7 @@ func (k *Kernel) Shutdown(ctx context.Context) error {
259
261
}
260
262
261
263
// buildSensors returns a slice of concrete Sensor types based on the configuration.
262
- func (k * Kernel ) buildSensors (config * Config ) ([]entity.Sensor , error ) {
264
+ func (k * Kernel ) buildSensors (config * Config , quiet bool ) ([]entity.Sensor , error ) {
263
265
var sensors []entity.Sensor
264
266
// Parse default sensor configuration.
265
267
for key , sensorConfig := range config .Sensors {
@@ -279,6 +281,7 @@ func (k *Kernel) buildSensors(config *Config) ([]entity.Sensor, error) {
279
281
DeviceClass : data .DeviceClass ,
280
282
Icon : data .Icon ,
281
283
Unit : data .Unit ,
284
+ QuietOutput : quiet ,
282
285
})
283
286
}
284
287
// Parse custom scripts.
0 commit comments