Turn off speakers and mixer when no one is present
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
656b040cdc
commit
644f038732
21
main.go
21
main.go
|
@ -1,10 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"automation/device"
|
||||||
"automation/integration/hue"
|
"automation/integration/hue"
|
||||||
|
"automation/integration/kasa"
|
||||||
"automation/integration/mqtt"
|
"automation/integration/mqtt"
|
||||||
"automation/integration/ntfy"
|
"automation/integration/ntfy"
|
||||||
"automation/device"
|
|
||||||
"automation/presence"
|
"automation/presence"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
@ -26,7 +27,8 @@ func main() {
|
||||||
h := hue.Connect()
|
h := hue.Connect()
|
||||||
|
|
||||||
// Kasa
|
// Kasa
|
||||||
// k := kasa.New("10.0.0.32")
|
mixer := kasa.New("10.0.0.49")
|
||||||
|
speakers := kasa.New("10.0.0.182")
|
||||||
|
|
||||||
// ntfy.sh
|
// ntfy.sh
|
||||||
n := ntfy.Connect()
|
n := ntfy.Connect()
|
||||||
|
@ -50,12 +52,23 @@ func main() {
|
||||||
select {
|
select {
|
||||||
case present := <-p.Presence:
|
case present := <-p.Presence:
|
||||||
fmt.Printf("Presence: %t\n", present)
|
fmt.Printf("Presence: %t\n", present)
|
||||||
h.SetFlag(41, present)
|
// Notify users of presence update
|
||||||
n.Presence(present)
|
n.Presence(present)
|
||||||
|
|
||||||
|
// Set presence on the hue bridge
|
||||||
|
h.SetFlag(41, present)
|
||||||
|
|
||||||
if !present {
|
if !present {
|
||||||
|
// Turn off all the devices that we manage ourselves
|
||||||
provider.TurnAllOff()
|
provider.TurnAllOff()
|
||||||
|
|
||||||
|
// Turn off kasa devices
|
||||||
|
mixer.SetState(false)
|
||||||
|
speakers.SetState(false)
|
||||||
|
|
||||||
|
// @TODO Turn off nest thermostat
|
||||||
} else {
|
} else {
|
||||||
// In the future this is were we can do things like turning on the lights in the living room
|
// @TODO Turn on the nest thermostat again
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-h.Events:
|
case <-h.Events:
|
||||||
|
|
Reference in New Issue
Block a user