You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the bridge, the device status in the Apple home app is no longer synchronized after the state changes several times, and it needs to be controlled before it will be synchronized。
func main() {
a := accessory.NewBridge(accessory.Info{
Name: "Bridge",
})
b := accessory.NewSwitch(accessory.Info{
Name: "Lamp",
})
d := accessory.NewSwitch(accessory.Info{
Name: "Lamp1",
})
s, err := hap.NewServer(hap.NewFsStore("./db"), a.A, b.A, d.A)
if err != nil {
log.Panic(err)
}
// Log to console when client (e.g. iOS app) changes the value of the on characteristic
b.Switch.On.OnValueRemoteUpdate(func(on bool) {
if on {
log.Println("Client changed switch to on")
} else {
log.Println("Client changed switch to off")
}
})
s.Pin = "34679023"
// Periodically toggle the switch's on characteristic
go func() {
for {
on := !b.Switch.On.Value()
if on {
log.Println("Switch is on")
} else {
log.Println("Switch is off")
}
b.Switch.On.SetValue(on)
time.Sleep(5 * time.Second)
}
}()
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
ctx, cancel := context.WithCancel(context.Background())
go func() {
<-c
signal.Stop(c)
cancel()
}()
s.ListenAndServe(ctx)
}
Remove the first bridge a, then the status in the Apple home app is synchronized no matter how the value is set
What causes this?
The text was updated successfully, but these errors were encountered:
Using the bridge, the device status in the Apple home app is no longer synchronized after the state changes several times, and it needs to be controlled before it will be synchronized。
Remove the first bridge a, then the status in the Apple home app is synchronized no matter how the value is set
What causes this?
The text was updated successfully, but these errors were encountered: