Skip to content

April Demo

Guillaume C. Marty edited this page Apr 18, 2016 · 52 revisions

This is a script detailing step-by-step how to run and prepare the G1 demos.

As for all demos, assume that the person who was supposed to run the demo is stuck in the airplane and someone else has to do it instead, someone who has never used Foxbox and who is operating with 12 hours of jetlag, stress and an unreliable network. Oh, and it's raining, too.

1. Setting up devices

1.1 Motion Sensor or Door/Window Detector (both demos)

Note: the Fibaro Motion Sensor does not need to be paired in secure mode but the Door/Window Detector needs it.

  • How long does it take? between 15 and 30 minutes.
  • Who can help me if it doesn't work? @JulienW

1.2 IP Camera (demo 1)

Pairing

No specific pairing is required.

Fabrice's camera (the one used during the workweek) already has the security disabled for snapshots.

How do I check that the camera has been detected?

You should see an INFO line in the foxbox console output which looks something like this:

[2016-04-13 13:07:51.915] (10670) INFO  Adding IpCamera ae67e622-7a66-465e-bab0-28107b26d795 Manufacturer: D-Link Model: DCS-5010L Name: DCS-5010L(192.168.0.134:80)

You could also browse to http://localhost:3000/api/v1/services and look for a service with an adapter that starts with ip-camera.

If you run foxbox with --disable-tls, you can also run svc.py from tools/scripts:

> ./svc.py --service=ip-camera
Adapter: [email protected] ID: service:[email protected]
  setters:
    setter:[email protected]
    setter:[email protected]
    setter:[email protected]
  getters:
    getter:[email protected]
    getter:image_newest.ae67e622-7a66-465e-bab0-28107b26d795@link.mozilla.org
    getter:[email protected]
    getter:[email protected]

How long does it take?

On my home network, I have 4 cameras (all connected via Wifi) and they all show up within a second or so of starting foxbox. The cameras use UPnP and the D-Link cameras broadcasts itself once every 3 minutes. So if the UPnP broadcast when foxbox starts is missed, then it should see one from the camera sometime in the next 3-minutes.

Configuration

