UNPKG

node-red-contrib-home-assistant-websocket

Version:
164 lines (163 loc) 5.58 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, state_type: schema.state_type !== undefined ? schema.state_type : 'str', halt_if_type: schema.halt_if_type !== undefined ? schema.halt_if_type : 'str', halt_if_compare: schema.halt_if_compare !== undefined ? schema.halt_if_compare : 'is', }; return newSchema; }, }, { // CHANGES: // - if state changed to send true condition to the first out and false to the second version: 1, up: (schema) => { const newSchema = { ...schema, version: 1, ignorePrevStateNull: false, ignorePrevStateUnknown: false, ignorePrevStateUnavailable: false, ignoreCurrentStateUnknown: false, ignoreCurrentStateUnavailable: false, }; return newSchema; }, }, { version: 2, up: (schema) => { const newSchema = { ...schema, version: 2, for: schema.for !== undefined ? schema.for : '0', forType: schema.forType || 'num', forUnits: schema.forUnits || 'minutes', }; return newSchema; }, }, { version: 3, up: (schema) => { const newSchema = { ...schema, version: 3, outputProperties: [ { property: 'payload', propertyType: 'msg', value: '', valueType: 'entityState', }, { property: 'data', propertyType: 'msg', value: '', valueType: 'eventData', }, { property: 'topic', propertyType: 'msg', value: '', valueType: 'triggerId', }, ], }; return newSchema; }, }, { version: 4, up: (schema) => { var _a; const newSchema = { ...schema, version: 4, }; if (schema.entityidfiltertype === 'substring' && ((_a = schema.entityidfilter) === null || _a === void 0 ? void 0 : _a.includes(','))) { newSchema.entityidfiltertype = 'list'; newSchema.entityidfilter = schema.entityidfilter .split(',') .map((e) => e.trim()) .filter((e) => e.length > 0); } return newSchema; }, }, { version: 5, up: (schema) => { const newSchema = { ...schema, version: 5, entityId: schema.entityidfilter, entityIdType: schema.entityidfiltertype, ifState: schema.haltifstate, ifStateType: schema.halt_if_type, ifStateOperator: schema.halt_if_compare, outputInitially: schema.outputinitially, stateType: schema.state_type, outputOnlyOnStateChange: schema.output_only_on_state_change, exposeAsEntityConfig: '', }; newSchema.entityidfilter = undefined; newSchema.entityidfiltertype = undefined; newSchema.haltifstate = undefined; newSchema.halt_if_type = undefined; newSchema.halt_if_compare = undefined; newSchema.outputinitially = undefined; newSchema.state_type = undefined; newSchema.output_only_on_state_change = undefined; newSchema.exposeToHomeAssistant = undefined; newSchema.haConfig = undefined; return newSchema; }, }, { version: 6, up: (schema) => { const newSchema = { ...schema, version: 6, 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; }, }, ];