🔀 Merge branch 'ha-load-options' of https://github.com/pemontto/n8n into pemontto-ha-load-options

This commit is contained in:
Jan Oberhauser
2021-12-11 17:54:20 +01:00
5 changed files with 95 additions and 8 deletions

View File

@@ -6,7 +6,9 @@ import {
ICredentialsDecrypted,
ICredentialTestFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
NodeCredentialTestResult,
@@ -52,6 +54,8 @@ import {
} from './CameraProxyDescription';
import {
getHomeAssistantEntities,
getHomeAssistantServices,
homeAssistantApiRequest,
} from './GenericFunctions';
@@ -169,9 +173,29 @@ export class HomeAssistant implements INodeType {
status: 'OK',
message: 'Authentication successful!',
};
},
},
loadOptions: {
async getAllEntities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await getHomeAssistantEntities.call(this);
},
async getCameraEntities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await getHomeAssistantEntities.call(this, 'camera');
},
async getDomains(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await getHomeAssistantServices.call(this);
},
async getDomainServices(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const currentDomain = this.getCurrentNodeParameter('domain') as string;
if (currentDomain) {
return await getHomeAssistantServices.call(this, currentDomain);
} else {
return [];
}
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {