In this tutorial we are going to create a Apple Shortcut to turn on and off a relay connected to a ESP8266, ESP32 or Raspberry Pi using the Sinric Pro API.
Please complete Tutorial - Turn on and off a Relay in order to learn how to connect your ESP or Pi to Sinric Pro.
Login to Sinric Portal, select Credentials and click on New API Key click save and Copy the newly created API Key
You can use the curl
to send a test request to this API endpoint.
curl --location --request POST 'https://apple.sinric.pro/v1/shortcuts/actions' \
--header 'Content-Type: application/json' \
--data-raw '{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setPowerState", "value": { "state" : "On"} }'
https://apple.sinric.pro/v1/shortcuts/actions
POST
.Key | Input Type | Text |
---|---|---|
api_key | Text | Your API key from above. |
device_id | Text | Your device id from the Sinric Pro Portal. |
action | Text | Action to perform. set to setPowerState . Check below for more examples. |
value | Dictionary | Enter state as key and On or Off value. |
Tap on play button below to test the request!
Now you can control your ESP8266, ESP32 or Raspberry Pi via Apple Shortcut from home screen.
Power On or Off:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setPowerState", "value": { "state" : "On"} }
Garage door open/close:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setMode", "value": { "mode" : "Open"} }
Blinds open/close:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setRangeValue", "value": { "rangeValue" : 100} }
Change power level:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setPowerLevel", "value": { "powerLevel": 50 } }
Change brightness:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setBrightness", "value": { "brightness": 50 } }
Trigger doorbell:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "DoorbellPress", "value": { "state": "pressed" } }
Set target temperature:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "targetTemperature", "value": { "temperature": 18 } }
Change color:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setColor", "value": { "color": { "b": 0, "g": 0, "r": 0 } } }
Change color temperature:
{ "api_key": "YOUR_API_KEY_FROM_ABOVE", "device_id": "YOUR_DEVICE_ID", "action": "setColorTemperature", "value": {"colorTemperature":2700} }
More examples : https://github.com/sinricpro/sample_messages