{
  "settings": {
    "httpServer": {
      "enabled": true,
      "port": 80
    },
    "database": {
      "deviceAttributeLogging": [
        {
          "deviceId": "*",
          "attributeName": "*",
          "type": "*",
          "interval": "0",
          "expire": "7d"
        },
        {
          "deviceId": "*",
          "attributeName": "*",
          "type": "continuous",
          "interval": "5min",
          "expire": "7d"
        },
        {
          "deviceId": "*",
          "attributeName": "temperature",
          "type": "number",
          "expire": "1y"
        },
        {
          "deviceId": "*",
          "attributeName": "humidity",
          "type": "number",
          "expire": "1y"
        }
      ],
      "messageLogging": [
        {
          "level": "*",
          "tags": [],
          "expire": "7d"
        },
        {
          "level": "debug",
          "tags": [],
          "expire": "0"
        }
      ]
    },
    "authentication": {
      "secret": "xxxxxxxxxx"
    },
    "httpsServer": {},
    "cors": {},
    "gui": {}
  },
  "plugins": [
    {
      "plugin": "cron"
    },
    {
      "plugin": "mobile-frontend"
    },
    {
      "driverOptions": {
        "serialDevice": "/dev/ttyUSB0",
        "baudrate": 115200
      },
      "enableReceiving": true,
      "receiverPin": 0,
      "transmitterPin": 8,
      "plugin": "homeduino",
      "active": true,
      "enableDSTSensors": true
    },
    {
      "apiKey": "42807e554d2ced958db5ae8351b5d383",
      "debug": true,
      "plugin": "openweather",
      "active": true
    },
    {
      "debug": true,
      "client_secret": "https://calendar.google.com/calendar/ical/emilejukn%40gmail.com/private-4ae63cb55e50994323cad7aeb4d309fd/basic.ics",
      "plugin": "google-calendar",
      "active": true,
      "access_token": "",
      "refresh_token": ""
    },
    {
      "plugin": "charts",
      "active": true
    }
  ],
  "devices": [
    {
      "pin": 17,
      "id": "k3",
      "name": "K3",
      "class": "HomeduinoContactSensor"
    },
    {
      "pin": 7,
      "id": "j3",
      "name": "J3",
      "class": "HomeduinoSwitch"
    },
    {
      "pin": 8,
      "id": "j4",
      "name": "J4",
      "class": "HomeduinoSwitch"
    },
    {
      "pin": 15,
      "id": "k1",
      "name": "K1",
      "class": "HomeduinoContactSensor",
      "interval": 100
    },
    {
      "pin": 3,
      "id": "k2",
      "name": "K2",
      "class": "HomeduinoContactSensor",
      "interval": 100
    },
    {
      "pin": 14,
      "id": "k0",
      "name": "K0",
      "class": "HomeduinoContactSensor",
      "interval": 100
    },
    {
      "pin": 5,
      "id": "j1",
      "name": "J1",
      "class": "HomeduinoSwitch"
    },
    {
      "pin": 13,
      "defaultState": false,
      "id": "led",
      "name": "led",
      "class": "HomeduinoSwitch"
    },
    {
      "variables": [
        {
          "name": "points",
          "expression": "$points",
          "type": "number",
          "label": "Shots made"
        },
        {
          "name": "shots",
          "expression": "$shots",
          "type": "number",
          "label": "Shots taken"
        }
      ],
      "xAttributeOptions": [],
      "id": "pointsview",
      "name": "pointsView",
      "class": "VariablesDevice"
    },
    {
      "variables": [
        {
          "name": "score",
          "label": "SCORE",
          "expression": "$score",
          "type": "number",
          "min": 0,
          "max": 200,
          "unit": "",
          "showRange": false
        }
      ],
      "id": "score",
      "name": "score",
      "class": "GaugeDevice"
    },
    {
      "xAttributeOptions": [],
      "id": "timer",
      "name": "timer",
      "class": "Timer"
    },
    {
      "variables": [
        {
          "name": "Message",
          "expression": "$text",
          "label": "Message"
        }
      ],
      "xAttributeOptions": [],
      "id": "error",
      "name": "Message",
      "class": "VariablesDevice"
    },
    {
      "subtitle": "Scores",
      "height": 200,
      "timerange": "3d",
      "legend": true,
      "allowtrace": true,
      "variables": [
        {
          "name": "Score",
          "expression": "$score",
          "type": "number",
          "chart": "line",
          "dashstyle": "Solid"
        }
      ],
      "yaxis": [
        {
          "label": "",
          "unit": ""
        }
      ],
      "datebuttons": [
        {
          "label": "1min",
          "count": 1,
          "unit": "minute",
          "datagrouping": false
        },
        {
          "label": "1day",
          "count": 1,
          "unit": "day",
          "datagrouping": false
        },
        {
          "label": "ALL",
          "count": 0,
          "unit": "all",
          "datagrouping": false
        }
      ],
      "id": "scoregraph",
      "name": "scoreGraph",
      "class": "ChartDevice",
      "interval": 10
    },
    {
      "variable": "$time",
      "type": "number",
      "min": 5,
      "max": 600,
      "step": 5,
      "id": "settimer",
      "name": "setTimer",
      "class": "VariableInputDevice"
    }
  ],
  "rules": [
    {
      "id": "k1on",
      "name": "K1ON",
      "rule": "when $k1.contact increased and if \"$k1state\" = \"0\" then set $k1state to 1",
      "active": false,
      "logging": true
    },
    {
      "id": "k1off",
      "name": "K1OFF",
      "rule": "when $k1.contact increased and if \"$k1state\" = \"1\" then set $k1state to 0",
      "active": false,
      "logging": true
    },
    {
      "id": "k2on",
      "name": "K2ON",
      "rule": "when $k2.contact increased and if \"$k2state\" = \"0\" then set $k2state to 1",
      "active": false,
      "logging": true
    },
    {
      "id": "k2off",
      "name": "K2OFF",
      "rule": "when $k2.contact increased and if \"$k2state\" = \"1\" then set $k2state to 0",
      "active": false,
      "logging": true
    },
    {
      "id": "k3on",
      "name": "K3ON",
      "rule": "when $k3.contact increased and if \"$k3state\" = \"0\" then set $k3state to 1",
      "active": false,
      "logging": true
    },
    {
      "id": "k3off",
      "name": "K3OFF",
      "rule": "when $k3.contact increased and if \"$k3state\" = \"1\" then set $k3state to 0",
      "active": false,
      "logging": true
    },
    {
      "id": "k0on",
      "name": "K0ON",
      "rule": "when $k0.contact increased and if \"$k0state\" = \"0\" then set $k0state to 1",
      "active": true,
      "logging": true
    },
    {
      "id": "k0off",
      "name": "K0OFF",
      "rule": "when $k0.contact increased and if \"$k0state\" = \"1\" then set $k0state to 0",
      "active": true,
      "logging": true
    },
    {
      "id": "points",
      "name": "points",
      "rule": "when k1 is opened then set $points to $points + 1",
      "active": true,
      "logging": true
    },
    {
      "id": "shots",
      "name": "shots",
      "rule": "when k2 is opened then set $shots to $shots + 1 and set $text to \"...\"",
      "active": true,
      "logging": true
    },
    {
      "id": "startgamebutton",
      "name": "startGameButton",
      "rule": "when \"$k0state\" = \"1\" then turn j1 on and set $score to 0 and set $text to \"...\" and set $points to 0 after 5 seconds and set $shots to 0 after 5 seconds",
      "active": true,
      "logging": true
    },
    {
      "id": "startgame",
      "name": "startGame",
      "rule": "when j1 is turned on then start the timer after 5 seconds and turn on led after 5 seconds and set $text to \"GAME STARTS IN 5 SECONDS!\" and set $text to \"3..\" after 2 seconds and set $text to \"2..\" after 3 seconds and set $text to \"1..\" after 4 seconds and set $text to \"START!!!\" after 5 seconds",
      "active": true,
      "logging": true
    },
    {
      "id": "endgame",
      "name": "endGame",
      "rule": "when $timer.time = $time then turn j1 off and turn led off and set $k0state to 0 and set $score to (($points / $shots * 100)+$points) and stop timer and reset timer",
      "active": true,
      "logging": true
    },
    {
      "id": "pointsrestriction",
      "name": "pointsRestriction",
      "rule": "when $points is greater than $shots then set $points to $points - 1 and set $text to \"Points can't be greater than Shots!\"",
      "active": true,
      "logging": true
    },
    {
      "id": "scorerestriction",
      "name": "scoreRestriction",
      "rule": "when $shots is less than $min and $score is greater than 0 then set $score to 0 and set $text to \"Score wasn't calculated. Minimum Shots required is $min!\"",
      "active": true,
      "logging": true
    },
    {
      "id": "setmin",
      "name": "setMin",
      "rule": "when $time changes then set $min to $time*0.2",
      "active": true,
      "logging": true
    }
  ],
  "pages": [
    {
      "id": "favourite",
      "name": "Favourites",
      "devices": []
    },
    {
      "id": "projektas",
      "name": "PROJEKTAS",
      "devices": [
        {
          "deviceId": "k1"
        },
        {
          "deviceId": "led"
        },
        {
          "deviceId": "k2"
        },
        {
          "deviceId": "settimer"
        },
        {
          "deviceId": "k0"
        },
        {
          "deviceId": "timer"
        },
        {
          "deviceId": "j1"
        },
        {
          "deviceId": "pointsview"
        },
        {
          "deviceId": "score"
        },
        {
          "deviceId": "error"
        },
        {
          "deviceId": "scoregraph"
        }
      ]
    }
  ],
  "groups": [],
  "users": [
    {
      "username": "admin",
      "password": "xxxxxxxxxx",
      "role": "admin"
    }
  ],
  "roles": [
    {
      "name": "admin",
      "permissions": {
        "pages": "write",
        "rules": "write",
        "variables": "write",
        "messages": "write",
        "events": "write",
        "devices": "write",
        "groups": "write",
        "plugins": "write",
        "updates": "write",
        "database": "write",
        "config": "write",
        "controlDevices": true,
        "restart": true
      }
    }
  ],
  "variables": [
    {
      "name": "k1state",
      "value": 1
    },
    {
      "name": "k2state",
      "value": 0
    },
    {
      "name": "k3state",
      "value": 0
    },
    {
      "name": "k0state",
      "value": 0
    },
    {
      "name": "points",
      "value": 2
    },
    {
      "name": "shots",
      "value": 2
    },
    {
      "name": "score",
      "value": 0
    },
    {
      "name": "text",
      "value": "Score wasn't calculated. Minimum Shots required is 6!"
    },
    {
      "name": "time",
      "value": 30
    },
    {
      "name": "min",
      "value": 6
    }
  ]
}