lavva.exalushome.extalife
v2.0.107
Published
Library implementing communication and abstraction layers for ExtaLife API in ExalusHome system
Downloads
411
Readme
ExalusHome ExtaLife library for Lavva
ExtaLife library is a part of exalushome-library that allows you to manage ExtraLife protocol devices connected to TR7 controller.
Library installation:
If you want to use this library in any JavaScript or TypeScript project you can use npm to install it as package from npm repository. For that you will have to use command:
npm install lavva.exalushome.extalife
or
yarn add lavva.exalushome.extalife
Initialization:
If you have installed this package then you have to initialize this library first before usage. To do this, you have to call:
import { ExtaLifeService } from 'lavva.exalushome.extalife/build/js/ExtaLife';
ExtaLifeService.Init();
Getting ExtaLifeService:
The library is based on the DI of exalushome-library, so you need to load the base service from the API, then you can load ExtaLife Device Services.
const extaLifeService = Api.Get<ExtaLifeService>(ExtaLifeService);
Getting services of the device:
Getting device services is similar to getting any services from exalushome-library. To get any device service that is registered in dependency container you have to use Generic parameter of requested service and reference (name) of service that you want to use, some methods allow to load service for requested device so in this cases you need to put a device as reference.
To get any service that coud handle ExtaLife device functions You can use followed methods of ExtaLifeService:
Getting device service by type:
//Getting device service - general construction, in <IDeviceConfigService>(DeviceConfigService) we should put service that we want to load.
const deviceService = await extaLifeService.GetDeviceServiceByServiceTypeAsync<IDeviceConfigService>(DeviceConfigService)
//Getting device service - example of Rck21ConfigService
const configService = await extaLifeService.GetDeviceServiceByServiceTypeAsync<IRck21ConfigService>(Rck21ConfigService)
Getting device service by IDevice reference:
//Getting IDevice by GUID (RCK-21)
const device = await devicesApi.GetDevice("bf5545ca-8bca-4364-a281-49676d307432")
//Getting configuration service by IDevice reference.
const configService = await extaLifeService.GetDeviceServiceAsync<IRck21ConfigService>(device, Rck21ConfigService);
A given device can support several services, we can get all supported services by method below using IDevice reference - functions returns array of supported services, if no service is supported then we get an empty array.
//Getting IDevice by GUID (RCK-21)
const device = await devicesApi.GetDevice("bf5545ca-8bca-4364-a281-49676d307432")
//Getting array of configuration services by IDevice reference.
const configServices = await extaLifeService.GetAllDeviceServicesAsync(device);
We can check if given service is supported by any device:
//Getting IDevice by GUID (RCK-21)
const device = await devicesApi.GetDevice("bf5545ca-8bca-4364-a281-49676d307432")
//Checking if some service is supported, device and service reference as parameter.
const isSupportedRck21ConfigService = extaLifeService.IsDeviceServiceSupported(device, Rck21ConfigService)
Currently suported device services
- IRck21ConfigService - configuration service for RCK-21 reed switch device
Using device service
Every device service have some unique methods to do some actions with ExtaLife device, method can change configs, get current settings of devices etc. Methods can take different parameters depending on the model of the device and functionality. Documentation for each service is available as a readme in the service catalogs: src/Devices/DeviceServices/service_name