Skip to content

Commit 9fea2ba

Browse files
committed
feat: add motion and contact sensor accessories
1 parent 98079d5 commit 9fea2ba

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

accessory/contact_sensor.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package accessory
2+
3+
import "github.com/brutella/hap/service"
4+
5+
type ContactSensor struct {
6+
*A
7+
ContactSensor *service.ContactSensor
8+
}
9+
10+
// NewContactSensor implements a contact sensor.
11+
func NewContactSensor(info Info) *ContactSensor {
12+
a := ContactSensor{}
13+
a.A = New(info, TypeSensor)
14+
15+
a.ContactSensor = service.NewContactSensor()
16+
a.AddS(a.ContactSensor.S)
17+
18+
return &a
19+
}

accessory/motion_sensor.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package accessory
2+
3+
import "github.com/brutella/hap/service"
4+
5+
type MotionSensor struct {
6+
*A
7+
MotionSensor *service.MotionSensor
8+
}
9+
10+
// NewMotionSensor returns a motion sensor.
11+
func NewMotionSensor(info Info) *MotionSensor {
12+
a := MotionSensor{}
13+
a.A = New(info, TypeSensor)
14+
15+
a.MotionSensor = service.NewMotionSensor()
16+
a.AddS(a.MotionSensor.S)
17+
18+
return &a
19+
}

0 commit comments

Comments
 (0)