Home Automatisierung über
Webserver mit REST-Interface
Steuerung mittels generischer App
konfiguriert durch ladbare JSON-Definitionsdatei.
Siehe zugehöriger Arduino Yun
Webserver
JSON
-Code zu dargestellter Anwendung:
{
"style": "plastic",
"orientation": "portrait",
"pagebuttonwidth": "static",
"navigation": "fixed",
"description": "Board Status ",
"connections": [
{
"host": "192.168.178.10",
"protocol": "http",
"name": "WIFI",
"port": 80
},
{
"host": "gries.spdns.de",
"protocol": "http",
"name": "WAN",
"port": 80
}
],
"theme": "dark",
"version": 2,
"device": "iPhone 5",
"type": "NetIOConfiguration",
"pages": [
{
"sound": "active",
"name": "AF104 YUN",
"items": [
{
"text": "(c) 2014 M. Gries",
"top": 460,
"height": 20,
"width": 120,
"fontsize": 12,
"textcolor": "128,128,128",
"type": "label",
"textalign": "right",
"left": 190
},
{
"text": "UI v14.3.8",
"top": 460,
"height": 20,
"width": 100,
"fontsize": 12,
"textcolor": "128,128,128",
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "AF104 ",
"top": 460,
"height": 20,
"width": 100,
"reads": "/arduino/version/1",
"fontsize": 12,
"parseResponse": ".*$",
"textcolor": "128,128,128",
"type": "label",
"textalign": "center",
"formatResponse": "AF104 v{0}",
"left": 100
},
{
"comment": "Using REST API",
"offSend": "/arduino/digital/8/0",
"parseResponse": ".*$",
"top": 30,
"interval": 500,
"offText": "Aus",
"height": 30,
"width": 90,
"reads": "/arduino/digital/8",
"onValue": "lamp_on",
"offValue": "lamp_off",
"onText": "Ein",
"onSend": "/arduino/digital/8/1",
"type": "switch",
"formatResponse": "{0}",
"left": 220,
"knobColor": "55,55,55",
"requiresSendReponse": true,
"offColor": "45,45,45",
"onColor": "65,65,65"
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 20,
"interval": 2000,
"reads": "/arduino/digital/8",
"height": 50,
"width": 60,
"shape": "rounded",
"connection": "WAN",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 10
},
{
"text": "Flur 1.OG",
"top": 20,
"height": 50,
"width": 130,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 80
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 80,
"interval": 2000,
"reads": "/arduino/digital/9",
"height": 50,
"width": 60,
"shape": "rounded",
"connection": "WAN",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 10
},
{
"text": "Aussenlicht",
"top": 80,
"height": 50,
"width": 130,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 80
},
{
"comment": "Using REST API",
"offSend": "/arduino/digital/9/0",
"parseResponse": ".*$",
"top": 90,
"interval": 500,
"offText": "Aus",
"height": 30,
"width": 90,
"reads": "/arduino/digital/9",
"onValue": "lamp_on",
"offValue": "lamp_off",
"onText": "Ein",
"onSend": "/arduino/digital/9/1",
"type": "switch",
"formatResponse": "{0}",
"left": 220,
"offColor": "45,45,45",
"onColor": "65,65,65",
"knobColor": "55,55,55"
},
{
"sends": [
"/arduino/digital/8/0",
"/arduino/digital/9/0"
],
"top": 400,
"height": 50,
"width": 300,
"shape": "rounded",
"fontsize": 24,
"label": "alles AUS",
"type": "button",
"left": 10
},
{
"sends": [
"/arduino/aussenlicht/60"
],
"top": 140,
"connection": "WAN",
"height": 40,
"width": 60,
"shape": "rounded",
"label": "1 min",
"type": "button",
"left": 10
},
{
"sends": [
"/arduino/aussenlicht/180"
],
"top": 140,
"connection": "WAN",
"height": 40,
"width": 130,
"shape": "rounded",
"label": "3 min",
"type": "button",
"left": 80
},
{
"sends": [
"/arduino/aussenlicht/300"
],
"top": 140,
"connection": "WAN",
"height": 40,
"width": 90,
"shape": "rounded",
"label": "5 min",
"type": "button",
"left": 220
}
],
"sendOnAppear": "/arduino/mode/8/output",
"label": " AF104 ",
"width": 320,
"connection": "WAN",
"hapticFeedback": true,
"height": 480
},
{
"name": "Auduino Yun Intern",
"items": [
{
"icon": "lamp_off",
"top": 60,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"text": "RX",
"top": 60,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"icon": "lamp_off",
"top": 120,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 180,
"interval": 1000,
"reads": "/arduino/digital/13",
"height": 50,
"width": 100,
"shape": "rounded",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 20
},
{
"comment": "Number required (any)",
"icon": "lamp_off",
"parseResponse": ".*$",
"top": 300,
"interval": 2000,
"reads": "/arduino/alive/0",
"height": 50,
"width": 100,
"shape": "rounded",
"label": "On",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 20
},
{
"icon": "lamp_off",
"top": 360,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"icon": "lamp_off",
"top": 420,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"text": "TX",
"top": 120,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "L13",
"top": 180,
"height": 50,
"width": 60,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "Current Board Status",
"top": 10,
"height": 40,
"width": 280,
"fontsize": 28,
"type": "label",
"textalign": "center",
"left": 20
},
{
"text": "WAN",
"top": 240,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "ON",
"top": 300,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "WLAN",
"top": 360,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "USB",
"top": 420,
"height": 50,
"width": 60,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"comment": "Using REST API",
"sends": [
"/arduino/toggle/13"
],
"top": 180,
"height": 50,
"width": 80,
"shape": "rounded",
"icon": "next",
"type": "button",
"left": 220
},
{
"text": "(c) 2013 M. Gries",
"top": 460,
"height": 10,
"width": 90,
"fontsize": 11,
"textcolor": "128,128,128",
"type": "label",
"textalign": "right",
"left": 210
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 240,
"interval": 1000,
"reads": "/arduino/digital/9",
"height": 50,
"width": 100,
"shape": "rounded",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 20
}
],
"sendOnAppear": "/arduino/mode/9/output",
"height": 480,
"width": 320,
"connection": "WIFI",
"fitToScreen": true,
"sounds": "active",
"label": "Yun (WIFI)"
},
{
"name": "Auduino Yun Extern",
"items": [
{
"icon": "lamp_off",
"top": 60,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"text": "RX",
"top": 60,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"icon": "lamp_off",
"top": 120,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 180,
"reads": "/arduino/digital/13",
"height": 50,
"width": 100,
"shape": "rounded",
"connection": "WAN",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 20
},
{
"icon": "lamp_off",
"top": 240,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"comment": "Number required (any)",
"icon": "lamp_off",
"parseResponse": ".*$",
"top": 300,
"reads": "/arduino/alive/0",
"height": 50,
"width": 100,
"shape": "rounded",
"label": "On",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 20
},
{
"icon": "lamp_off",
"top": 360,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"icon": "lamp_off",
"top": 420,
"height": 50,
"width": 100,
"shape": "rounded",
"label": "newButton",
"type": "button",
"left": 20
},
{
"text": "TX",
"top": 120,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "L13",
"top": 180,
"height": 50,
"width": 60,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "Current Board Status",
"top": 10,
"height": 40,
"width": 280,
"fontsize": 28,
"type": "label",
"left": 20
},
{
"text": "WAN",
"top": 240,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "ON",
"top": 300,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "WLAN",
"top": 360,
"height": 50,
"width": 160,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"text": "USB",
"top": 420,
"height": 50,
"width": 60,
"fontsize": 24,
"type": "label",
"textalign": "left",
"left": 140
},
{
"comment": "Using REST API",
"sends": [
"/arduino/toggle/13"
],
"top": 180,
"height": 50,
"width": 80,
"shape": "rounded",
"icon": "next",
"type": "button",
"left": 220
},
{
"text": "(c) 2013 M. Gries",
"top": 460,
"height": 10,
"width": 90,
"fontsize": 11,
"textcolor": "128,128,128",
"type": "label",
"textalign": "right",
"left": 210
}
],
"sendOnAppear": "/arduino/mode/13/output",
"height": 480,
"width": 320,
"connection": "WAN",
"hapticFeedback": true,
"fitToScreen": true,
"sounds": "active",
"label": "Yun (WAN)"
},
{
"sound": "active",
"name": "mySerial Rx",
"items": [
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 20,
"connection": "WAN",
"height": 20,
"width": 280,
"reads": "/arduino/serial/2/baud",
"type": "label",
"formatResponse": "Serial 2 port set to {0} Bd",
"left": 20
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 60,
"interval": 2000,
"reads": "/arduino/serial/2/read",
"height": 290,
"width": 280,
"connection": "WAN",
"type": "label",
"textalign": "left",
"formatResponse": ">>> {0}",
"left": 20
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 360,
"reads": "/arduino/digital/10",
"height": 50,
"width": 60,
"shape": "rounded",
"connection": "WAN",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 30
},
{
"comment": "Using REST API",
"parseResponse": ".*$",
"top": 420,
"reads": "/arduino/digital/11",
"height": 50,
"width": 60,
"shape": "rounded",
"connection": "WAN",
"icon": "lamp_off",
"type": "button",
"formatResponse": "icon_{0}.png",
"left": 30
},
{
"text": "<10>",
"top": 360,
"height": 50,
"width": 130,
"fontsize": 24,
"textcolor": "128,128,128",
"type": "label",
"textalign": "center",
"left": 110
},
{
"text": "<11>",
"top": 420,
"height": 50,
"width": 130,
"fontsize": 24,
"textcolor": "128,128,128",
"type": "label",
"textalign": "center",
"left": 110
}
],
"label": "mySerial",
"width": 320,
"connection": "WIFI",
"height": 480
},
{
"sound": "active",
"name": "Error",
"items": [
{
"text": "command queue full (max 80 commands can to queued) \n",
"top": 50,
"height": 60,
"width": 300,
"fontsize": 20,
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "ERR1",
"top": 10,
"height": 40,
"width": 100,
"fontsize": 24,
"textcolor": "225,0,0",
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "ERR3",
"top": 230,
"height": 40,
"width": 100,
"fontsize": 24,
"textcolor": "255,0,0",
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "ERR4",
"top": 340,
"height": 40,
"width": 100,
"fontsize": 24,
"textcolor": "255,0,0",
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "ERR2",
"top": 120,
"height": 40,
"width": 100,
"fontsize": 24,
"textcolor": "255,0,0",
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": ".png file not found on App sharing folder (check iTunes)",
"top": 380,
"height": 60,
"width": 300,
"fontsize": 20,
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "cannot connect to host (check ip-address or connection)",
"top": 270,
"height": 60,
"width": 300,
"fontsize": 20,
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "parse- or formatResponse wrong (check regular expressions)",
"top": 160,
"height": 60,
"width": 300,
"fontsize": 20,
"type": "label",
"textalign": "left",
"left": 10
},
{
"text": "(c) 2014 M. Gries",
"top": 460,
"height": 10,
"width": 90,
"fontsize": 11,
"textcolor": "128,128,128",
"type": "label",
"textalign": "right",
"left": 220
},
{
"text": "UI v14.3.8",
"top": 460,
"height": 10,
"width": 80,
"fontsize": 11,
"textcolor": "128,128,128",
"type": "label",
"textalign": "left",
"left": 10
}
],
"label": "Help",
"width": 320,
"connection": "WAN",
"height": 480
}
],
"name": "AF104"
}