Exemple #1
0
// NewOutlet returns an outlet which implements model.Outlet.
func NewOutlet(info model.Info) *outlet {
	accessory := New(info)
	s := service.NewOutlet(info.Name, false, true) // off

	accessory.AddService(s.Service)

	sw := outlet{accessory, s}

	return &sw
}
Exemple #2
0
// NewOutlet returns an outlet which implements model.Outlet.
func NewOutlet(info model.Info) *outlet {
	accessory := New(info)
	s := service.NewOutlet(info.Name, false, true) // off

	accessory.AddService(s.Service)

	sw := outlet{accessory, s, nil, nil}

	s.On.OnConnChange(func(conn net.Conn, c *characteristic.Characteristic, new, old interface{}) {
		if sw.onChanged != nil {
			sw.onChanged(s.On.On())
		}
	})

	s.InUse.OnConnChange(func(conn net.Conn, c *characteristic.Characteristic, new, old interface{}) {
		if sw.inUseChanged != nil {
			sw.inUseChanged(s.InUse.InUse())
		}
	})

	return &sw
}