Gladys

3.9.1

Gladys Node.js API documentation

A documentation of all function of Gladys API.

If you see an error please create an issue.

Alarm

gladys.alarm.create

This function create an alarm
gladys.alarm.create(alarm: Object): Alarm
Parameters
Name Type Description
alarm Object
Parameters properties
Name Type Description
alarm.name String The name of the alarm
alarm.datetime datetime Datetime of the alarm when the alarm is at a specific date
alarm.time time Time of the alarm when it's a reccurring alarm
alarm.dayofweek integer The day the alarm should ring (reccurring alarm)
Returns
Alarm: alarm
Example
var alarm = {
     name: 'Monday wake up !',
     time: '08:00',
     dayofweek: 1
};

gladys.alarm.create(alarm)
     .then(function(alarm){
         // alarm created !
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.alarm.delete

This function delete an alarm
gladys.alarm.delete(alarm: Object): Alarm
Parameters
Name Type Description
alarm Object
Parameters properties
Name Type Description
alarm.id integer The id of alarm
Returns
Alarm: alarm
Example
var alarm = {
     id: 1,
};

gladys.alarm.delete(alarm)
     .then(function(alarm){
        // alarm deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.alarm.get

This function retunr all alarm of user
gladys.alarm.get(user: Object): Array<alarms>
Parameters
Name Type Description
user Object
Parameters properties
Name Type Description
user.id integer The id of the user whose alarms we want
Returns
Array<alarms>: alarm
Example
var user = {
     id: 1,
};

gladys.alarm.get(user)
     .then(function(alarms){
        // all alarms of this user ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

Area

gladys.area.create

This function create an area
gladys.area.create(area: Object): area
Parameters
Name Type Description
area Object
Parameters properties
Name Type Description
area.name String The name of the area
area.latitude latitude The latitude of the area
area.longitude longitude The longitude of the area
area.radius integer The radius of the area
area.user integer The id of the area's user
Returns
area: area
Example
var area = {
     name: 'My Home !',
     latitude: 42,
     longitude: 3,
     radius: 40,
     user: 1
};

gladys.area.create(area)
     .then(function(area){
        // area created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.area.update

This function update an area
gladys.area.update(area: Object): area
Parameters
Name Type Description
area Object
Parameters properties
Name Type Description
area.id integer The id of the area
area.name String The name of the area
area.latitude latitude The latitude of the area
area.longitude longitude The longitude of the area
area.radius integer The radius of the area
area.user integer The id of the area's user
Returns
area: area
Example
var area = {
     id: 1
     name: 'My area updated',
     latitude: 42,
     longitude: 3,
     radius: 40,
     user: 1
};

gladys.area.update(area)
     .then(function(area){
        // area updated ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.area.delete

This function delete an area
gladys.area.delete(area: Object): area
Parameters
Name Type Description
area Object
Parameters properties
Name Type Description
area.id integer The id of the area
Returns
area: area
Example
var area = {
     id: 1
};

gladys.area.delete(area)
     .then(function(area){
        // area deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.area.get

This function return all area of the user
gladys.area.get(user: Object): Array<areas>
Parameters
Name Type Description
user Object
Parameters properties
Name Type Description
user.id integer The id of the user's areas
Returns
Array<areas>: area
Example
var user = {
     id: 1
};

gladys.area.get(user)
     .then(function(areas){
        // all areas of this user ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.area.userIn

This function return all areas the user is currently in
gladys.area.userIn(user: Object): any
Parameters
Name Type Description
user Object
Parameters properties
Name Type Description
user.id String The id of the user
Returns
any: [ {area} ] areas
Example
var user = {
   id: 1
};

gladys.area.userIn(user)
     .then((areas) => {
        // areas is an array of areas where the user is in currently
     })
     .catch((err) => {
         // something bad happened ! :/
     });

Box

gladys.box.create

This function create an box
gladys.box.create(box: Object): box
Parameters
Name Type Description
box Object
Parameters properties
Name Type Description
box.boxtype boxtype The id of the boxType
box.x integer The x position of the box
box.y integer The y position of the box
box.user integer The id of the box's user
Returns
box: box
Example
var box = {
     boxtype: 1,
     x: 1,
     y: 1,
     user: 1
};

gladys.box.create(box)
     .then(function(box){
        // box created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.box.update

This function update an box
gladys.box.update(box: Object): box
Parameters
Name Type Description
box Object
Parameters properties
Name Type Description
box.id integer The id of the box
box.boxtype boxtype The id of the boxType
box.x integer The x position of the box
box.y integer The y position of the box
box.param text JSON of the box's parameters
box.user integer The id of the box's user
Returns
box: box
Example
var box = {
     id: 1,
     boxtype: 2,
     x: 2,
     y: 1,
     param: {"first param":"hello world !"}
     user: 1
};

gladys.box.update(box)
     .then(function(box){
        // box updated ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.box.delete

This function delete an box
gladys.box.delete(box: Object): box
Parameters
Name Type Description
box Object
Parameters properties
Name Type Description
box.id integer The id of the box
Returns
box: box
Example
var box = {
     id: 1
};

gladys.box.delete(box)
     .then(function(box){
        // box deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.box.getBoxUser

This function return all box of one user
gladys.box.getBoxUser(options: Object): Array<boxs>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.user Object
Returns
Array<boxs>: box
Example
var options = {
    user : {
        id : 1
    }
}

gladys.box.getBoxUser(options)
     .then(function(boxs){
        // all boxs of this user ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.box.getById

This function return box
gladys.box.getById(id: integer): box
Parameters
Name Type Description
id integer The id of the boxs
Returns
box: box
Example
var id = 1

gladys.box.getById(id)
     .then(function(box){
        // do something  
     })
     .catch(function(err){
         // something bad happened ! :/
     });

BoxType

gladys.boxType.create

This function create an boxType
gladys.boxType.create(boxType: Object): boxType
Parameters
Name Type Description
boxType Object
Parameters properties
Name Type Description
boxType.uuid String The uuid of the boxType
boxType.title String The title of the boxType
boxType.path String The path of the boxType.ejs file
boxType.view String The view where the boxType should be displayed
Returns
boxType: boxType
Example
var boxType = {
     uuid: "18f956ff-9953-4be9-891f-0f379a4ec167", //This is an example, do not use it
     title: "My boxType",
     path: "views/boxs/my-box.ejs", 
     view: "dashboard" 
};

gladys.boxType.create(boxType)
     .then(function(boxType){
        // boxType created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.boxType.update

This function update an boxType
gladys.boxType.update(boxType: Object): boxType
Parameters
Name Type Description
boxType Object
Parameters properties
Name Type Description
boxType.id integer The id of the boxType
boxType.uuid String The uuid of the boxType
boxType.title String The title of the boxType
boxType.path String The path of the boxType.ejs file
boxType.view String The view where the boxType should be displayed
Returns
boxType: boxType
Example
var boxType = {
     id: 1,
     uuid: "18f956ff-9953-4be9-891f-0f379a4ec167", //This is an example, do not use it
     title: "New title of My boxType",
     path: "views/boxs/my-box.ejs", 
     view: "dashboard" 
};

gladys.boxType.update(boxType)
     .then(function(boxType){
        // boxType updated ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.boxType.delete

This function delete an boxType
gladys.boxType.delete(boxType: Object): boxType
Parameters
Name Type Description
boxType Object
Parameters properties
Name Type Description
boxType.id integer The id of the boxType
Returns
boxType: boxType
Example
var boxType = {
     id: 1
};

gladys.boxType.delete(boxType)
     .then(function(boxType){
        // boxType deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.boxType.getAll

This function return all boxType
gladys.boxType.getAll(): Array<boxTypes>
Returns
Array<boxTypes>: boxType
Example
gladys.boxType.getAll()
     .then(function(boxTypes){
        // boxType deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

Calendar

gladys.calendar.create

This function create an calendar
gladys.calendar.create(calendars: Object): calendar
Parameters
Name Type Description
calendars Object
Parameters properties
Name Type Description
calendars.externalid String The externalId of the calendar
calendars.name String The name of the calendar
calendars.description String The description of the calendar
calendars.service String The service of the calendar
calendars.user User The id of the calendar's user
Returns
calendar: calendar
Example
var calendars = {
     externalid: "gladys-calendar123456789", //This is an example, do not use it, it must be unique
     name: "My awesome calendar",
     description: "calendar description",
     service: "google"
     user: 1
};

gladys.calendar.create(calendars)
     .then(function(calendar){
        // calendar created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.calendar.update

This function update an calendar
gladys.calendar.update(calendar: Object): calendar
Parameters
Name Type Description
calendar Object
Parameters properties
Name Type Description
calendar.id integer The id of calendar
calendar.externalid String The externalId of the calendar
calendar.name String The name of the calendar
calendar.description String The description of the calendar
calendar.service String The service of the calendar
calendar.user User The id of the calendar's user
Returns
calendar: calendar
Example
var calendar = {
     id: 1,
     externalid: "gladys-calendar123456789", //This is an example, do not use it, it must be unique
     name: "My awesome calendar",
     description: "calendar description",
     service: "google"
     user: 1
};

gladys.calendar.update(calendar)
     .then(function(calendar){
        // calendar updated ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.calendar.delete

This function delete an calendar
gladys.calendar.delete(calendar: Object): calendar
Parameters
Name Type Description
calendar Object
Parameters properties
Name Type Description
calendar.id integer The id of calendar
Returns
calendar: calendar
Example
var calendar = {
     id: 1,
};

gladys.calendar.delete(calendar)
     .then(function(calendar){
        // calendar deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.calendar.get

This function return all calendars
gladys.calendar.get(options: Object): Array<calendars>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of calendars to return (optional)
options.skip integer The number of calendars to skip (optional)
Returns
Array<calendars>: calendars
Example
var options = {
     take: 50,
     skip: 0
}
gladys.calendar.get(options)
     .then(function(calendars){
         // do something
     })

gladys.calendar.getByService

This function return an calendar with a specific service
gladys.calendar.getByService(service: String): calendar
Parameters
Name Type Description
service String
Returns
calendar: calendar
Example
var service = "gladys-calendar123456789"

gladys.calendar.getByService(service)
     .then(function(calendar){
         // do something
     })

CalendarEvent

gladys.calendar.createEvent

This function create an event
gladys.calendar.createEvent(event: Object): event
Parameters
Name Type Description
event Object
Parameters properties
Name Type Description
event.externalid String The externalId of the event
event.name String The name of the event
event.location String The location of the event
event.start datetime The start of the event
event.end datetime The end of the event
event.fullday boolean If the event lasts a full day
event.calendar Calendar The id of the calendar
Returns
event: event
Example
var event = {
     externalid: "gladys-calendarevent123456789", //This is an example, do not use it, it must be unique
     name: "My awesom event",
     location: "Paris",
     start: "2018-03-20 08:30:00",
     end: "2018-03-20 09:30:00",
     fullday: false,
     calendar: 1
};

gladys.calendar.createEvent()
     .then(function(event){
        // event created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.calendar.updateEvent

This function update an event
gladys.calendar.updateEvent(calendarEvent: Object): event
Parameters
Name Type Description
calendarEvent Object
Parameters properties
Name Type Description
calendarEvent.id integer The id of the event
calendarEvent.externalid String The externalId of the event
calendarEvent.name String The name of the event
calendarEvent.location String The location of the event
calendarEvent.start datetime The start of the event
calendarEvent.end datetime The end of the event
calendarEvent.fullday boolean If the event lasts a full day
calendarEvent.calendar calendar The id of the calendar
Returns
event: event
Example
var calendarEvent = {
     id: 1,
     externalid: "gladys-calendarevent123456789", //This is an example, do not use it, it must be unique
     name: "My new awesom event name",
     location: "Paris",
     start: "2018-03-20 08:30:00",
     end: "2018-03-20 09:30:00",
     fullday: false,
     calendar: 1
};

gladys.calendar.updateEvent(calendarEvent)
     .then(function(event){
        // event updated ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.calendar.deleteEvent

This function delete an event
gladys.calendar.deleteEvent(calendarEvent: Object): event
Parameters
Name Type Description
calendarEvent Object
Parameters properties
Name Type Description
calendarEvent.id integer The id of the event
Returns
event: event
Example
var calendarEvent = {
     id: 1
};

gladys.calendar.deleteEvent(calendarEvent)
     .then(function(event){
        //event deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.calendar.getEvents

This function return all events
gladys.calendar.getEvents(options: Object): Array<events>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of events to return (optional)
options.skip integer The number of events to skip (optional)
Returns
Array<events>: events
Example
var options = {
     take: 50,
     skip: 0
}
gladys.calendar.getEvents(options)
     .then(function(events){
         // do something
     })

gladys.calendar.getFirstEventTodayUser

This function returns the first event of the specified user's day
gladys.calendar.getFirstEventTodayUser(userId: integer): event
Parameters
Name Type Description
userId integer
Returns
event: event
Example
var userId = 1

gladys.calendar.getFirstEventTodayUser(userId)
     .then(function(event){
         // do something
     })

gladys.calendar.getNextEventUser

This function returns the next event of the specified user's day
gladys.calendar.getNextEventUser(user: Object): event
Parameters
Name Type Description
user Object
Parameters properties
Name Type Description
user.id integer The id of user
Returns
event: event
Example
var user = {
     id: 1
}

gladys.calendar.getNextEventUser(user)
     .then(function(event){
         // do something
     })

Device

gladys.device.create

This function create an device and its deviceType (see exemple for more details)
gladys.device.create(param: Object, device: Object, types: Array): Device
Parameters
Name Type Description
param Object
Parameters properties
Name Type Description
param.device Object
param.types Array if the device has deviceType (optional)
Name Type Description
device Object
Parameters properties
Name Type Description
device.name String The name of the device
device.identifer String The identifer of the device, it must be unique
device.protocol String The protocol of the device
device.service String The service of the device, the module to which it must be connected
Name Type Description
types Array
Parameters properties
Name Type Description
types.type String The type of the deviceType (binary or multilevel)
types.sensor bolean If the type is an sensor
types.min integer The min of the deviceType
types.max integer The max of the deviceType
Returns
Device: device
Example
var param = {
    device: {
        name: 'Light in my room',
        identifier: 'milight-12',
        protocol: 'milight',
        service: 'milight'
    },
    types: [
        {
            type: 'binary',
            sensor: false,
            min: 0,
            max: 1
        },
        {
            type:'multilevel',
            unit: 'color',
            sensor: false,
            min: 0,
            max: 100
        }
    ]   
};

gladys.device.create(param)
     .then(function(device){
        // device created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.device.update

This function update an device and its deviceType
gladys.device.update(device: Object): Device
Parameters
Name Type Description
device Object
Parameters properties
Name Type Description
device.id integer The id of the device
device.name String The name of the device
device.identifer String The identifer of the device, it must be unique
device.protocol String The protocol of the device
device.service String The service of the device, the module to which it must be connected
Returns
Device: device
Example
var device: {
     id: 1
     name: 'Light updated',
     identifier: 'milight-122',
     protocol: 'milight',
     service: 'milight'
};

gladys.device.update(device)
     .then(function(device){
        // device updated ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.device.delete

This function delete an device and its deviceType
gladys.device.delete(device: Object): Device
Parameters
Name Type Description
device Object
Parameters properties
Name Type Description
device.id integer The id of the device
Returns
Device: device
Example
var device: {
     id: 1
};

gladys.device.delete(device)
     .then(function(device){
        // device deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.device.get

This function return all device
gladys.device.get(options: Object): Array<devices>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of devices to return (optional)
options.skip integer The number of devices to skip (optional)
Returns
Array<devices>: devices
Example
var options = {
     take: 50,
     skip: 0
}
gladys.device.get(options)
     .then(function(devices){
         // do something
     })

gladys.device.getByIdentifier

This function return one device
gladys.device.getByIdentifier(options: Object): device
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.identifier String he identifer of the device
options.service String The service of the device
Returns
device: device
Example
var options = {
     identifier: 'milight-122',
     service: 'milight'
}
gladys.device.getByIdentifier(options)
     .then(function(device){
         // do something
     })

gladys.device.getByService

This function return one device
gladys.device.getByService(options: Object): device
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.service String The service of the device
Returns
device: device
Example
var options = {
     service: 'milight'
}
gladys.device.getByService(options)
     .then(function(device){
         // do something
     })

DeviceState

gladys.deviceState.create

This function create an deviceState
gladys.deviceState.create(state: Object): State
Parameters
Name Type Description
state Object
Parameters properties
Name Type Description
state.value float The value of state
state.devicetype Devicetype The id of deviceType to which state has been assigned
Returns
State: state
Example
var state = {
     value: 50,
     devicetype: 2
}

gladys.deviceState.create(state)
     .then(function(state){
        // deviceState created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.deviceState.createByDeviceTypeIdentifier

This function create an deviceState
gladys.deviceState.createByDeviceTypeIdentifier(identifier: String, service: String, state: float): State
Parameters
Name Type Description
identifier String The identifer of device to which deviceType has been assigned
Name Type Description
service String The service of device to which deviceType has been assigned
Name Type Description
state float The value of state
Returns
State: state
Example
var identifier = 'milight-12';
var service = 'milight';
var state = {
 value: 1
};

gladys.deviceState.createByDeviceTypeIdentifier(identifier, service, state)
     .then(function(state){
        // deviceState created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.deviceState.get

This function return all deviceState
gladys.deviceState.get(options: Object): Array<deviceStates>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of deviceStates to return (optional)
options.skip integer The number of deviceStates to skip (optional)
Returns
Array<deviceStates>: deviceStates
Example
var options = {
     take: 50,
     skip: 0
}
gladys.deviceState.get(options)
     .then(function(deviceStates){
         // do something
     })

gladys.deviceState.purge

This function purge table of deviceState
gladys.deviceState.purge(options: Object)
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.devicetype number The id of deviceType to purge the states
options.days number The number of days beyond which we want to purge the states
Example
var options = {
     devicetype: 1,
     days: 2
}
gladys.deviceState.purge(options)
     .then(function(deviceStates){
         // do something
     })

DeviceType

gladys.deviceType.create

This function create an deviceType
gladys.deviceType.create(type: Object): DeviceType
Parameters
Name Type Description
type Object
Parameters properties
Name Type Description
type.name String The name of the deviceType
type.type String The type of the deviceType (binary or multilevel)
type.sensor bolean If the deviceType is an sensor
type.min integer The min of the deviceType
type.max integer The max of the deviceType
type.unit String The unit of the deviceType
type.device Device The id of device to which it is assigned
Returns
DeviceType: deviceType
Example
var type = {
     name: "My deviceType",
     type: 'multilevel',
     sensor: true,
     min: 0,
     max: 50,
     unit: "%",
     device: 1
};

gladys.deviceType.create(type)
     .then(function(devicType){
        // deviceType created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.deviceType.delete

This function delete an deviceType
gladys.deviceType.delete(deviceType: Object): DeviceType
Parameters
Name Type Description
deviceType Object
Parameters properties
Name Type Description
deviceType.id integer The id of the deviceType
Returns
DeviceType: deviceType
Example
var deviceType = {
     id: 1
};

gladys.deviceType.delete(deviceType)
     .then(function(deviceType){
        // deviceType deleted ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.deviceType.getAll

This function return all deviceTypes
gladys.deviceType.getAll(): Array<deviceType>
Returns
Array<deviceType>: deviceType
Example
gladys.deviceType.getAll()
     .then(function(deviceTypes){
         // do something
     })

gladys.deviceType.getByCategory

This function return all deviceTypes of a category
gladys.deviceType.getByCategory(options: Object): Array<deviceType>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.category String The category deviceType we want to get
options.room integer The room.id we want to get
options.type String The type of deviceType we want to get
Returns
Array<deviceType>: deviceType
Example
gladys.deviceType.getByCategory(options)
     .then(function(deviceType){
         // do something
     })

gladys.deviceType.getById

This function return an deviceTypes
gladys.deviceType.getById(device: Object): DeviceType
Parameters
Name Type Description
device Object
Parameters properties
Name Type Description
device.id String The id of deviceType we want to get
Returns
DeviceType: deviceType
Example
var device = {
     id: 1
}

gladys.deviceType.getById(device)
     .then(function(deviceType){
         // do something
     })

gladys.deviceType.getByIdentifier

This function return an deviceTypes
gladys.deviceType.getByIdentifier(options: Object): DeviceType
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.deviceIdentifier String The identifier of device we want to get the deviceType
options.deviceService String The service of device we want to get the deviceType
options.deviceTypeIdentifier String The identifier of deviceType we want to get
Returns
DeviceType: deviceType
Example
var options = {
     deviceIdentifier: "milight-1",
     deviceService: "milight",
     deviceTypeIdentifier: "milight_light_1"
}

gladys.deviceType.getByIdentifier(options)
     .then(function(deviceType){
         // do something
     })

gladys.deviceType.getByType

This function return all deviceTypes of one type
gladys.deviceType.getByType(device: Object): Array<deviceType>
Parameters
Name Type Description
device Object
Parameters properties
Name Type Description
device.type String The type of deviceType we want to get
Returns
Array<deviceType>: deviceType
Example
var device = {
     type: "binary"
}

gladys.deviceType.getByType(device)
     .then(function(deviceTypes){
         // do something
     })

gladys.deviceType.getByDevice

This function return all deviceTypes of an device
gladys.deviceType.getByDevice(device: Object): Array<deviceType>
Parameters
Name Type Description
device Object
Parameters properties
Name Type Description
device.id String The id of device we want to get the deviceType
Returns
Array<deviceType>: deviceType
Example
var device = {
     id: 1
}

gladys.deviceType.getByDevice(device)
     .then(function(deviceType){
         // do something
     })

gladys.deviceType.getByRoom

This function return all deviceTypes ordered by room
gladys.deviceType.getByRoom(options: any): Array<deviceType>
Parameters
Name Type Description
options any
Returns
Array<deviceType>: deviceType
Example
gladys.deviceType.getByRoom()
     .then(function(deviceTypes){
         // do something
     })

Event

gladys.event.create

This function create an event
gladys.event.create(event: Object): Event
Parameters
Name Type Description
event Object
Parameters properties
Name Type Description
event.code String The event code you want to create
event.user integer The id of the user concerned by the event (only for user-related event) (optional)
event.house integer The id of the house where the events take place (optional)
event.room integer The id of the room where the events take place (optional)
Returns
Event: event
Example
var event = {
     code: 'wakeup',
     user: 1,
     house: 1,
     room: 2
};

gladys.event.create(event)
     .then(function(event){
        // event created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.event.get

This function return all events
gladys.event.get(options: Object, user: Object): Array<events>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of events to return (optional)
options.skip integer The number of events to skip (optional)
options.user Object
Name Type Description
user Object
Parameters properties
Name Type Description
user.id integer Th id of user
Returns
Array<events>: events
Example
var options = {
     user = {id: 1},
     take: 50,
     skip: 0
}
gladys.event.get(options)
     .then(function(events){
         // do something
     })

gladys.event.getByEventtype

This function return all events of one eventtype
gladys.event.getByEventtype(options: Object): Array<events>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of events to return (optional)
options.skip integer The number of events to skip (optional)
options.eventtype Object The id of eventtype
Returns
Array<events>: events
Example
var options = {
     eventtype: 1,
     take: 50,
     skip: 0
}
gladys.event.getByEventType(options)
     .then(function(events){
         // do something
     })

EventType

gladys.eventType.create

This function create an eventType
gladys.eventType.create(type: Object)
Parameters
Name Type Description
type Object
Parameters properties
Name Type Description
type.code String The code of eventType, it must be unique
type.name String The name of eventType
type.description String The description of eventType
type.category String The category of eventType
type.service String The service of eventType
type.faIcon String The faIcon of eventType
type.iconColor String The iconColor of eventType
Example
var type = {
     code: "back-at-home",
     name: "Back at Home",
     description: "User is back at home",
     category: "user", 
     service: "0",
     faIcon: "fa fa-home",
     iconColor: "bg-light-blue" 
}
gladys.eventType.create(type)
     .then(function(eventType){
         // do something
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.eventType.get

This function return all eventTypes
gladys.eventType.get(): Array<eventType>
Returns
Array<eventType>: eventType
Example
gladys.eventType.get()
     .then(function(eventTypes){
         // do something
     })

gladys.eventType.getByCategory

This function return all eventType of one category
gladys.eventType.getByCategory(options: Object): Array<eventType>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.category String The category of eventType to return
Returns
Array<eventType>: eventTypes
Example
var type = {
     category: "user"
}
gladys.eventType.getByCategory(options)
     .then(function(eventTypes){
         // do something
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.eventType.getByCode

This function return an eventType
gladys.eventType.getByCode(type: Object): EventType
Parameters
Name Type Description
type Object
Parameters properties
Name Type Description
type.code String The code of eventType to return
Returns
EventType: eventType
Example
var type = {
     code: "back-at-home"
}
gladys.eventType.getByCode(type)
     .then(function(eventType){
         // do something
     })
     .catch(function(err){
         // something bad happened ! :/
     });

House

gladys.house.create

This function create an house
gladys.house.create(house: Object): House
Parameters
Name Type Description
house Object
Parameters properties
Name Type Description
house.name String The name of the house
house.address String The address of the house
house.city String The city of the house
house.postcode integer The postcode of the house
house.country String The country of the house
house.latitude float The latitude of the house
house.longitude float The longitude of the house
Returns
House: house
Example
var house = {
     name: "Maison",
     address: "9 route de gien",
     city: "Paris",
     postcode: 90100,
     country: "france",
     latitude: 42,
     longitude: 43,
}

gladys.house.create(house)
     .then(function(house){
         // do something
     })

gladys.house.update

This function update an house
gladys.house.update(house: Object): House
Parameters
Name Type Description
house Object
Parameters properties
Name Type Description
house.id integer The id of the house
house.name String The name of the house
house.address String The address of the house
house.city String The city of the house
house.postcode integer The postcode of the house
house.country String The country of the house
house.latitude float The latitude of the house
house.longitude float The longitude of the house
Returns
House: house
Example
var house = {
     id: 1
     name: "Maison",
     address: "9 route de gien",
     city: "Paris",
     postcode: 90100,
     country: "france",
     latitude: 42,
     longitude: 43,
}

gladys.house.update(house)
     .then(function(house){
         // do something
     })

gladys.house.delete

This function delete an house
gladys.house.delete(house: Object)
Parameters
Name Type Description
house Object
Parameters properties
Name Type Description
house.id integer The id of the house
Example
var house = {
     id: 1
}

gladys.house.delete(house)
     .then(function(house){
         // do something
     })

gladys.house.get

This function return all houses
gladys.house.get(options: Object): Array<houses>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of houses to return (optional)
options.skip integer The number of houses to skip (optional)
Returns
Array<houses>: houses
Example
var options = {
     take: 50,
     skip: 0
}
gladys.house.get(options)
     .then(function(houses){
         // do something
     })

gladys.house.getById

This function retunr an house
gladys.house.getById(options: any, house: Object): House
Parameters
Name Type Description
options any
Name Type Description
house Object
Parameters properties
Name Type Description
house.id integer The id of the house
Returns
House: house
Example
var house = {
     id: 1
}

gladys.house.getById(house)
     .then(function(house){
         // do something
     })

gladys.house.getUsers

This function retunr an house
gladys.house.getUsers(options: any, house: Object): House
Parameters
Name Type Description
options any
Name Type Description
house Object
Parameters properties
Name Type Description
house.id integer The id of the house
Returns
House: house
Example
var house = {
     id: 1
}

gladys.house.getById(house)
     .then(function(isEmpty){
         if(isEmpty){
             //House is not empty
         }else{
             //House is empty
         }
     })

gladys.house.checkUserPresence

This function check if an user as at home and create an event in timeline
gladys.house.checkUserPresence()
Example
gladys.house.checkUserPresence();

Location

gladys.location.create

This function create an location
gladys.location.create(location: Object): Location
Parameters
Name Type Description
location Object
Parameters properties
Name Type Description
location.latitude float The latitude of location
location.longitude float The longitude of location
location.altitude float The altitude of location (optional)
location.accuracy float The accuracy of location (optional)
Returns
Location: location
Example
var location = {
     latitude: 'wakeup',
     longitude: 1,
     altitude: 1,
     accuracy: 2
};

gladys.location.create(location)
     .then(function(location){
        // location created ! 
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.location.get

This function return all locations
gladys.location.get(): Array<locations>
Returns
Array<locations>: location
Example
gladys.lacation.get()
     .then(function(locations){
         // do something
     })

gladys.location.getByUser

This function return all locations
gladys.location.getByUser(options: Object): Array<locations>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of locations to return (optional)
options.skip integer The number of locations to skip (optional)
options.accuracy integer The accuracy of locations we want get (optional)
options.user integer The user id to which the locations are assigned
Returns
Array<locations>: location
Example
var options = {
     take: 50,
     skip: 0,
     accuracy: 300,
     user: 1
}
gladys.lacation.getByUser()
     .then(function(locations){
         // do something
     })
     .catch(function(err){
         // something bad happened ! :/
     });

Machine

gladys.machine.create

This function create an machine
gladys.machine.create(machine: Object): Machine
Parameters
Name Type Description
machine Object
Parameters properties
Name Type Description
machine.name String The name of the machine
machine.house House The id of house of the machine
machine.host String The host of the machine
machine.me boolean If this machine is the created machine
Returns
Machine: machine
Example
var machine = {
     name: "Machine one",
     house: 1,
     host: "ip address",
     me: true,
}

gladys.machine.create(machine)
     .then(function(machine){
         // machine created
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.machine.update

This function update an machine
gladys.machine.update(machine: Object): Machine
Parameters
Name Type Description
machine Object
Parameters properties
Name Type Description
machine.id integer The id of machine
machine.name String The name of the machine
machine.house House The id of house of the machine
machine.host String The host of the machine
machine.me boolean If this machine is the updated machine
Returns
Machine: machine
Example
var machine = {
     id: 1,
     name: "Machine one updated",
     house: 1,
     host: "ip address",
     me: true,
}

gladys.machine.update(machine)
     .then(function(machine){
         // machine updated
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.machine.delete

This function delete an machine
gladys.machine.delete(machine: Object)
Parameters
Name Type Description
machine Object
Parameters properties
Name Type Description
machine.id integer The id of the machine
Example
var machine = {
     id: 1
}

gladys.machine.delete(machine)
     .then(function(machine){
         // do something
     })

gladys.machine.get

This function return all machines
gladys.machine.get(): Array<machines>
Returns
Array<machines>: machine
Example
gladys.machine.get()
     .then(function(machines){
         // do something
     })

gladys.machine.heartbeat

This function set the lastSeen attribute of the machine to now
gladys.machine.heartbeat(machine: machine): Machine
Parameters
Name Type Description
machine machine The machine
Parameters properties
Name Type Description
machine.uuid uuid The uuid of the machine
Returns
Machine: machine
Example
var machine = {
     uuid: '46929309-0fa0-4f29-8c51-4d8e6ff6b078'
};

gladys.machine.heartbeat(machine)
     .then((machine) => {
         
     })
     .catch((err) => {
         // something bad happened ! :/
     });

Message

gladys.message.send

This function send an message
gladys.message.send(user: any, message: Object): Message
Parameters
Name Type Description
user any
Name Type Description
message Object
Parameters properties
Name Type Description
message.sender User The sender of message
message.receiver User The name of message, If it is null then the receveiver is Gladys
message.text text The text of message
message.service String The service of message
Returns
Message: message
Example
var message = {
     text: "Hello Gladys !",
     service: "Pushbullet"
} // the sender is user

var user = {
     id: 1
}

gladys.message.send(user, message)
     .then(function(message){
         // message sended
     })
     .catch(function(err){
         // something bad happened ! :/
     });

Mode

gladys.mode.create

This function create an mode
gladys.mode.create(mode: Object): Mode
Parameters
Name Type Description
mode Object
Parameters properties
Name Type Description
mode.code String The code of the mode, it must be unqiue
mode.name String The name of the mode
mode.description String The description of the mode
Returns
Mode: mode
Example
var mode = {
     code: "romantic"
     name: "romantic ;)",
     description: "it's the romantic mode",
}

gladys.mode.create(mode)
     .then(function(mode){
         // mode created
     })

gladys.mode.change

This function change mode of an house
gladys.mode.change(params: Object): Mode
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.house integer The house we want to change the mode
params.mode String The code of the mode
Returns
Mode: mode
Example
var params = {
     house: 1,
     mode: "romantic"
}

gladys.mode.change(params)
     .then(function(mode){
         // do something
     })

gladys.mode.delete

This function delete an mode
gladys.mode.delete(mode: Object): Mode
Parameters
Name Type Description
mode Object
Parameters properties
Name Type Description
mode.id integer The id of the mode
Returns
Mode: mode
Example
var mode = {
     id: 1
}

gladys.mode.delete(mode)
     .then(function(mode){
         // mode deleted
     })

gladys.mode.get

This function return all modes
gladys.mode.get(): Array<mode>
Returns
Array<mode>: modes
Example
gladys.mode.get()
     .then(function(modes){
         // do something
     })

Module

gladys.module.heartbeat

This function set the lastSeen attribute of the module to now
gladys.module.heartbeat(module: module): Module
Parameters
Name Type Description
module module The module
Parameters properties
Name Type Description
module.machine uuid The uuid of the machine
module.slug String The slug of the module
Returns
Module: module
Example
var module = {
 machine: '46929309-0fa0-4f29-8c51-4d8e6ff6b078',
 slug: 'hue'
};

gladys.module.heartbeat(module)
     .then((module) => {
         
     })
     .catch((err) => {
         // something bad happened ! :/
     });

Music

gladys.music.play

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the music/which precise deviceType is playing.
gladys.music.play(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.music.play(params)

gladys.music.pause

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the music/which precise deviceType is playing.
gladys.music.pause(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.music.pause(params)

gladys.music.stop

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the music/which precise deviceType is playing.
gladys.music.stop(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.music.stop(params)

gladys.music.next

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the music/which precise deviceType is playing.
gladys.music.next(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.music.next(params)

gladys.music.previous

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the music/which precise deviceType is playing.
gladys.music.previous(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.music.previous(params)

gladys.music.setMuted

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the music/which precise deviceType is playing.
gladys.music.setMuted(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.music.setMuted(params)

Notification

gladys.notification.create

This function create an notification
gladys.notification.create(options: Object): Notification
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.title String The title of the notification
options.text String The text of the notification
options.link String The link of view
options.icon String The icon of the notification
options.iconColor String The icon color of the notification icon
options.user User The id of the user of the notification
Returns
Notification: notification
Example
var options = {
     title: "Update available !",
     text: "Gladys Update 3.8.0 is available",
     link: "/dashboard"
     icon: "fa fa-refresh",
     iconColor: "bg-light-blue",
     user: 1
}

gladys.notification.create(options)
     .then(function(notification){
         // notification created
     })
     .catch(function(err){
         // something bad happened ! :/
     });

gladys.notification.install

This function create an notificationType
gladys.notification.install(type: Object)
Parameters
Name Type Description
type Object
Parameters properties
Name Type Description
type.service String The service of notification
type.name String The name of notification
Example
var type = {
    service: 'pushbullet',
    name: 'PushBullet'
};

gladys.notification.install(notificationType)
      .then(function(type){
          // new type created !
      })
      .catch(function(err){
         // something bad happened :/ 
      });

gladys.notification.get

This function return all notifications
gladys.notification.get(options: Object, user: Object): Array<notifications>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of notifications to return (optional)
options.skip integer The number of notifications to skip (optional)
options.user Object
Name Type Description
user Object
Parameters properties
Name Type Description
user.id integer The id of the user
Returns
Array<notifications>: notifications
Example
var options = {
     take: 50,
     skip: 0,
     user: {
         id: 1
     }
}
gladys.notification.get(options)
     .then(function(notifications){
         // do something
     })

Param

gladys.param.setValue

This function set value of an param
gladys.param.setValue(param: Object): Param
Parameters
Name Type Description
param Object
Parameters properties
Name Type Description
param.name String The name of the param, it must be unique
param.value String The value of the param
Returns
Param: param
Example
var param = {
     name: "api_key",
     value: "djfudf5d95f23d6d5f5"
}

gladys.param.setValue(param)
     .then(function(param){
         // value seted
     })

gladys.param.delete

This function delete an param
gladys.param.delete(param: Object): Param
Parameters
Name Type Description
param Object
Parameters properties
Name Type Description
param.name String The name of the param
Returns
Param: param
Example
var param = {
     name: "api_key"
}

gladys.param.delete(param)
     .then(function(param){
         // param deleted
     })

gladys.param.get

This function return all params
gladys.param.get(): Array<params>
Returns
Array<params>: param
Example
gladys.param.get()
     .then(function(params){
         // do something
     })

gladys.param.getValue

This function retrun the value an params
gladys.param.getValue(name: String): String
Parameters
Name Type Description
name String The name of the param
Returns
String: param
Example
var name = 'param_1'

gladys.param.getValue(name)
    .then(function(param){
       // do something
    })

gladys.param.getValues

This function retrun the values of the params
gladys.param.getValues(array: Array): Array<param>
Parameters
Name Type Description
array Array Array of the name of the params
Returns
Array<param>: param
Example
var array = ['param_1', 'param_2', 'param_3']

gladys.param.getValues(array)
    .then(function(param){
       // do something
    })

gladys.param.getByModule

This function return all params by module
gladys.param.getByModule(options: any): Array<params>
Parameters
Name Type Description
options any
Returns
Array<params>: param
Example
gladys.param.getByModule({id: MODULE_ID})
     .then((params) => {
         // do something
     })

ParamUser

gladys.paramUser.setValue

This function set value of an param user
gladys.paramUser.setValue(paramUser: Object): ParamUser
Parameters
Name Type Description
paramUser Object
Parameters properties
Name Type Description
paramUser.name String The name of the param, it must be unique
paramUser.value String The value of the param
Returns
ParamUser: paramUser
Example
var paramUser = {
     user: 1,
     name: "api_key",
     value: "djfudf5d95f23d6d5f5"
}

gladys.paramUser.setValue(paramUser)
     .then(function(param){
         // value seted
     })

gladys.paramUser.delete

This function delete an user param
gladys.paramUser.delete(paramUser: Object): ParamUser
Parameters
Name Type Description
paramUser Object
Parameters properties
Name Type Description
paramUser.name String The name of the param
paramUser.user String The id of the user to whom the param is assigned
Returns
ParamUser: paramUser
Example
var paramUser = {
     name: "api_key",
     user: 1
}

gladys.paramUser.delete(paramUser)
     .then(function(param){
         // user param deleted
     })

gladys.paramUser.get

This function return all param of an user
gladys.paramUser.get(user: Object): Array<ParamUser>
Parameters
Name Type Description
user Object
Parameters properties
Name Type Description
user.id integer The id of the user we want get param
Returns
Array<ParamUser>: paramUser
Example
var user = {
     id: 1
}

gladys.paramUser.get(user)
     .then(function(paramsUser){
         // do something
     })

gladys.paramUser.getValue

This function retrun the value an param of an user
gladys.paramUser.getValue(name: String, userId: integer): String
Parameters
Name Type Description
name String The name of the param
Name Type Description
userId integer The id of the user we want get param value
Returns
String: param
Example
var name = 'param_1'
var userId = 1

gladys.paramUser.getValue(name, userId)
    .then(function(param){
       // do something
    })

Room

gladys.room.create

This function create an room
gladys.room.create(room: Object): Room
Parameters
Name Type Description
room Object
Parameters properties
Name Type Description
room.name String The name of the room
room.house House The id of the house of the room
Returns
Room: room
Example
var room = {
     name: "living room",
     house: 1,
}

gladys.room.create(room)
     .then(function(room){
         // room created
     })

gladys.room.update

This function update an room
gladys.room.update(room: Object): Room
Parameters
Name Type Description
room Object
Parameters properties
Name Type Description
room.id integer The id of the room
room.name String The name of the room
room.house House The id of the house of the room
Returns
Room: room
Example
var room = {
     id: 1,
     name: "living room updated",
     house: 1,
}

gladys.room.update(room)
     .then(function(room){
         // room updated
     })

gladys.room.delete

This function delete an room
gladys.room.delete(room: Object): Room
Parameters
Name Type Description
room Object
Parameters properties
Name Type Description
room.id integer The id of the room
Returns
Room: room
Example
var room = {
     id: 1,
}

gladys.room.delete(room)
     .then(function(room){
         // room deleted
     })

Television

gladys.television.pressKey

Allows you to navigate through the TV menus and validate. You can set the devicetype attribute OR the room attribute (if only one TV per room) OR the device attribute to determine which TV you want to use. If there is only one TV declared, you can skip params: it will be chosen by default.
gladys.television.pressKey(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype integer The id of the deviceType
params.room Integer The id of the room
params.device Integer The id of the device
Example
var params = {
     devicetype : 1 // or room or device
}

gladys.television.pressKey(params)

gladys.television.setChannel

Displays the channel on the TV. You can set the devicetype attribute OR the room attribute (if only one TV per room) OR the device attribute to determine which TV you want to use. If there is only one TV declared, you can skip params: it will be chosen by default.
gladys.television.setChannel(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype integer The id of the deviceType
params.room Integer The id of the room
params.device Integer The id of the device
Example
var params = {
     devicetype : 1 // or room or device
}

gladys.television.setChannel(params)

gladys.television.setMuted

Mute or unmute the TV sound. You can set the devicetype attribute OR the room attribute (if only one TV per room) OR the device attribute to determine which TV you want to use. If there is only one TV declared, you can skip params: it will be chosen by default.
gladys.television.setMuted(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype integer The id of the deviceType
params.room Integer The id of the room
params.device Integer The id of the device
Example
var params = {
     devicetype : 1 // or room or device
}

gladys.television.setMuted(params)

gladys.television.switchState

Turn a TV on or off. You can set the devicetype attribute OR the room attribute (if only one TV per room) OR the device attribute to determine which TV you want to use. If there is only one TV declared, you can skip params: it will be chosen by default.
gladys.television.switchState(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype integer The id of the deviceType
params.room Integer The id of the room
params.device Integer The id of the device
Example
var params = {
     devicetype : 1 // or room or device
}

gladys.television.switchState(params)

gladys.television.volumeDown

Decrease the TV sound. You can set the devicetype attribute OR the room attribute (if only one TV per room) OR the device attribute to determine which TV you want to use. If there is only one TV declared, you can skip params: it will be chosen by default.
gladys.television.volumeDown(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype integer The id of the deviceType
params.room Integer The id of the room
params.device Integer The id of the device
Example
var params = {
     devicetype : 1 // or room or device
}

gladys.television.volumeDown(params)

gladys.television.volumeUp

Increases the TV sound. You can set the devicetype attribute OR the room attribute (if only one TV per room) OR the device attribute to determine which TV you want to use. If there is only one TV declared, you can skip params: it will be chosen by default.
gladys.television.volumeUp(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype integer The id of the deviceType
params.room Integer The id of the room
params.device Integer The id of the device
Example
var params = {
     devicetype : 1 // or room or device
}

gladys.television.volumeUp(params)

gladys.room.get

This function return all rooms
gladys.room.get(options: Object): Array<rooms>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.take integer The number of rooms to return (optional)
options.skip integer The number of rooms to skip (optional)
Returns
Array<rooms>: rooms
Example
var options = {
     take: 50,
     skip: 0
}
gladys.room.get(options)
     .then(function(rooms){
         // do something
     })

Time

gladys.time.isInTimeRange

This function return true or false if current time is in the provided time range
gladys.time.isInTimeRange(options: any, option: Object): boolean
Parameters
Name Type Description
options any
Name Type Description
option Object
Parameters properties
Name Type Description
option.start string Beginning of the interval for validation (HH:MM:SS)
option.end string End of the interval for validation (HH:MM:SS)
Returns
boolean: isInTimeRange
Example
var option = {
    start: '10:00:00',
    end: '15:00:00'
};

gladys.time.isInTimeRange(option)
     .then(function(isInTimeRange){
         if(isInTimeRange){
             //The time is within the given range.
         }else{
             //The time is not in the given range.
         }
     });

gladys.time.isItAM

This function return true or false, test if it's morning.
gladys.time.isItAM(options: any, house: Object): House
Parameters
Name Type Description
options any
Name Type Description
house Object
Parameters properties
Name Type Description
house.house integer The id of the house
Returns
House: house
Example
var house = {
    house: '1'
};

gladys.time.isItAM(house)
     .then(function(isItAM){
         if(isItAM){
             //The time in the selected house is morning.
         }else{
             //The time in the selected house is not morning.
         }
     });

gladys.time.isItEvening

This function return true or false, test if it's evening.
gladys.time.isItEvening(options: any, house: Object): House
Parameters
Name Type Description
options any
Name Type Description
house Object
Parameters properties
Name Type Description
house.house integer The id of the house
Returns
House: house
Example
var house = {
    house: '1'
};

gladys.time.isItEvening(house)
     .then(function(isItEvening){
         if(isItEvening){
             //The time in the selected house is evening.
         }else{
             //The time in the selected house is not evening.
         }
     });

gladys.time.isItNight

This function return true or false, test if it's night.
gladys.time.isItNight(options: any, house: Object): House
Parameters
Name Type Description
options any
Name Type Description
house Object
Parameters properties
Name Type Description
house.house integer The id of the house
Returns
House: house
Example
var house = {
    house: '1'
};

gladys.time.isItNight(house)
     .then(function(isItNight){
         if(isItNight){
             //The time in the selected house is night.
         }else{
             //The time in the selected house is not night.
         }
     });

gladys.time.isItPM

This function return true or false, test if it's afternoon.
gladys.time.isItPM(options: any, house: Object): House
Parameters
Name Type Description
options any
Name Type Description
house Object
Parameters properties
Name Type Description
house.house integer The id of the house
Returns
House: house
Example
var house = {
    house: '1'
};

gladys.time.isItPM(house)
     .then(function(isItPM){
         if(isItPM){
             //The time in the selected house is afternoon.
         }else{
             //The time in the selected house is not afternoon.
         }
     });

Weather

gladys.weather.get

This function return weather of location
gladys.weather.get(options: Object): results
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.latitude float The latitude where you want the weather
options.longitude float The longitude where you want the weather
options.offset integer (in hour) If you want to get the weather in the future
Returns
results: results
Example
var options = {
     latitude: 42,
     longitude: 43,
     offset: 1
}

gladys.weather.get(options)
     .then(function(results){
         // do something
     })

gladys.deviceState.getFiltered

This function return all deviceState filtered by date
gladys.deviceState.getFiltered(options: Object): Array<deviceStates>
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.threshold integer The percentage reduction of the number of states
options.startDate Date The date from which you want deviceState
options.endDate Date The date until which you want deviceState
Returns
Array<deviceStates>: deviceStates
Example
var options = {
     threshold: 50,
     startDate: 2018-08-27 8:29:13,
     endDate: 2018-08-28 8:29:13
}
gladys.deviceState.getFiltered(options)
     .then(function(deviceStates){
         // do something
     })

gladys.deviceType.getByTag

This function is useful to find deviceType by tag
gladys.deviceType.getByTag(options: Object): Array
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.tag String string or array of tags
Returns
Array: Array of deviceTypes
Example
var options = {
   tag: ['light']
};

gladys.deviceType.getByTag(options)
     .then((deviceTypes) => {
        // deviceTypes is an array of deviceTypes
     })
     .catch((err) => {
         // something bad happened ! :/
     });

gladys.event.purgeByEventType

This function purge all events on a specific eventtype code and older than days
gladys.event.purgeByEventType(options: Object): event
Parameters
Name Type Description
options Object
Parameters properties
Name Type Description
options.eventtype integer The code of eventtype we want to purge
options.days integer The days we want to keep for this kind of event (optionnal)
Returns
event: event
Example
var options = {
     days: 2,
     eventtype: 'devicetype-new-value'
}
gladys.event.purgeByEventType(options)
     .then(function(events){
         // do something
     })

gladys.location.getBydateRange

This function return all locations between two dates
gladys.location.getBydateRange(dates: any): Array<locations>
Parameters
Name Type Description
dates any
Returns
Array<locations>: locations
Example
gladys.lacation.getByRange({start: {Date}, end: {Date})
     .then(function(locations){
         // do something
     })

gladys.module.getMethods

this function returns a list of methods passed in parameters with a true or false value if they are exposed by a module.
gladys.module.getMethods(params: any, module: string, service: string, methods: array): array
Parameters
Name Type Description
params any
Name Type Description
module string The module slug
Name Type Description
service string The name of the gladys api service, like 'television', 'music', ... (option)
Name Type Description
methods array the module's method(s) you want to test
Returns
array: data
Example
var params = {
'module' :"livebox",
'service':"television",
'methods' :["getState", "setChannel", "getChannel", "setMuted", "getMuted"]
};

gladys.module.getMethods(params)
     .then((data) => {
         var availableMethods = data.data
         
     })
     .catch((err) => {
         // something bad happened ! :/
     });

The structure of availableMethods is then as follows:
{
 getState: true,
 setChannel: true,
 getChannel: false,
 setMuted: true,
 getMuted: false
 }

gladys.television.fastForward

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.fastForward(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.fastForward(params)

gladys.television.pause

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.pause(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.pause(params)

gladys.television.play

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.play(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.play(params)

gladys.television.programMinus

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.programMinus(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.programMinus(params)

gladys.television.programPlus

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.programPlus(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.programPlus(params)

gladys.television.programVod

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.programVod(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.programVod(params)

gladys.television.rewind

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.rewind(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.rewind(params)

gladys.television.stop

You can put the devicetype attribute OR the room attribute to determine in which room you want to control the television/which precise deviceType is playing.
gladys.television.stop(params: Object)
Parameters
Name Type Description
params Object
Parameters properties
Name Type Description
params.devicetype Integer The id of the deviceType
params.room Integer The id of the room
Example
var params = {
     devicetype : 1 // or room
}

gladys.television.stop(params)