feat(bridge): MQTT bridge with Home Assistant auto-discovery
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package bridge
|
||||
|
||||
import "fmt"
|
||||
|
||||
func (b *Bridge) availTopic() string { return b.cfg.BaseTopic + "/availability" }
|
||||
func (b *Bridge) stateTopic(out int) string {
|
||||
return fmt.Sprintf("%s/output%d/state", b.cfg.BaseTopic, out)
|
||||
}
|
||||
func (b *Bridge) cmdTopic(out int) string {
|
||||
return fmt.Sprintf("%s/output%d/set", b.cfg.BaseTopic, out)
|
||||
}
|
||||
func (b *Bridge) discoveryTopic() string {
|
||||
return fmt.Sprintf("%s/device/ezcoo_matrix/config", b.cfg.DiscoveryPrefix)
|
||||
}
|
||||
func (b *Bridge) availPayload() string {
|
||||
if b.available.Load() {
|
||||
return "online"
|
||||
}
|
||||
return "offline"
|
||||
}
|
||||
Reference in New Issue
Block a user