Class: Home

Home

new Home(element, options)

Construct a new Home object.
Parameters:
Name Type Description
element HTMLElement the HTML element in which to insert the rooms and controls for this home.
options Object basic options for this home. This must include name and control_endpoint. Control updates will be POSTed to control_endpoint/control_id.
Source:

Methods

<static> register_control(type, control)

Register a new control type.
Parameters:
Name Type Description
type String controls of this type will be created using the registered control function.
control Class the object that will be instantiated for every control of this type. This must have a constructor (which is given a Home instance and options parameters) and a render method.
Source:

add_control(room_id, control_id, control)

Add a control to a room.
Parameters:
Name Type Description
room_id String the id of the room in which to add the control. The room has to have been added via #add_room.
control_id String the id of the control being added.
control Object the control to add. Requires a type that has been registered earlier with Home.register_control and any other control-specific options. Example:

{"type": "on-off", "name": "Lights", "on": true}
Source:

add_room(id, room)

Add a room to this home.
This:
Parameters:
Name Type Description
id String the id of the new room.
room Object the room to add. This must include a name and can include a map of controls. Example:

{
  "name": "Bedroom",
  "controls": {
    "bedroom/lights": {"type": "on-off", "name": "Lights", "on": true}
  }
}
Source:
See: