UNPKG

node-red-contrib-home-assistant-websocket

Version:
116 lines (115 loc) 3.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const const_1 = require("../../common/const"); exports.default = [ { version: 0, up: (schema) => { const newSchema = { ...schema, version: 0, }; return newSchema; }, }, { version: 1, up: (schema) => { const newSchema = { ...schema, version: 1, inputs: 1, enableInput: true, }; return newSchema; }, }, { version: 2, up: (schema) => { var _a; const newSchema = { ...schema, version: 2, }; if (schema.entityidfiltertype === 'substring' && ((_a = schema.entityid) === null || _a === void 0 ? void 0 : _a.includes(','))) { newSchema.entityidfiltertype = 'list'; newSchema.entityid = schema.entityid .split(',') .map((e) => e.trim()) .filter((e) => e.length > 0); } return newSchema; }, }, { version: 3, up: (schema) => { const newSchema = { ...schema, version: 3, entityId: schema.entityid, entityIdType: schema.entityidfiltertype, debugEnabled: schema.debugenabled, customOutputs: schema.customoutputs, outputInitially: schema.outputinitially, stateType: schema.state_type, exposeAsEntityConfig: '', }; newSchema.entityid = undefined; newSchema.entityidfiltertype = undefined; newSchema.debugenabled = undefined; newSchema.customoutputs = undefined; newSchema.outputinitially = undefined; newSchema.state_type = undefined; return newSchema; }, }, { version: 4, up: (schema) => { const newSchema = { ...schema, version: 4, }; if (schema.stateType === undefined) { newSchema.stateType = 'str'; } return newSchema; }, }, { version: 5, up: (schema) => { const newSchema = { ...schema, version: 5, entities: [], entityId: undefined, entityIdType: undefined, }; const entitites = { [const_1.IdSelectorType.Entity]: [], [const_1.IdSelectorType.Substring]: [], [const_1.IdSelectorType.Regex]: [], }; switch (schema.entityIdType) { case 'list': entitites[const_1.IdSelectorType.Entity] = schema.entityId; break; case 'exact': entitites[const_1.IdSelectorType.Entity] = [schema.entityId]; break; case 'substring': entitites[const_1.IdSelectorType.Substring] = [schema.entityId]; break; case 'regex': entitites[const_1.IdSelectorType.Regex] = [schema.entityId]; break; } newSchema.entities = entitites; return newSchema; }, }, ];