Library to access Gigaset Elements API.
npm install gigaset-elements-api
// or
yarn add gigaset-elements-api
import { GigasetElementsApi } from "gigaset-elements-api";
const api = new GigasetElementsApi({
email: "username/email for accessing GE cloud",
password: "password of accessing GE cloud",
});
The constructor of the GigasetElementsApi
class acccepts the following configuration object:
{
// required
email: "<email>", // username/email for accessing GE cloud
password: "<password>", // password of accessing GE cloud
// optional
authorizeHours: 6, // defaults to 6, number of hours after which GE cloud needs reauthorization
requestLogger: (message: string) => void, // for logging all http requests
}
Check whether GE cloud is in maintenance mode and currently not available
api.isMaintenance(): Promise<boolean>
Retrive system health data.
api.getSystemHealth(): Promise<IGigasetElementsSystemHealth>
Retrieves base station and sensor data. Automatically handles authorization if required.
api.getBaseStations(): Promise<IBaseStationRoot>;
Retrieves elements, including sensor data (i.e. temperature for universal sensor). Automatically handles authorization if required.
api.getElements(): Promise<IElementRoot>;
Retrieves the most recent events that occured until a given point in time. Events are sorted by timestamp in descending order. Only the most recent limit
number of events will be returned.
api.getRecentEvents(until: Date | number, limit = 500): Promise<IEventRoot>;
Retrieves events that occured during a time period. Events are sorted by timestamp in descending order. Limit is applied from the end of the period.
api.getEvents(from: Date | number, to: Date | number, limit = 500): Promise<IEventRoot>
Utility method to retrieves all events that occured during a time period, using multiple requests if more than batchSize
events occured in this period. Events are sorted by timestamp in descending order. If to
is not specified, the current date will be used.
api.getAllEvents(from: Date | number, to?: Date | number, batchSize = 500): Promise<IEventsItem[]>
Sends a command for an endNode, i.e. "on" or "off" for plugs. Throws if the command is invalid (HTTP 400), i.e. when sending "off" to a plug that is already turned off.
api.sendCommand(baseStationId: string, endNodeId: string, commandName: string): Promise<void>;
Sets the setPoint for a thermostat. !completely untested due to lack of hardware!
api.setThermostat(baseStationId: string, endNodeId: string, setPoint: number): Promise<void>;
Turn user alarm (panic button) on or off,
api.setUserAlarm(on: boolean): Promise<void>;
Updates the active alarm mode.
setAlarmMode(baseStationId: string, mode: "away" | "home" | "night" | "custom"): Promise<void>
Authorize against the GE cloud. Retrieves and stores authorization cookie for further api requests. Usually this is done automatically by methods that need authorization like getRecentEvents
and doesn't neet to be called manually.
api.authorize(): Promise<true>;
Check whether authorization is due, i.e. last authorization was more than authorizeHours
ago. Usually this is only used internally.
api.needsAuth(): boolean;
-
The library was designed to fit my needs for an ioBroker adapter. If additional functionality is required please open an issue.
-
Event data in the Gigaset Elements cloud reaches back 1 month, and a maximum of 500 events can be retrieved per api call as per my tests.
So far the library has been tested with the following sensors, which have also test data available:
Sensor | Description |
---|---|
is01 | Siren |
um01 | Universal/Window/Door |
wd01 | Water |
sd01 | Smoke (only test alarms) |
sp01 | Plug v1 (sponsored by Voggl93) |
In addition definitions and test data for IP Phones (gp02) has been included.
npm test
// or with watch mode
npm run test:watch
npm run generate:merge-test-data
See also Test Data
This library would not be possible without the awsome work of https://github.com/ycardon/gigaset-elements-proxy and https://github.com/dynasticorpheus/gigasetelements-ha.
Hardware sponsors:
- Voggl93 (Plug v1)