This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues or pull requests.
automation/automation/zeus.go
Dreaded_X d42afecd67
All checks were successful
continuous-integration/drone/push Build is passing
Added option to activate computer through mqtt
2022-12-03 02:15:06 +01:00

24 lines
508 B
Go

package automation
import (
"automation/device"
"automation/home"
"fmt"
"log"
paho "github.com/eclipse/paho.mqtt.golang"
)
func zeusAutomation(client paho.Client, home *home.Home) {
const name = "living_room/zeus"
on(client, fmt.Sprintf("automation/appliance/%s", name), func(message struct{Activate bool `json:"activate"`}) {
computer, err := device.GetDevice[device.Activate](&home.Devices, name)
if err != nil {
log.Println(err)
return
}
computer.Activate(message.Activate)
})
}