Skip to content

Commit

Permalink
add more validation
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilGruber committed Nov 26, 2024
1 parent d977fe6 commit 521d619
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion devices/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func NewRule(config core.RuleConfig, devices map[string]DeviceInterface) *Rule {
log.Printf("Creating rule %v\n", config)
for _, triggerConfig := range config.Triggers {
log.Println("Creating trigger")
if _, ok := devices[triggerConfig.DeviceName]; !ok {
log.Printf("Device %s not found\n", triggerConfig.DeviceName)
continue
}
trigger := Trigger{
Device: devices[triggerConfig.DeviceName],
Key: triggerConfig.Key,
Expand All @@ -46,7 +50,10 @@ func NewRule(config core.RuleConfig, devices map[string]DeviceInterface) *Rule {
}

for _, receiverConfig := range config.Receivers {
log.Println("Creating receiver")
if _, ok := devices[receiverConfig.DeviceName]; !ok {
log.Printf("Device %s not found\n", receiverConfig.DeviceName)
continue
}
receiver := Receiver{
Device: devices[receiverConfig.DeviceName],
Key: receiverConfig.Key,
Expand Down

0 comments on commit 521d619

Please sign in to comment.