import { Logger } from '../logger'; import { CertificateStorage } from '../certificate-storage'; import { Observable } from 'rxjs'; import { AbstractBshcClient } from './abstract-bshc-client'; import { BshbResponse } from '../bshb-response'; import { BshbCallOptions } from '../bshb-call-options'; import { BinaryResponse } from '../model/binary-response'; /** * This client contains some basic calls which are available to contact Bosch Smart Home Controller (BSHC) * the method {@link BshcClient#call} is not a predefined call and allows to specify it in more detail * * @author Christopher Holomek * @since 26.09.2019 */ export declare class BshcClient extends AbstractBshcClient { private certificateStorage; private static COMMON_PORT; private static PATH_PREFIX; /** * Create a new instance of the Bosch Smart Home Controller Client * * @param host * host name / ip address of BSHC * @param certificateStorage * instance of certificate storage * @param logger * logger to use * @param ignoreServerCertificateCheck * Ignores the server certificate. */ constructor(host: string, certificateStorage: CertificateStorage, logger: Logger, ignoreServerCertificateCheck: boolean); private getOptions; /** * Get information about BSHC * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getInformation(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all rooms stored * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getRooms(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get a specific room * @param id * identifier of a room * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getRoom(id: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Same as {@link BshcClient#getDevice()} * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getDevices(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all devices * @return bshb response object */ getDevice(): Observable>; /** * Get a specified device * @param deviceId * identifier of the device interested in. If undefined all devices are returned * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getDevice(deviceId: string | undefined, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all available service ids of a specified device * @param deviceId identifier of a device * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return a string array which contains all service ids of a device */ getDeviceServiceIds(deviceId: string, bshbCallOptions?: BshbCallOptions): Observable; /** * Get supported device types * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getSupportedDeviceTypes(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get services of all devices * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getDevicesServices(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all services of all devices * @return bshb response object */ getDeviceServices(): Observable>; /** * Get all services of a specified device * @param deviceId identifier of the relevant device * @return bshb response object */ getDeviceServices(deviceId: string): Observable>; /** * Get all services of a specified device * @param deviceId identifier of the relevant device * @param serviceId 'all' to get all services * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getDeviceServices(deviceId: string | undefined, serviceId: 'all', bshbCallOptions?: BshbCallOptions): Observable>; /** * Get a specified service of a specified device * @param deviceId identifier of the relevant device * @param serviceId identifier of a service * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getDeviceServices(deviceId: string | undefined, serviceId: string | undefined, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all automations * @return bshb response object */ getAutomations(): Observable>; /** * Get a specific automation * @return bshb response object */ getAutomations(automationId: string): Observable>; /** * Get all automations or a specific automation with the specified options. * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getAutomations(automationId?: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Update an existing or create a new automation with the specified id and data. * @param automationId * Identifier of existing or new automation * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ setAutomation(automationId: string, data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Trigger the specified automation * @param automationId * identifier of an automation * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ triggerAutomation(automationId: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all scenarios * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getScenarios(bshbCallOptions?: BshbCallOptions): Observable>; /** * Trigger the specified scenario * @param scenarioId * identifier of a scenario * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ triggerScenario(scenarioId: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get the user defined state with the specified id or all user defined state if the id is undefined. * * @param id * (optional) identifier of the user defined state * @param bshbCallOptions * (optional) define custom headers, etc. Some values may be overwritten. E.g. host * return bshb response object */ getUserDefinedStates(id?: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Set the state of a user defined state identified by the specified id. * * @param id * identifier of the user defined state * @param state * activate or deactivate the state * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * return bshb response object */ setUserDefinedState(id: string, state: boolean, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get alarm state * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getAlarmState(bshbCallOptions?: BshbCallOptions): Observable>; /** * Set alarm state * @param armed * true if alarm should be armed. Otherwise false * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ setAlarmState(armed: boolean, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get alarm state * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getPresenceSimulation(bshbCallOptions?: BshbCallOptions): Observable>; /** * Set alarm state * @param enable * true if presence is enabled. Otherwise false * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ setPresenceSimulation(enable: boolean, bshbCallOptions?: BshbCallOptions): Observable>; /** * Tell BSHC to set a new value for a specified state. Use the device service path to identify the state * @param path * device service path to use * @param data * data to send. Will be converted to json. It must contain @type otherwise BSHC will not understand the request * (see https://apidocs.bosch-smarthome.com/local/). * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ putState(path: string, data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all connected clients * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getClients(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all messages * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getMessages(bshbCallOptions?: BshbCallOptions): Observable>; /** * Delete all specified message ids * @param ids * an array of identifier of messages * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ deleteMessages(ids: string[], bshbCallOptions?: BshbCallOptions): Observable>; /** * Get the specified message * @param id * identifier of a message * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ getMessage(id: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Delete a specified message * @param id * identifier of a message * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host * @return bshb response object */ deleteMessage(id: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get status of windows/doors * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ getOpenWindows(bshbCallOptions?: BshbCallOptions): Observable>; /** * Create a new climate schedule for the specified device. * @param deviceId * identifier of the device to get the schedules from * @param data * schedule data to use * * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ createClimateSchedule(deviceId: string, data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all available climate schedules for a device * @param deviceId * identifier of the device to get the schedules from * @param type * type of schedule. At the moment "HEATING" or "COOLING". "HEATING" is default. * * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ getClimateSchedules(deviceId: string, type?: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Update an existing climate schedule for the specified device. * @param deviceId * identifier of the device to get the schedules from * @param data * schedule data to use * * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ updateClimateSchedule(deviceId: string, data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Activate the specified climate schedule for the specified device. * @param deviceId * identifier of the device to get the schedules from * @param id * identifier of the schedule to activate * * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ activateClimateSchedules(deviceId: string, id: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Delete an existing climate schedule for the specified device. * @param deviceId * identifier of the device to get the schedules from * @param id * identifier of the schedule to remove * * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ deleteClimateSchedule(deviceId: string, id: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get all available climate templates * @param type * type of schedule. At the moment "HEATING" or "COOLING". "HEATING" is default. * * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ getClimateTemplates(type?: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Subscribe to listen to notifications of bshc * * @return an object which contains 'result' which is the subscriptionId and 'jsonrpc' which is the json-rpc version */ subscribe(): Observable>; /** * Start long polling after subscription. Request is kept open for 30 seconds. * * @param subscriptionId * identifier from subscription request * * @param subscriptionId */ longPolling(subscriptionId: string): Observable>; /** * Start long polling after subscription. Time a request is kept open can be specified by timeout value. * This time is transmitted to BSHC and will be considered by it. * Actual client timeout will be extended by 1s in favour of network delays. * * @param subscriptionId * identifier from subscription request * @param timeout * time (ms) for how long the request is kept open. Default is 30000 ms */ longPolling(subscriptionId: string, timeout: number): Observable>; /** * Start long polling after subscription. Time a request is kept open can be specified by timeout value. * This time is transmitted to BSHC and will be considered by it. * Actual client timeout will be extended by 1s in favour of network delays. * * @param subscriptionId * identifier from subscription request * @param timeout * time (ms) for how long the request is kept open. Default is 30000 ms * @param delay * delay (ms) for how the timeout is extended. So timeout + delay = connection timeout. Default is 1000 ms */ longPolling(subscriptionId: string, timeout: number, delay: number): Observable>; /** * Stop subscription * * @param subscriptionId * identifier from subscription request */ unsubscribe(subscriptionId: string): Observable>; /** * Get intrusion detection system state */ getIntrusionDetectionSystemState(bshbCallOptions?: BshbCallOptions): Observable>; /** * Arm intrusion detection system with last active profile */ armIntrusionDetectionSystem(): Observable>; /** * Activate intrusion detection system with specified profile * @param profileId * profile to use *@param bshbCallOptions * additional options for http call */ armIntrusionDetectionSystem(profileId: number, bshbCallOptions?: BshbCallOptions): Observable>; /** * Disarm intrusion detection system * @param bshbCallOptions * additional options for http call */ disarmIntrusionDetectionSystem(bshbCallOptions?: BshbCallOptions): Observable>; /** * Mute intrusion detection system * @param bshbCallOptions * additional options for http call */ muteIntrusionDetectionSystem(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get water alarm configuration * * @param bshbCallOptions * additional options for http call */ getWaterAlarm(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get water alarm configuration * * @param bshbCallOptions * additional options for http call */ getWaterAlarmConfiguration(bshbCallOptions?: BshbCallOptions): Observable>; /** * Mute alarm * * @param bshbCallOptions * additional options for http call */ muteWaterAlarm(bshbCallOptions?: BshbCallOptions): Observable>; /** * Update water alarm * * @param data * data to set. Check {@link #getAirPurityGuardian} for values. * @param bshbCallOptions * additional options for http call */ updateWaterAlarm(data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get air purity guardian configuration * * @param bshbCallOptions * additional options for http call */ getAirPurityGuardian(bshbCallOptions?: BshbCallOptions): Observable>; /** * Update air purity guardian configuration * * @param id * Identifier of the air purity guardian to update * @param data * data to set. Check {@link #getAirPurityGuardian} for values. * @param bshbCallOptions * additional options for http call */ updateAirPurityGuardian(id: string, data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get motion lights configuration * * @param bshbCallOptions * additional options for http call */ getMotionLights(bshbCallOptions?: BshbCallOptions): Observable>; /** * Update motion lights configuration * * @param id * Identifier of the motion light to update * @param data * data to set. Check {@link #getAirPurityGuardian} for values. * @param bshbCallOptions * additional options for http call */ updateMotionLights(id: string, data: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get the status of backup. So far the values I could see are: * NONE, IN_PROGRESS, READY and ERROR. * * @param bshbCallOptions * additional options for http call */ getBackupStatus(bshbCallOptions?: BshbCallOptions): Observable>; /** * Create the backup on the bshc. This is only possible if the client is not a restricted client, which is the * default behavior of this extension when creating a client. The client type can only be adjusted in the bosch * app so far. If a backup is created it can be downloaded via getBackup. You cannot create another backup until * you deleted the existing backup. * @param systemPassword * This call requires the system password of the bshc. * @param encryptionPassword * password used to encrypt the backup. If not specified the systemPassword is used. * @param bshbCallOptions * additional options for http call */ createBackup(systemPassword: string, encryptionPassword?: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get the backup file as byte array. Furthermore, the result also includes some information like the filename. * This method cannot be called in case the backup status is IN_PROGRESS. * @param bshbCallOptions * additional options for http call */ getBackup(bshbCallOptions?: BshbCallOptions): Observable>; /** * Delete the backup file * @param bshbCallOptions * additional options for http call */ deleteBackup(bshbCallOptions?: BshbCallOptions): Observable>; /** * Get the status of restore. So far the values I could see are: * NONE, BACKUP_UPLOADED, RESTORE_AUTHORIZED, VALIDATING, RESTORING, RESTORED, RESTORED_OTHER_SHC, ERROR. * * @param bshbCallOptions * additional options for http call */ getRestoreStatus(bshbCallOptions?: BshbCallOptions): Observable>; /** * Upload a restore file specified as a buffer to bshc of a previous backup file. * The restore process is not started by this call. * * @param data * restore file buffer data * @param bshbCallOptions * additional options for http call */ uploadRestoreFile(data: Buffer, bshbCallOptions?: BshbCallOptions): Observable>; /** * Delete the restore file * * @param bshbCallOptions * additional options for http call */ deleteRestoreFile(bshbCallOptions?: BshbCallOptions): Observable>; /** * Start the restore process * * @param encryptionPassword * password to with which the backup file was created before * @param bshbCallOptions * additional options for http call */ startRestoreProcess(encryptionPassword: string, bshbCallOptions?: BshbCallOptions): Observable>; /** * Get the status of the partner restore. This allows to see, which partner integrations could be restored or not. * This call is only allowed after a successful restoring process or in other words when the restore status is * RESTORED or RESTORED_OTHER_SHC * * @param bshbCallOptions * additional options for http call */ getPartnerRestoreStatus(bshbCallOptions?: BshbCallOptions): Observable>; /** * Not defined call to BSHC in case something is missing here * @param port * port to use * @param method * HTTP method to use * @param path * url path to use * @param data * data to send. Will be converted to json. It must contain @type otherwise BSHC will not understand the request. * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ call(port: number, method: string, path: string, data?: any, bshbCallOptions?: BshbCallOptions): Observable>; /** * Not defined privileged call to BSHC in case something is missing here. Privileged calls requires the * systemPassword, which is included the request header. Only use if it is really necessary. * @param port * port to use * @param method * HTTP method to use * @param path * url path to use * @param data * data to send. Will be converted to json. It must contain @type otherwise BSHC will not understand the request. * @param bshbCallOptions * define custom headers, etc. Some values may be overwritten. E.g. host */ privilegedCall(port: number, method: string, path: string, systemPassword: string, data?: any, bshbCallOptions?: BshbCallOptions): Observable>; }