Follow me

Exercise 2 : Using multiple lights and dimmer lights

Now you will enhance the tutorial version by managing dimmer lights.

Question 1 – More lights: Note that there is only one light per room. Copy the script and rename the copy to multiple_lights_environment.bhv.

Modify the script to have at least two lights per room.

When creating a new device, you must give it an unique ID. An ID cannot be used twice. The ID is a string and there is no restriction on how to format the device name. We strongly recommend to give it an easily recognizable name.
Stop the running script. Use the reset environment command in the “Script Panel” and run your newly created script.

Question 2 – No more than n lights: As you can notice, the present implementation of the follow me is turning all the lights on when a user enter a room. This is obviously not energy friendly.

Change the current implementation so that the number of light per room can be configured.
We strongly recommend you store the maximum number in a member variable (you will have to reuse it later when building the administration interfaces) :

/** 
* The maximum number of lights to turn on when a user enters the room :
**/
private int maxLightsToTurnOnPerRoom = 1;

Question 3 – Using the dimmer lights: You will now manage a new type of device called “dimmer light”. The specification of dimmer lights is given in the iCASA documentation. Each dimmer light uses the fr.liglab.adele.icasa.device.light.DimmerLight interface.The full javadoc is available here

Modify the application to switch on (0%) and off(100%) the dimmer lights (as well as the binary lights) when the user is moving.

Modify your script so add some dimmer lights in the different rooms. Example :

<create-device id="DL-A0001W-S" type="iCasa.DimmerLight" />

Check your application is working as expected.