Closed Gucan closed 4 years ago
There is no such problem when not using container
bridge := accessory.New(accessory.Info{Name:"Gucan-Bridge",Manufacturer:"Gucan",SerialNumber:"GCBRIDGE",Model:"BR"},accessory.TypeBridge) container := accessory.NewContainer()
NAME:=[]string{"Switch1","Switch2","Switch3"}
for i:=0;i<3;i++ { N:=NAME[i] acc := accessory.NewSwitch(accessory.Info{Name:N,Manufacturer:"Gucan",SerialNumber:"GCSWITCH",Model:"A"}) acc.Switch.On.OnValueRemoteUpdate(func(on bool) { if on == true { print("ON") } else { print("OFF") } }) container.AddAccessory(acc.Accessory) }
Such code Switch1 will be lost
There is no need to create an accessory container yourself.
You can add your switches to the bridge like this
hc.NewIPTransport(cfg, bridge, switches)
In this way, you can't use the for loop. It's troublesome to add accessories
Why not? You can add the accessories to a slice in the for-loop.
Closed due to inactivity
Why can't the first device under the bridge device be displayed after updating to 1.2.1?