Skip to content

Commit 9e1251f

Browse files
Added the Motion API (#33)
1 parent 86ee654 commit 9e1251f

File tree

5 files changed

+211
-0
lines changed

5 files changed

+211
-0
lines changed

src/main.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ tags:
3232
description: API to manage light services. These are offered by devices with lighting capabilities.
3333
- name: LightLevel
3434
description: API to manage light level services. These are offered by devices with light level sensing capabilities.
35+
- name: Motion
36+
description: API to manage motion services. These are offered by devices with motion sensing capabilities.
3537
- name: GroupedLight
3638
description: API to manage grouped light services. These are offered by rooms, zones, and homes.
3739
- name: Bridge
@@ -73,6 +75,11 @@ paths:
7375
$ref: './light_level/light_level.yaml'
7476
/clip/v2/resource/light_level/{lightId}:
7577
$ref: './light_level/light_level_{lightLevelId}.yaml'
78+
# Motion
79+
/clip/v2/resource/motion:
80+
$ref: './motion/motion.yaml'
81+
/clip/v2/resource/motion/{motionId}:
82+
$ref: './motion/motion_{motionId}.yaml'
7683
# Grouped Level
7784
/clip/v2/resource/grouped_light:
7885
$ref: './grouped_light/grouped_light.yaml'

src/motion/motion.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
get:
2+
operationId: getMotionSensors
3+
summary: List motion sensors.
4+
description: List all available motion sensors.
5+
tags:
6+
- Motion
7+
security:
8+
- HueApplicationKey: [ ]
9+
responses:
10+
200:
11+
description: Motion Success Response
12+
content:
13+
application/json:
14+
schema:
15+
allOf:
16+
- $ref: '../common/ApiResponse.yaml'
17+
- type: object
18+
properties:
19+
data:
20+
type: array
21+
items:
22+
$ref: './schemas/MotionGet.yaml'
23+
401:
24+
$ref: '../common/error.yaml#/components/responses/Unauthorized'
25+
403:
26+
$ref: '../common/error.yaml#/components/responses/Forbidden'
27+
404:
28+
$ref: '../common/error.yaml#/components/responses/NotFound'
29+
405:
30+
$ref: '../common/error.yaml#/components/responses/MethodNotAllowed'
31+
406:
32+
$ref: '../common/error.yaml#/components/responses/NotAcceptable'
33+
409:
34+
$ref: '../common/error.yaml#/components/responses/Conflict'
35+
429:
36+
$ref: '../common/error.yaml#/components/responses/TooManyRequests'
37+
500:
38+
$ref: '../common/error.yaml#/components/responses/InternalServerError'
39+
503:
40+
$ref: '../common/error.yaml#/components/responses/ServiceUnavailable'
41+
507:
42+
$ref: '../common/error.yaml#/components/responses/InsufficientStorage'

src/motion/motion_{motionId}.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
get:
2+
operationId: getMotionSensor
3+
summary: Get motion sensor.
4+
description: Get details of a single motion sensor from its given `{motionId}`.
5+
tags:
6+
- Motion
7+
security:
8+
- HueApplicationKey: [ ]
9+
parameters:
10+
- name: motionId
11+
in: path
12+
schema:
13+
type: string
14+
required: true
15+
description: ID of the motion sensor
16+
responses:
17+
200:
18+
description: Motion Success Response
19+
content:
20+
application/json:
21+
schema:
22+
allOf:
23+
- $ref: '../common/ApiResponse.yaml'
24+
- type: object
25+
properties:
26+
data:
27+
type: array
28+
items:
29+
$ref: './schemas/MotionGet.yaml'
30+
401:
31+
$ref: '../common/error.yaml#/components/responses/Unauthorized'
32+
403:
33+
$ref: '../common/error.yaml#/components/responses/Forbidden'
34+
404:
35+
$ref: '../common/error.yaml#/components/responses/NotFound'
36+
405:
37+
$ref: '../common/error.yaml#/components/responses/MethodNotAllowed'
38+
406:
39+
$ref: '../common/error.yaml#/components/responses/NotAcceptable'
40+
409:
41+
$ref: '../common/error.yaml#/components/responses/Conflict'
42+
429:
43+
$ref: '../common/error.yaml#/components/responses/TooManyRequests'
44+
500:
45+
$ref: '../common/error.yaml#/components/responses/InternalServerError'
46+
503:
47+
$ref: '../common/error.yaml#/components/responses/ServiceUnavailable'
48+
507:
49+
$ref: '../common/error.yaml#/components/responses/InsufficientStorage'
50+
put:
51+
operationId: updateMotionSensor
52+
summary: Update Motion Sensor
53+
description: Update a single motion sensor from its given `{motionId}`.
54+
tags:
55+
- Motion
56+
security:
57+
- HueApplicationKey: [ ]
58+
parameters:
59+
- name: motionId
60+
in: path
61+
schema:
62+
type: string
63+
required: true
64+
description: Id of the motion sensor
65+
requestBody:
66+
content:
67+
application/json:
68+
examples:
69+
TurnOn:
70+
summary: Turn the motion sensor on.
71+
value:
72+
enabled: true
73+
schema:
74+
$ref: './schemas/MotionPut.yaml'
75+
responses:
76+
200:
77+
description: Success
78+
content:
79+
application/json:
80+
schema:
81+
allOf:
82+
- $ref: '../common/ApiResponse.yaml'
83+
- type: object
84+
properties:
85+
data:
86+
type: array
87+
items:
88+
$ref: '../common/ResourceIdentifier.yaml'
89+
401:
90+
$ref: '../common/error.yaml#/components/responses/Unauthorized'
91+
403:
92+
$ref: '../common/error.yaml#/components/responses/Forbidden'
93+
404:
94+
$ref: '../common/error.yaml#/components/responses/NotFound'
95+
405:
96+
$ref: '../common/error.yaml#/components/responses/MethodNotAllowed'
97+
406:
98+
$ref: '../common/error.yaml#/components/responses/NotAcceptable'
99+
409:
100+
$ref: '../common/error.yaml#/components/responses/Conflict'
101+
429:
102+
$ref: '../common/error.yaml#/components/responses/TooManyRequests'
103+
500:
104+
$ref: '../common/error.yaml#/components/responses/InternalServerError'
105+
503:
106+
$ref: '../common/error.yaml#/components/responses/ServiceUnavailable'
107+
507:
108+
$ref: '../common/error.yaml#/components/responses/InsufficientStorage'

src/motion/schemas/MotionGet.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
type: object
2+
allOf:
3+
- $ref: '../../common/ResourceOwned.yaml'
4+
- type: object
5+
properties:
6+
enabled:
7+
type: boolean
8+
description: ture when the sensor is activated, false when deactivated
9+
motion:
10+
type: object
11+
properties:
12+
motion:
13+
type: boolean
14+
description: Deprecated. Moved to motion_report/motion.
15+
motion_valid:
16+
type: boolean
17+
description: Deprecated. Motion is valid when motion_report property is present, invalid when absent.
18+
motion_report:
19+
type: object
20+
properties:
21+
changed:
22+
type: string
23+
description: last time the value of this property is changed
24+
motion:
25+
type: boolean
26+
description: true if motion is detected
27+
sensitivity:
28+
type: object
29+
properties:
30+
status:
31+
type: string
32+
enum:
33+
- set
34+
- changing
35+
sensitivity:
36+
type: integer
37+
description: Sensitivity of the sensor. Value in the range 0 to sensitivity_max
38+
sensitivity_max:
39+
type: integer
40+
description: Maximum value of the sensitivity configuration attribute.

src/motion/schemas/MotionPut.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
type: object
2+
properties:
3+
type:
4+
type: string
5+
description: Type of the supported resources (always `motion` here)
6+
enabled:
7+
type: boolean
8+
description: true when the sensor is activated, false when deactivated
9+
sensitivity:
10+
type: object
11+
properties:
12+
sensitivity:
13+
type: integer
14+
description: Sensitivity of the sensor. Value in the range 0 to sensitivity_max.

0 commit comments

Comments
 (0)