HomeAssistant: add auto-discovery (#25141)
This commit is contained in:
parent
c33a6c20e0
commit
ef096a236f
31 changed files with 764 additions and 119 deletions
33
server/network/registry.go
Normal file
33
server/network/registry.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/evcc-io/evcc/api/globalconfig"
|
||||
)
|
||||
|
||||
var (
|
||||
mu sync.Mutex
|
||||
registry []func()
|
||||
)
|
||||
|
||||
var config globalconfig.Network
|
||||
|
||||
func Config() globalconfig.Network {
|
||||
return config
|
||||
}
|
||||
|
||||
func Register(fun func()) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
registry = append(registry, fun)
|
||||
}
|
||||
|
||||
func Start(conf globalconfig.Network) {
|
||||
config = conf
|
||||
|
||||
for _, fun := range registry {
|
||||
go fun()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue