Added support for WRT-10 as a Device Automation
This commit is contained in:
parent
36e5c62b4f
commit
5a21290364
8 changed files with 174 additions and 22 deletions
|
|
@ -22,12 +22,29 @@ class DeviceRegistry {
|
|||
outputDevices = {};
|
||||
/** @private @type {import('types/DeviceRegistry').OutputDevices} */
|
||||
sceneDevices = {};
|
||||
/** @private @type {import('types/DeviceRegistry').InputDevices} */
|
||||
inputDevices = {};
|
||||
|
||||
/** @param device {import('./types/ApiSite').Device} */
|
||||
addPhysicalDevice(device) {
|
||||
this.devices[device.deviceId] = device;
|
||||
}
|
||||
|
||||
/** @param inputDevice {import('types/DeviceRegistry').InputDevice} */
|
||||
addInputDevice(inputDevice) {
|
||||
this.inputDevices = {
|
||||
...this.inputDevices,
|
||||
[inputDevice.uniqueId]: inputDevice,
|
||||
};
|
||||
|
||||
logger.verbose(
|
||||
`Added/updated input device: ${JSON.stringify(inputDevice)}. ${
|
||||
Object.keys(this.inputDevices).length
|
||||
} output devices in total.`,
|
||||
);
|
||||
this.outputUniqueIdByBleOutputAddress[`${inputDevice.bleOutputAddress}_${inputDevice.input}`] = inputDevice.uniqueId;
|
||||
};
|
||||
|
||||
/** @param outputDevice {import('types/DeviceRegistry').OutputDevice} */
|
||||
addOutputDevice(outputDevice) {
|
||||
if (outputDevice.hiddenFromIntegrations || outputDevice.hiddenFromRoomList) {
|
||||
|
|
@ -84,6 +101,7 @@ class DeviceRegistry {
|
|||
clearPlejdDevices() {
|
||||
this.devices = {};
|
||||
this.outputDevices = {};
|
||||
this.inputDevices = {};
|
||||
this.outputDeviceUniqueIdsByRoomId = {};
|
||||
this.outputUniqueIdByBleOutputAddress = {};
|
||||
}
|
||||
|
|
@ -100,6 +118,13 @@ class DeviceRegistry {
|
|||
return Object.values(this.outputDevices);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {import('./types/DeviceRegistry').InputDevice[]}
|
||||
*/
|
||||
getAllInputDevices() {
|
||||
return Object.values(this.inputDevices);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {import('./types/DeviceRegistry').OutputDevice[]}
|
||||
*/
|
||||
|
|
@ -119,11 +144,23 @@ class DeviceRegistry {
|
|||
return this.outputDevices[uniqueOutputId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} uniqueInputId
|
||||
*/
|
||||
getInputDevice(uniqueInputId) {
|
||||
return this.inputDevices[uniqueInputId];
|
||||
}
|
||||
|
||||
/** @returns {import('./types/DeviceRegistry').OutputDevice} */
|
||||
getOutputDeviceByBleOutputAddress(bleOutputAddress) {
|
||||
return this.outputDevices[this.outputUniqueIdByBleOutputAddress[bleOutputAddress]];
|
||||
}
|
||||
|
||||
/** @returns {import('./types/DeviceRegistry').InputDevice} */
|
||||
getInputDeviceByBleOutputAddress(bleInputAddress, inputButton) {
|
||||
return this.inputDevices[this.outputUniqueIdByBleOutputAddress[`${bleInputAddress}_${inputButton}`]];
|
||||
}
|
||||
|
||||
/** @returns {string[]} */
|
||||
getOutputDeviceIdsByRoomId(roomId) {
|
||||
return this.outputDeviceUniqueIdsByRoomId[roomId];
|
||||
|
|
@ -133,6 +170,10 @@ class DeviceRegistry {
|
|||
return (this.outputDevices[uniqueOutputId] || {}).name;
|
||||
}
|
||||
|
||||
getInputDeviceName(uniqueInputId) {
|
||||
return (this.inputDevices[uniqueInputId] || {}).name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string } deviceId The physical device serial number
|
||||
* @return {import('./types/ApiSite').Device}
|
||||
|
|
@ -171,6 +212,11 @@ class DeviceRegistry {
|
|||
return `${deviceId}_${outputIndex}`;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
getUniqueInputId(deviceId, inputIndex) {
|
||||
return `${deviceId}_${inputIndex}`;
|
||||
}
|
||||
|
||||
/** @param apiSite {import('./types/ApiSite').ApiSite} */
|
||||
setApiSite(apiSite) {
|
||||
this.apiSite = apiSite;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue