UNPKG

node-red-contrib-home-assistant-websocket

Version:
137 lines (136 loc) 3.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = [ { version: 0, up: (schema) => { const newSchema = { ...schema, version: 0, }; return newSchema; }, }, { // entity_id moved from the data property to its on property version: 1, up: (schema) => { const newSchema = { ...schema, version: 1, }; try { const data = JSON.parse(schema.data); if (data.entity_id) { newSchema.entityId = data.entity_id; delete data.entity_id; newSchema.data = !Object.keys(data).length ? '' : JSON.stringify(data); } else { newSchema.entityId = ''; } } catch (e) { } return newSchema; }, }, { version: 2, up: (schema) => { const newSchema = { ...schema, version: 2, outputProperties: [], }; if (schema.output_location_type !== 'none') { newSchema.outputProperties = [ { property: schema.output_location, propertyType: schema.output_location_type, value: '', valueType: 'data', }, ]; } return newSchema; }, }, { version: 3, up: (schema) => { const newSchema = { ...schema, version: 3, queue: 'none', }; return newSchema; }, }, { version: 4, up: (schema) => { const newSchema = { ...schema, version: 4, target: { entityId: (schema === null || schema === void 0 ? void 0 : schema.entityId) ? schema.entityId .split(',') .map((e) => e.trim()) : [], areaId: [], deviceId: [], }, domain: schema.service_domain, mergeContext: schema.mergecontext, entityId: undefined, service_domain: undefined, mergecontext: undefined, }; return newSchema; }, }, { version: 5, up: (schema) => { var _a, _b, _c; const newSchema = { ...schema, version: 5, areaId: (_a = schema.target) === null || _a === void 0 ? void 0 : _a.areaId, deviceId: (_b = schema.target) === null || _b === void 0 ? void 0 : _b.deviceId, entityId: (_c = schema.target) === null || _c === void 0 ? void 0 : _c.entityId, target: undefined, }; return newSchema; }, }, { version: 6, up: (schema) => { const newSchema = { ...schema, version: 6, floorId: [], labelId: [], }; if (schema.domain || schema.service) { newSchema.action = `${schema.domain}.${schema.service}`; } return newSchema; }, }, { version: 7, up: (schema) => { const newSchema = { ...schema, version: 7, blockInputOverrides: false, }; return newSchema; }, }, ];