Caretaker Quickstart Guide

This tutorial describes how you start the Caretaker system in simulation mode

Prerequisites

How this is done depends on your actual system. Please refer to the installation documents that you can find on the internet.

Caretaker Server

This involves cloning the Git repository, creating a SQLite database and starting the server:

git clone https://github.com/grappendorf/caretaker-server
cd caretaker-server
gem install bundler
bundle install
rake db:demo
rackup -p 3000

If everything went well, the server starts up and is now listening on port 3000 for incoming request to its REST API:

# I, [2016-03-11T12:06:50.618296 #7203]  INFO -- : Service manager starting
# I, [2016-03-11T12:06:50.635174 #7203]  INFO -- : Device Manager starting
# I, [2016-03-11T12:06:50.679509 #7203]  INFO -- : WLAN master simualtor starting
# I, [2016-03-11T12:06:50.680515 #7203]  INFO -- : Device Script Manager starting
# I, [2016-03-11T12:06:50.682886 #7203]  INFO -- : Device Action Manager starting
# I, [2016-03-11T12:06:50.684518 #7203]  INFO -- : Philips Hue Manager starting
# I, [2016-03-11T12:06:50.684847 #7203]  INFO -- : Websockets Manager starting
# Thin web server (v1.6.4 codename Gob Bluth)
# Maximum connections set to 1024
# Listening on localhost:3000, CTRL+C to stop

You can verify that everything is working correctly by accessing the root URL of the server:

http http://localhost:3000
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 15
Content-Type: application/json
Server: thin
Vary: Origin

{
  "status": "ok"
}

Caretaker WebApp

The web application is contained in a separate project, which we also need to clone and start in another shell:

git clone https://github.com/grappendorf/caretaker-webapp
cd caretaker-webapp
npm install
./bin/bower install
./bin/grunt

If everything went well, a web server is started on port 8000 and is now serving the files of the Caretaker web aplication:

# ...
# Running "connect:server" (connect) task
# Started connect web server on http://localhost:8000
# Running "watch" task
# Waiting...

Access the web application

Point your web browser to http://localhost:8000 and login with user admin@example.com password admin. Open the Devices menu in the navigation bar and click on Devices. Currently there are no devices connected and so we need to start some devices in the next section.

Caretaker empty device list

Start the device simulator UI

This is a small JavaScript Electron application which draws visual representations of the simulated remote devices and lets you control them by pressing the virtual buttons and knobs. Clone the project and start the application. With no devices currently started, the window will be empty.

git clone https://github.com/grappendorf/caretaker-devices
cd workspace-caretaker/caretaker-devices/caretaker-device-simulator/web/
npm install
npm start

Start some simulated devices

Enter the directory which contains the simulation code for the switch device (caretaker-devices/caretaker-device-switch/sim) and compile the code:

make

# g++ -I ../../caretaker-device-simulator/cpp -o sim -DARDUINO=100 -std=c++0x \
# ../../caretaker-device-simulator/cpp/*.cpp ../src/switch.cpp switch-sim.cpp \
# -lhiredis -l:libevent-2.0.so.5.1.9

Now we can start the device simulator:

./sim -p 2001 switch1

# Simulator starting...
# Connecting to Redis...
# Updating device state with "HMSET caretaker.devices.switch relais 0"
# Entering event loop
# Redis pub/sub connection established
# Redis command connection established
# Updating device state with "HMSET caretaker.devices.switch button 0 relais 0"
# Sending registration request to server
# Device state has changed
# Getting device state with "HGETALL caretaker.devices.switch"
# New device state: id=switch type=Switch name=switch relais=0 button=0
# Received registration response from server

The switch should now appear in the device list of the Catetaker web app as well as in the device simulator app. You should now start some more switches (switch1 to switch4) and also a remote control (name it remote). Be sure to start each device on its own port (-p option). You can start as many other devices as you like.

Caretaker device list Caretaker device simulator

Now click on Scripts in the navigation bar of the Caretaker web app and enable all device scripts by clicking on the checkboxes in the Enabled column. You should now be able to toggle the LEDs in the switch devices by either clicking on the switch buttons or by clicking on the buttons of the remote control.

Create a dashboard

Log off (Account, Sign out) and log in again as user user@example.com with password user. Create a new dashboard by clicking on Create dashboard and add a widget for each of the devices (Add widget, select the device, then click on Save). You can now control the switch devices by clicking on the buttons in the widgets. The widgets are also updated, when you click the buttons of the simulated devices.

Caretaker dashboard 3