Once you know the IP address of the camera (which you can determine by using the log, or by using an Android network scanner like Fing, then you'll want to configure the camera.

Browse to the camera's IP address. You'll need to login to the camera. The factory shipped username is 'admin' and the password is blank.

Update the firmware

All of the cameras that I purchased came with really old firmware on them. At least with the Android "mydlink lite" app, I found that they worked much better after upgrading the firmware.

  • Download the latest firmware for your camera. For example, for the DCS-5010L, this page: http://support.dlink.ca/ProductInfo.aspx?m=DCS-5010L (click on Downloads) had 1.13.05 available when this wiki was written. For different models, enter the model number in the search at the top.
  • Brose to the camera
  • Click on the Maintenance tab (across the top) and then click on "Firmware Upgrade"
  • Follow the directions.

Change the password (if desired - not required if you disable authentication in the next step).

  • Browse to the camera
  • Click on the Maintenance Tab
  • Click on Admin on the left hand side
  • Enter the old and new passwords and click Apply

The current camera adapter has getters/setters so that you can tell the camera adapter what the username and password is, but I don't think that there is any UI for this.

You can query what foxbox thinks the camera passwords are using:

./svc.py --get getter:password

and you can set the password for a specific camera using:

./svc.py --set setter:[email protected]=PASSWORD

replace setter:[email protected] with the setter for your camera (each camera will have a unique setter), and replace PASSWORD with the password you want to use.

Change the permissions for screen shots

  • Browse to the camera
  • Click on the Maintenance Tab
  • Click on Admin on the left hand side
  • In the middle of the page, in the "Server Settings" section, change the "Snapshot URL Authentication" from Enable to Disable.
  • Click Apply

Who can help me if it doesn't work?

Ask @dhylands on #foxlink IRC channel

1.3 Motion Sensor / Door Lock (Demo 2)

Note: the Fibaro Motion Sensor does not need to be paired in secure mode but the Door/Window Detector needs it. The Lock very likely needs to be paired in secure mode.

Otherwise follow the guide above.

1.4 Philips Hue lights (Demo 2)

Setting up the Philips Hue system requires between five and ten minutes. You should have:

  • The Philips Hue bridge (small white box with a huge round button on top)
  • Power supply for the Hue bridge
  • An Ethernet cable and a port to hook it up to
  • One or more Philips Hue light bulbs
  • A matching number of free E27 light sockets or appropriate adapters

Setting up the Hue lights

The Philips Hue bridge comes with a set of light bulbs which are pre-paired with their bridge. This requires no additional setup. Light bulbs must be screwed into regular E27 light bulb sockets and supplied with power.

Setting up the Hue bridge

The Hue bridge requires power via its power supply and an Ethernet connection to the local network. The Hue bridge and the Foxbox daemon must be connected to the same network. Internet connection for the Hue bridge is desirable (potentially faster discovery), but not mandatory for operation. Once the Hue bridge is connected and fully booted up (takes one to two minutes), two blue LEDs (if Internet connection unavailable) or three blue lights (Internet connection available) light up on its surface.

Pairing with the Foxbox Daemon

Once the Hue bridge is connected and fully booted, and the Hue lights are in place, (re-)start the Foxbox daemon and observe the log output. You should see two lines:

[2016-04-13 19:52:37.751] INFO  Starting Hue Hub Service for 001788fffe22f7f1
[2016-04-13 19:52:37.799] WARN  Philips Hue detected but not paired. Please, push pairing button on Philips Hue Bridge ID 001788fffe22f7f1 to start using it.

At this point, you must press the pairing button on the Hue bridge. It's the giant round button covering most of the bridge's top surface. You have two minutes to complete the pairing process before a timeout occurs. In that case, you need to restart the Foxbox daemon and try again. The timeout is announced on the console as:

[2016-04-13 19:54:37.851] WARN  Pairing timeout with Philips Hue Bridge ID 001788fffe22f7f1

Pairing is permanent until the config file in ~/.local/share/foxbox/foxbox.conf is deleted. The daemon will not need to be paired again after restart. Successful pairing is announced on the console as follows:

[2016-04-13 19:55:32.122] INFO  Connected to Philips Hue bridge model BSB002, ID 001788FFFE22F7F1, software version 01031131, IP address 172.16.0.6
[2016-04-13 19:55:32.265] INFO  New Philips Hue Extended Color Light service for light 1 on bridge 001788fffe22f7f1
[2016-04-13 19:55:32.273] INFO  New Philips Hue Extended Color Light service for light 2 on bridge 001788fffe22f7f1
[2016-04-13 19:55:32.289] INFO  New Philips Hue Extended Color Light service for light 3 on bridge 001788fffe22f7f1

Testing the setup

To test the setup, the simplest is to use the app.

Alternatively, you can temporarily run the Foxbox daemon without authentication and TLS support. First, change Cargo.toml from

[features]
default = ["authentication"]

to

[features]
default = []

and rebuild the Foxbox daemon. Then run it with cargo run -- --disable-tls and execute the script docs/scripts/huedemo.sh. It will blink all the connected Hue lights a couple of times and then quit with all the lights turned off – which is probably easier on your eyes than the "full bright white" setting a freshly powered-on Hue light greets you with. Don't forget to re-enable authentication, rebuild, and restart the daemon one last time without the --disable-tls option.

Getting help

If things go wrong, contact Christiane Ruetten, cr on the #foxlink IRC channel. Her mobile number is in the Mozilla phone book.

TBD Who is present in the office that day and can help with setting up Hue bridges?

2. Plan A: Full demo

If the front-end team has not had time to provide everything needed for the demos, skip to the next section for a reduced demo.

2.1 Setting up the Foxbox

  • Clone the code
git clone [email protected]:fxbox/foxbox.git
cd foxbox

FIXME(@Yoric): We'll branch out sooner or later, so this instruction will be updated.

# From the foxbox/ directory
$ rm ~/.local/share/foxbox/
$ \rm -Rf certs/
  • Build
cargo build
  • Run with TLS and WebPush
cargo run

This now defaults to use our dev server at knilxof.org and runs with TLS support.

  • Run with tunneling support (needed for the demo)
cargo run -- -t knilxof.org:443 -s foxbox

Issues

FIXME(@Yoric): Add link to issues

Cleaning up

If you want to start over.

# From the foxbox/ directory
$ rm ~/.local/share/foxbox/
$ \rm -Rf certs/

This cleans the profile folder (containing the users, config and recipes databases).

Getting help

@ferjm, @sgiles, @michielbdejong on #foxlink IRC channel

2.2 Setting up authentication

  • Go to https://fxbox.github.io/app
  • You should see this screen.
  • Click on the 'Log in' button. This will redirect you to the box.
  • If you have not previously created an admin account, you will be asked to enter a password twice. Note: account creation only works when you run the app inside the same network the box is running.
  • If you already have setup the box's admin account, you will be asked to enter the admin password.
  • After entering the password(s) you should see this screen.
  • The app stores the session and you shouldn't worry about manually authenticating any request. All happens under the hood.

Cleaning stuff

If you find issues creating the admin user or login in the box, you can try starting from scratch by:

  • Removing the users DB located at ~/.local/share/foxbox/users.sqlite
  • If you are using the app, cleaning the session by running foxbox.clear() from the web console

2.3 Checking that notifications work

FIXME(@ferjm, @gmarty, @francisco) How do we do that?

2.4 Actually running the demo

Demo 1

When John is away from home, Foxbox alerts him of an intruder barging in through the patio door (Notification says: “Your bedroom patio door has just been opened. Here is a photo of what I see".)

Warning The motion sensor is very sensitive. The best way to make sure that it doesn't cause a false positive is to put it in a box.

Warning The motion sensor is also very slow. It can take 30 seconds for it to update its state.

FIXME(@gmarty, @francisco) What should @fabrice do during the demo?

Create the recipe with the app.

FIXME(@gmarty, @francisco)

An intruder in the house.

  • If you are using a motion sensor, take it of the box, move your hand in front of it.
  • If you are using a window open/window closed sensor, open the window.

Witnessing that the recipe has worked.

FIXME(@gmarty, @francisco)

Demo 2

When Alex leaves home in a hurry, Foxbox takes care of locking front door and turning off kitchen lights and notifies Alex of the same. Notification says: "Hello Alex, I've turned your kitchen lights off & locked the door for you. Have a wonderful day"!

FIXME(@gmarty, @francisco) What should @fabrice do during the demo?

Turn on the lights with the app.

FIXME(@gmarty, @francisco)

Unlock the door with the app.

FIXME(@gmarty, @francisco)

Create the recipe with the app.

These recipes can't be created in the app at this point. Open the console of the dev tools and type:

foxbox.recipes.createDemoRecipes();

Leave the house

  • If you're using a door opened/door closed sensor, close the door.
  • If you're using a motion sensor, put it in a box.

Confirm that it works

  • The lights turn off.
  • The door locks.
  • The app receives a notification FIXME(@gmarty, @francisco).

3. Plan B: reduced demo

If the front-end team hasn't had sufficient time to finish, this demo goes through the command-line.

3.1 Setting up the Foxbox

  • Clone the code
git clone [email protected]:fxbox/foxbox.git
cd foxbox

FIXME(@Yoric): We'll branch out sooner or later, so this instruction will be updated.

# From the foxbox/ directory
$ rm ~/.local/share/foxbox/
$ \rm -Rf certs/
  • Deactivate authentication:

    in Cargo.toml, replace line default = ["authentication"] with default = []

  • Build

cargo build
  • Run without TLS and WebPush
cargo run -- --disable-tls

Known issues running the box

  • You will find issues running the box if you have not clean your certs folder after LetsEncrypt support landed.
  • TLS is currently broken, although there are workarounds. Check this issue to follow its progress.
  • Try removing the certs folder and running cargo run again if you see this panic on Mac:
thread 'Registrar' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', ../src/libcore/result.rs:746

Cleaning up

If you want to start over.

# From the foxbox/ directory
$ rm ~/.local/share/foxbox/
$ \rm -Rf certs/

This cleans the profile folder (containing the users, config and recipes databases).

Getting help

@ferjm, @sgiles, @michielbdejong on #foxlink IRC channel

3.2 Running the demos

3.3 Demo 1

When John is away from home, Foxbox alerts him of an intruder barging in through the patio door (Notification says: “Your bedroom patio door has just been opened. Here is a photo of what I see".)

Warning The motion sensor is very sensitive. The best way to make sure that it doesn't cause a false positive is to put it in a box.

Warning The motion sensor is also very slow. It can take 30 seconds for it to update its state.

Load the recipe through the REST API

$ curl -X PUT http://localhost:3000/api/v1/channels/set -d  '{"select":{"kind":"AddThinkerbellRule"},"value":{"ThinkerbellRule":{"name":"When there is movement in my bedroom, inform the user.","source":"{\"name\":\"When there is movement in my bedroom, inform the user.\",\"rules\":[{\"conditions\":[{\"source\":[{\"kind\":\"OpenClosed\",\"tags\":[]}],\"kind\":\"OpenClosed\",\"range\":{\"Eq\":{\"OpenClosed\":\"Open\"}}}],\"execute\":[{\"destination\":[{\"tags\":[]}],\"kind\":\"TakeSnapshot\",\"value\":{\"Unit\":null}},{\"destination\":[{\"kind\":\"Log\"}],\"kind\":\"Log\",\"value\":{\"String\":\"Your bedroom patio door has just been opened. Here is a photo of what I see.\"}}]}]}"}}}'

In case of success, this should display something along the lines of

{"thinkerbell-rule-add": null}

Rules are persisted across restarts. If this works once, this should continue working until you delete the rule/the db.

In case of problem

  • curl: (52) Empty reply from server You have a network problem. Do you have a public IP?

An intruder in the house.

  • If you are using a motion sensor, take it of the box, move your hand in front of it.
  • If you are using a window open/window closed sensor, open the window.

Confirm that it works

  • The Foxbox logs will display [[email protected]] Your bedroom patio door has just been opened. Here is a photo of what I see. (user None)
  • Download the image
$ curl -X PUT http://localhost:3000/api/v1/channels/get -d  '{"kind":{"adapter":"IPCam Adapter","kind":"latest image","type":"Binary","vendor":"[email protected]"}}' > /tmp/intruder.jpg
  • Open the image /tmp/intruder.jpg with your favorite viewer.

3.3 Demo 2

When Alex leaves home in a hurry, Foxbox takes care of locking front door and turning off kitchen lights and notifies Alex of the same. Notification says: "Hello Alex, I've turned your kitchen lights off & locked the door for you. Have a wonderful day"!

Turn on the lights

curl -X PUT http://localhost:3000/api/v1/channels/set -d '{"select": {"kind": "LightOn"}, "value": {"OnOff": "On"}}'

Unlock the lock

curl -X PUT http://localhost:3000/api/v1/channels/set -d '{"select": {"kind": "DoorLocked"}, "value": {"DoorLocked": "Unlocked"}}'

Load the recipe through the REST API

$ curl -X PUT http://localhost:3000/api/v1/channels/set -d '{"select":{"kind":"AddThinkerbellRule"},"value":{"ThinkerbellRule":{"name":"When nobody is home, close the lock, turn off everything.","source":"{\"name\":\"When nobody is home, close the lock, turn off everything.\",\"rules\":[{\"conditions\":[{\"source\":[{\"kind\":\"OpenClosed\"}],\"kind\":\"OpenClosed\",\"range\":{\"Eq\":{\"OpenClosed\":\"Closed\"}},\"duration\":10}],\"execute\":[{\"destination\":[{\"tags\":[]}],\"kind\":\"LightOn\",\"value\":{\"OnOff\":\"Off\"}},{\"destination\":[{\"tags\":[]}],\"kind\":\"DoorLocked\",\"value\":{\"DoorLocked\":\"Locked\"}},{\"destination\":[{\"kind\":\"Log\"}],\"kind\":\"Log\",\"value\":{\"String\":\"Hello Alex, I have turned your kitchen lights off & locked the door for you. Have a wonderful day.\"}}]}]}"}}}'

In case of success, this will result in the following response:

{"thinkerbell-rule-add": null}

Rules are persisted across restarts. If this works once, this should continue working until you delete the rule/the db.

In case of problem

  • curl: (52) Empty reply from server You have a network problem. Do you have a public IP?

Confirm that it works

  • The lights turn off.
  • The door locks.
  • The Foxbox logs will display [[email protected]] Hello Alex, I have turned your kitchen lights off & locked the door for you. Have a wonderful day. (user None)