Skip to content

Commit

Permalink
Added the /resource/temperature API (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibauult authored Oct 17, 2023
1 parent 4f163c7 commit 0cb886f
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ tags:
description: API to manage rooms. Rooms group devices and each device can only be part of one room.
- name: Zone
description: API to manage zones. Zones group services and each service can be part of multiple zones.
- name: Temperature
description: API to manage temperature services. These are offered by devices with temperature sensing capabilities.
paths:
# Authentication
/api:
Expand Down Expand Up @@ -77,6 +79,11 @@ paths:
$ref: './zone/zone.yaml'
/clip/v2/resource/zone/{zoneId}:
$ref: './zone/zone_{zoneId}.yaml'
# Temperature
/clip/v2/resource/temperature:
$ref: './temperature/temperature.yaml'
/clip/v2/resource/temperature/{temperatureId}:
$ref: './temperature/temperature_{temperatureId}.yaml'
components:
securitySchemes:
HueApplicationKey:
Expand Down
30 changes: 30 additions & 0 deletions src/temperature/schemas/TemperatureGet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
type: object
allOf:
- $ref: '../../common/ResourceOwned.yaml'
- type: object
properties:
enabled:
type: boolean
description: |
`true` when sensor is activated, `false` when deactivated
temperature:
type: object
properties:
temperature:
type: number
description: Deprecated. Moved to Temperature_report/temperature
example: 23
temperature_valid:
type: boolean
description: Deprecated. Indication whether the value presented in temperature is valid
temperature_report:
type: object
properties:
changed:
type: string
format: date-time
description: last time the value of this property is changed.
temperature:
type: number
description: Temperature in 1.00 degrees Celsius
example: 23
10 changes: 10 additions & 0 deletions src/temperature/schemas/TemperaturePut.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: object
properties:
type:
type: string
description: Type of the supported resources (always `temperature` here)
enum:
- temperature
enabled:
type: boolean
description: true when sensor is activated, false when deactivated
42 changes: 42 additions & 0 deletions src/temperature/temperature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
get:
operationId: getTemperatures
summary: List temperatures
description: List all temperatures
tags:
- Temperature
security:
- HueApplicationKey: [ ]
responses:
200:
description: Temperature Success Response
content:
application/json:
schema:
allOf:
- $ref: '../common/ApiResponse.yaml'
- type: object
properties:
data:
type: array
items:
$ref: './schemas/TemperatureGet.yaml'
401:
$ref: '../common/error.yaml#/components/responses/Unauthorized'
403:
$ref: '../common/error.yaml#/components/responses/Forbidden'
404:
$ref: '../common/error.yaml#/components/responses/NotFound'
405:
$ref: '../common/error.yaml#/components/responses/MethodNotAllowed'
406:
$ref: '../common/error.yaml#/components/responses/NotAcceptable'
409:
$ref: '../common/error.yaml#/components/responses/Conflict'
429:
$ref: '../common/error.yaml#/components/responses/TooManyRequests'
500:
$ref: '../common/error.yaml#/components/responses/InternalServerError'
503:
$ref: '../common/error.yaml#/components/responses/ServiceUnavailable'
507:
$ref: '../common/error.yaml#/components/responses/InsufficientStorage'
112 changes: 112 additions & 0 deletions src/temperature/temperature_{temperatureId}.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
get:
operationId: getTemperature
summary: Get temperature sensor information
description: Get details of a single temperature sensor from its given `{temperatureId}`.
tags:
- Temperature
security:
- HueApplicationKey: [ ]
parameters:
- name: temperatureId
in: path
schema:
type: string
required: true
description: ID of the temperature sensor
responses:
200:
description: Temperature Success Response
content:
application/json:
schema:
allOf:
- $ref: '../common/ApiResponse.yaml'
- type: object
properties:
data:
type: array
items:
$ref: './schemas/TemperatureGet.yaml'
401:
$ref: '../common/error.yaml#/components/responses/Unauthorized'
403:
$ref: '../common/error.yaml#/components/responses/Forbidden'
404:
$ref: '../common/error.yaml#/components/responses/NotFound'
405:
$ref: '../common/error.yaml#/components/responses/MethodNotAllowed'
406:
$ref: '../common/error.yaml#/components/responses/NotAcceptable'
409:
$ref: '../common/error.yaml#/components/responses/Conflict'
429:
$ref: '../common/error.yaml#/components/responses/TooManyRequests'
500:
$ref: '../common/error.yaml#/components/responses/InternalServerError'
503:
$ref: '../common/error.yaml#/components/responses/ServiceUnavailable'
507:
$ref: '../common/error.yaml#/components/responses/InsufficientStorage'
put:
operationId: updateTemperature
summary: Update temperature sensor
description: Update a temperature sensor from its given `{temperatureId}`.
tags:
- Temperature
security:
- HueApplicationKey: [ ]
parameters:
- name: temperatureId
in: path
schema:
type: string
required: true
description: ID of the temperature sensor
requestBody:
content:
application/json:
examples:
Enable:
summary: Enable temperature sensor
value:
enabled: true
Disable:
summary: Disable temperature sensor
value:
enabled: false
schema:
$ref: './schemas/TemperaturePut.yaml'
responses:
200:
description: Success
content:
application/json:
schema:
allOf:
- $ref: '../common/ApiResponse.yaml'
- type: object
properties:
data:
type: array
items:
$ref: '../common/ResourceIdentifier.yaml'
401:
$ref: '../common/error.yaml#/components/responses/Unauthorized'
403:
$ref: '../common/error.yaml#/components/responses/Forbidden'
404:
$ref: '../common/error.yaml#/components/responses/NotFound'
405:
$ref: '../common/error.yaml#/components/responses/MethodNotAllowed'
406:
$ref: '../common/error.yaml#/components/responses/NotAcceptable'
409:
$ref: '../common/error.yaml#/components/responses/Conflict'
429:
$ref: '../common/error.yaml#/components/responses/TooManyRequests'
500:
$ref: '../common/error.yaml#/components/responses/InternalServerError'
503:
$ref: '../common/error.yaml#/components/responses/ServiceUnavailable'
507:
$ref: '../common/error.yaml#/components/responses/InsufficientStorage'

0 comments on commit 0cb886f

Please sign in to comment.