From ce969ed7be2fcac5d7f8129822498813bd9dd4a4 Mon Sep 17 00:00:00 2001 From: HAS1WA3 Date: Wed, 31 Jul 2024 11:59:05 +0200 Subject: [PATCH] add automation trigger --- openapi/MainResources-local-openapi-v3.yml | 108 +++++++++++- ...rt Home Controller.postman_collection.json | 162 ++++++++++++++++-- 2 files changed, 255 insertions(+), 15 deletions(-) diff --git a/openapi/MainResources-local-openapi-v3.yml b/openapi/MainResources-local-openapi-v3.yml index 818c083..108d820 100644 --- a/openapi/MainResources-local-openapi-v3.yml +++ b/openapi/MainResources-local-openapi-v3.yml @@ -3,7 +3,7 @@ openapi: 3.0.0 info: title: Bosch Smart Home Local API for Main Resources description: |- - This description focuses on the JSON-based, REST-like API for the Main Resources (devices, rooms, scenarios, messages). To get a detailed description of the related services and states of a device, select one in the 'Select a definition' drop-down box (top right corner). + This description focuses on the JSON-based, REST-like API for the Main Resources (devices, rooms, scenarios, automations, messages). To get a detailed description of the related services and states of a device, select one in the 'Select a definition' drop-down box (top right corner). By using this documentation, the developer accepts and agrees to be bound by our [Terms and Conditions](https://github.com/BoschSmartHome/bosch-shc-api-docs#terms-and-conditions). @@ -21,6 +21,7 @@ tags: - name: Devices - name: Rooms - name: Scenarios + - name: Automations - name: Messages - name: Doors/Windows - name: UserDefinedStates @@ -190,6 +191,75 @@ paths: '405': description: The method was not allowed. ### + ### Automations + ### + '/automation/rules': + get: + summary: List all available Automations. + description: Returns all Automations. + tags: + - Automations + parameters: + - $ref: '#/components/parameters/apiVersionHeaderParam' + responses: + '200': + description: Accepted request. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Automation' + '404': + description: The entity could not be found. + '/automation/rules/{automationId}': + get: + summary: Retrieve a specific Automation. + description: |- + Returns the Automation identified by the `automationId` path parameter. The + response includes details about the Automation. + tags: + - Automations + parameters: + - $ref: '#/components/parameters/apiVersionHeaderParam' + - $ref: '#/components/parameters/automationIdPathParam' + responses: + '200': + description: Accepted request. + content: + application/json: + schema: + $ref: '#/components/schemas/Automation' + '404': + description: |- + The entity could not be found. One of the defined path parameters was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/AdvancedError' + + '/automation/rules/{automationId}/trigger': + put: + summary: Triggers the Automation. + description: |- + Triggers the Automation identified by the 'automationId' path parameter, ignoring any conditions being configured. + tags: + - Automations + parameters: + - $ref: '#/components/parameters/apiVersionHeaderParam' + - $ref: '#/components/parameters/automationIdPathParam' + responses: + '202': + description: Accepted request. + '404': + description: The entity could not be found. + content: + application/json: + schema: + $ref: '#/components/schemas/AdvancedError' + '405': + description: The method was not allowed. + ### ### Messages ### '/messages': @@ -423,6 +493,42 @@ components: description: An array of actions defined in this scenario. items: type: object + Automation: + type: object + properties: + '@type': + type: string + description: The type of the Object. + example: automation + id: + type: string + description: "A single fully qualified identifier of the Automation." + name: + type: string + description: The name of the Automation. + enabled: + type: boolean + description: Indicates if the Automation is enabled. + example: true + automationTriggers: + type: array + description: An array of triggers defined in this Automation. + items: + type: object + automationConditions: + type: array + description: An array of conditions defined in this Automation. + items: + type: object + automationActions: + type: array + description: An array of actions defined in this Automation. + items: + type: object + conditionLogicalOp: + type: string + description: The logical operator of the conditions. + enum: [AND,OR] Message: type: object properties: diff --git a/postman/Bosch Smart Home Controller.postman_collection.json b/postman/Bosch Smart Home Controller.postman_collection.json index ea547ed..41ee4a4 100644 --- a/postman/Bosch Smart Home Controller.postman_collection.json +++ b/postman/Bosch Smart Home Controller.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "e9ef2cd5-d80f-45f5-a2bd-47cb327fff19", + "_postman_id": "f537c0b8-ad5d-463b-b399-37a5d1b1f4ee", "name": "Bosch Smart Home Controller", "description": "This API enables you to locally access the state of and control your Bosch Smart Home system. Configuring the system is not supported.", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" @@ -503,7 +503,7 @@ "response": [] }, { - "name": "Messages as array", + "name": "Automations as array", "event": [ { "listen": "test", @@ -513,9 +513,39 @@ ], "type": "text/javascript" } - }, + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "api-version", + "value": "{{api_version}}", + "type": "text" + } + ], + "url": { + "raw": "{{shc_api}}/automation/rules", + "host": [ + "{{shc_api}}" + ], + "path": [ + "automation", + "rules" + ] + } + }, + "response": [] + }, + { + "name": "Automation by Id", + "event": [ { - "listen": "prerequest", + "listen": "test", "script": { "exec": [ "" @@ -538,19 +568,21 @@ } ], "url": { - "raw": "{{shc_api}}/messages", + "raw": "{{shc_api}}/automation/rules/{{automation_id}}", "host": [ "{{shc_api}}" ], "path": [ - "messages" + "automation", + "rules", + "{{automation_id}}" ] } }, "response": [] }, { - "name": "Open doors/windows", + "name": "Automation trigger", "event": [ { "listen": "test", @@ -572,26 +604,33 @@ } ], "request": { - "method": "GET", + "method": "PUT", "header": [ { "key": "Content-Type", - "value": "application/json" + "value": "application/json", + "type": "text" }, { "key": "api-version", - "type": "text", - "value": "{{api_version}}" + "value": "{{api_version}}", + "type": "text" } ], + "body": { + "mode": "raw", + "raw": "" + }, "url": { - "raw": "{{shc_api}}/doors-windows/openwindows", + "raw": "{{shc_api}}/automation/rules/{{automation_id}}/trigger", "host": [ "{{shc_api}}" ], "path": [ - "doors-windows", - "openwindows" + "automation", + "rules", + "{{automation_id}}", + "trigger" ] } }, @@ -678,6 +717,101 @@ } }, "response": [] + }, + { + "name": "Messages as array", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "api-version", + "value": "{{api_version}}", + "type": "text" + } + ], + "url": { + "raw": "{{shc_api}}/messages", + "host": [ + "{{shc_api}}" + ], + "path": [ + "messages" + ] + } + }, + "response": [] + }, + { + "name": "Open doors/windows", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "api-version", + "type": "text", + "value": "{{api_version}}" + } + ], + "url": { + "raw": "{{shc_api}}/doors-windows/openwindows", + "host": [ + "{{shc_api}}" + ], + "path": [ + "doors-windows", + "openwindows" + ] + } + }, + "response": [] } ] },