Documentazione API V1

Documentazione API pubblica Versione 1.

Prima di cominciare

Effettuare le richieste qui descritte espone il sistema a cui vi state collegando, quindi richiede che eventuali credenziali e token siano conservati in modo sicuro.

Ottenere il Token della Sessione

POST https://api.ohmautomation.io/control/v1/auth

Questo endpoint permette di ottenere il token della sessione, necessario per effettuare tutte le altre richieste.

Headers

Request Body

{
  "token": "r:qwertyuiop1234567890"
}

Eliminare la Sessione

POST https://api.ohmautomation.io/control/v1/logout

Questo endpoint permette di eliminare la sessione, così da rendere il token inutilizzabile.

Headers

{
  "token": <deleted_token>
}

JSON delle Scorciatoie

GET https://api.ohmautomation.io/control/v1/shortcuts?token=abc

Questo endpoint permette di ottenere un JSON con la configurazione delle scorciatoie dell'utente a cui corrisponde il token.

Query Parameters

{
    "shortcuts": [
        {
            "askConfirm": false,
            "category": "shortcut",
            "color": "#117ED9",
            "desc": "Spegni tutte le luci",
            "icon": "house_2",
            "id": "abc123",
            "itemACL": [
                {
                    "id": "qwerty",
                    "read": true,
                    "write": true
                }
            ],
            "name": "Demo",
            "objectId": "system",
            "operations": [
                {
                    "function": {
                        "args": {},
                        "name": "turn_off_all_lights"
                    },
                    "objectId": "system",
                    "timer": {
                        "days": 0,
                        "hours": 0,
                        "min": 0,
                        "sec": 0
                    }
                }
            ],
            "parameters": []
        },
        {
            "askConfirm": false,
            "category": "shortcut",
            "color": "#FFB300",
            "desc": "Attiva/Disattiva TV",
            "icon": "tv",
            "id": "abc1234",
            "itemACL": [
                {
                    "id": "qwerty",
                    "read": true,
                    "write": true
                }
            ],
            "name": "TV",
            "objectId": "ac278aa6-fdd8-4899-960e-55ad702452ce",
            "operations": [
                {
                    "function": {
                        "args": {},
                        "name": "toggle"
                    },
                    "objectId": "ac278aa6-fdd8-4899-960e-55ad702452ce",
                    "timer": {
                        "days": 0,
                        "hours": 0,
                        "min": 0,
                        "sec": 0
                    }
                }
            ],
            "parameters": []
        },
        {
            "askConfirm": false,
            "category": "shortcut",
            "color": "#880E4F",
            "desc": "Apri/Chiudi cancello",
            "icon": "gate",
            "id": "abc12345
            "itemACL": [
                {
                    "id": "qwerty",
                    "read": true,
                    "write": true
                }
            ],
            "name": "Cancello",
            "objectId": "",
            "operations": [
                {
                    "function": {
                        "args": {},
                        "name": "on"
                    },
                    "objectId": "a41f6a53-3b69-44e4-abf2-fed4bed8785c",
                    "timer": {
                        "days": 0,
                        "hours": 0,
                        "min": 0,
                        "sec": 0
                    }
                }
            ],
            "parameters": []
        }
    ]
}

È possibile evitare l'uso del token nell'url e allegarlo agli Headers.

JSON Scorciatoie con Headers

GET https://api.ohmautomation.io/control/v1/shortcuts

Come il precedente metodo, anche in questo caso otteniamo un JSON con la configurazione delle scorciatoie, ma il token lo indichiamo negli Headers. Consigliamo questa soluzione in quanto non espone il token nell'url.

Headers

{
    "shortcuts": [
        {
            "askConfirm": false,
            "category": "shortcut",
            "color": "#117ED9",
            "desc": "Spegni tutte le luci",
            "icon": "house_2",
            "id": "abc123",
            "itemACL": [
                {
                    "id": "qwerty",
                    "read": true,
                    "write": true
                }
            ],
            "name": "Demo",
            "objectId": "system",
            "operations": [
                {
                    "function": {
                        "args": {},
                        "name": "turn_off_all_lights"
                    },
                    "objectId": "system",
                    "timer": {
                        "days": 0,
                        "hours": 0,
                        "min": 0,
                        "sec": 0
                    }
                }
            ],
            "parameters": []
        },
        {
            "askConfirm": false,
            "category": "shortcut",
            "color": "#FFB300",
            "desc": "Attiva/Disattiva TV",
            "icon": "tv",
            "id": "abc1234",
            "itemACL": [
                {
                    "id": "qwerty",
                    "read": true,
                    "write": true
                }
            ],
            "name": "TV",
            "objectId": "ac278aa6-fdd8-4899-960e-55ad702452ce",
            "operations": [
                {
                    "function": {
                        "args": {},
                        "name": "toggle"
                    },
                    "objectId": "ac278aa6-fdd8-4899-960e-55ad702452ce",
                    "timer": {
                        "days": 0,
                        "hours": 0,
                        "min": 0,
                        "sec": 0
                    }
                }
            ],
            "parameters": []
        },
        {
            "askConfirm": false,
            "category": "shortcut",
            "color": "#880E4F",
            "desc": "Apri/Chiudi cancello",
            "icon": "gate",
            "id": "abc12345
            "itemACL": [
                {
                    "id": "qwerty",
                    "read": true,
                    "write": true
                }
            ],
            "name": "Cancello",
            "objectId": "",
            "operations": [
                {
                    "function": {
                        "args": {},
                        "name": "on"
                    },
                    "objectId": "a41f6a53-3b69-44e4-abf2-fed4bed8785c",
                    "timer": {
                        "days": 0,
                        "hours": 0,
                        "min": 0,
                        "sec": 0
                    }
                }
            ],
            "parameters": []
        }
    ]
}

Esecuzione della Scorciatoia

POST https://api.ohmautomation.io/control/v1/shortcut

Headers

Request Body

Visualizza Scorciatoia via Web

GET https://api.ohmautomation.io/control/v1/shortcut?token=abc&link=0&lang=it

Questo endpoint permette la visualizzazione e l'esecuzione di una scorciatoia.

Query Parameters

HTML