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. |
Methods
-
<static> register_control(type, control)
-
Register a new control type.
Parameters:
Name Type Description typeString controls of this type will be created using the registered control function. controlClass 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 rendermethod. -
add_control(room_id, control_id, control)
-
Add a control to a room.
Parameters:
Name Type Description room_idString the id of the room in which to add the control. The room has to have been added via #add_room. control_idString the id of the control being added. controlObject the control to add. Requires a typethat has been registered earlier with Home.register_control and any other control-specific options. Example:{"type": "on-off", "name": "Lights", "on": true} -
add_room(id, room)
-
Add a room to this home.
This:
- {Home}
Parameters:
Name Type Description idString the id of the new room. roomObject the room to add. This must include a nameand can include a map ofcontrols. Example:{ "name": "Bedroom", "controls": { "bedroom/lights": {"type": "on-off", "name": "Lights", "on": true} } }- Source:
- See: