UNPKG

iobroker.heatingcontrol

Version:
785 lines (654 loc) 95.8 kB
/* eslint-disable prefer-template */ "use strict"; const GetUsedRooms = require("./database.js").GetUsedRooms; const GetTranslation = require("./support_tools.js").GetTranslation; let parentAdapter; let SystemLanguage = "de"; //******************************************************************* // async function CreateDatapoints(adapter, language) { parentAdapter = adapter; SystemLanguage = language; parentAdapter.log.info("start CreateDatapoints"); try { //=================================================================================== await CreateDatapoint("LastProgramRun", "state", "value", "string", "", true, false); await CreateDatapoint("CurrentProfile", "state", "value", "number", "", true, true); await CreateDatapoint("HeatingPeriodActive", "state", "value", "boolean", "", true, true); await CreateDatapoint("PublicHolidyToday", "state", "value", "boolean", "", true, true); await CreateDatapoint("Present", "state", "value", "boolean", "", true, true); await CreateDatapoint("PartyNow", "state", "value", "boolean", "", true, true); await CreateDatapoint("GuestsPresent", "state", "value", "boolean", "", true, true); await CreateDatapoint("HolidayPresent", "state", "value", "boolean", "", true, true); await CreateDatapoint("VacationAbsent", "state", "value", "boolean", "", true, true); await CreateDatapoint("MaintenanceActive", "state", "value", "boolean", "", true, true); await CreateDatapoint("PowerInterruptionPeriodActive", "state", "value", "boolean", "", true, true); if (parentAdapter.config.UseActors) { await CreateDatapoint("ActorsOn", "state", "value", "number", "", true, false); } if (parentAdapter.config.UseFireplaceMode) { await CreateDatapoint("FireplaceModeActive", "state", "value", "boolean", "", true, true); } //=================================================================================== await CreateDatapoint("info", "channel", "", "string", "", true, false); await CreateDatapoint("info.UsedRooms", "state", "value", "string", "", true, false); await CreateDatapoint("info.TemperatureDecreaseMode", "state", "value", "string", "", true, false); await CreateDatapoint("info.ProfileType", "state", "value", "string", "", true, false); await CreateDatapoint("info.NumberOfProfiles", "state", "value", "number", "", true, false); await CreateDatapoint("info.NumberOfPeriods", "state", "value", "number", "", true, false); await CreateDatapoint("info.PublicHolidayLikeSunday", "state", "value", "boolean", "", true, false); await CreateDatapoint("info.UseMinTempPerRoom", "state", "value", "boolean", "", true, false); await CreateDatapoint("info.UseFixHeatingPeriod", "state", "value", "boolean", "", true, false); if (parentAdapter.config.UseFixHeatingPeriod) { await CreateDatapoint("info.FixHeatingPeriodStart", "state", "value", "string", "", true, false); await CreateDatapoint("info.FixHeatingPeriodEnd", "state", "value", "string", "", true, false); } //=================================================================================== await CreateDatapoint("Rooms", "channel", "", "string", "", true, false); for (let room = 0; room < parentAdapter.config.rooms.length; room++) { if (parentAdapter.config.rooms[room].isActive) { const key = "Rooms." + parentAdapter.config.rooms[room].name; await CreateDatapoint(key, "channel", "", "string", "", true, false); await CreateDatapoint(key + ".CurrentTarget", "state", "value", "number", "°C", true, false, "current target temperature"); await CreateDatapoint(key + ".ActiveTimeSlot", "state", "value", "number", "", true, false,"current timeslot in timeperiod"); await CreateDatapoint(key + ".CurrentTimePeriodFull", "state", "value", "string", "", true, false, "full name of current timeperiod"); await CreateDatapoint(key + ".CurrentTimePeriod", "state", "value", "number", "", true, false, "current overall timeperiod"); await CreateDatapoint(key + ".CurrentTimePeriodTime", "state", "value", "string", "", true, false, "start time of current timeperiod"); await CreateDatapoint(key + ".CurrentTimePeriodTemperature", "state", "level.temperature", "number", "°C", true, false, "target temperature of current timeperiod"); await CreateDatapoint(key + ".WindowIsOpen", "state", "value", "boolean", "", true, false); await CreateDatapoint(key + ".State", "state", "value", "string", "", true, false); await CreateDatapoint(key + ".TemperaturOverride", "state", "level.temperature", "number", "°C", true, true); await CreateDatapoint(key + ".TemperaturOverrideTime", "state", "level.timer", "string", "hh:mm", true, true); await CreateDatapoint(key + ".TemperaturOverrideRemainingTime", "state", "value", "number", "min", true, false); await CreateDatapoint(key + ".StatusLog", "state", "value", "string", "", true, false); await CreateDatapoint(key + ".isActive", "state", "value", "boolean", "", true, true); if (parentAdapter.config.ThermostatModeIfNoHeatingperiod == 1) { await CreateDatapoint(key + ".TemperatureIfNoHeatingPeriod", "state", "level.temperature", "number", "°C", true, true); } if (parentAdapter.config.UseMinTempPerRoom) { await CreateDatapoint(key + ".MinimumTemperature", "state", "level.temperature", "number", "°C", true, true); } //not used anymore //if (parseInt(parentAdapter.config.UseChangesFromThermostat) === 4) { //each room reparately // await CreateDatapoint(key + ".ChangesFromThermostatMode", "state", "value", "number", "", true, true); //} if (parseInt(parentAdapter.config.UseChangesFromThermostat) > 1) { await CreateDatapoint(key + ".ResetManual", "state", "button", "boolean", "", false, true); } if (parentAdapter.config.UseAddTempSensors) { await CreateDatapoint(key + ".TemperatureOffset", "state", "value", "number", "°C", true, true); } if (parseInt(parentAdapter.config.regulatorType) == 2) { await CreateDatapoint(key + ".Regulator.HysteresisOnOffset", "state", "value", "number", "°C", true, true); await CreateDatapoint(key + ".Regulator.HysteresisOffOffset", "state", "value", "number", "°C", true, true); } } } //=================================================================================== await CreateDatapoint("Profiles", "channel", "", "string", "", true, false); for (let profile = 1; profile <= parseInt(parentAdapter.config.NumberOfProfiles, 10); profile++) { const key = "Profiles." + profile; await CreateDatapoint(key, "channel", "", "string", "", true, false); await CreateDatapoint(key + ".ProfileName", "state", "value", "string", "", true, true); if (parseInt(parentAdapter.config.NumberOfProfiles, 10) > profile) { await CreateDatapoint(key + ".CopyProfile", "state", "button", "boolean", "", false, true); } for (let room = 0; room < parentAdapter.config.rooms.length; room++) { if (parentAdapter.config.rooms[room].isActive) { const id = key + "." + parentAdapter.config.rooms[room].name; await CreateDatapoint(id, "channel", "", "string", "", true, false); let id1 = id; if (parseInt(parentAdapter.config.NumberOfProfiles, 10) > profile) { await CreateDatapoint(id + ".CopyProfile", "state", "button", "boolean", "", false, true); } if (parseInt(parentAdapter.config.ProfileType, 10) === 1) { await CreateDatapoint(id1 + ".Mo-Su", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Mo-Su.Periods", "channel", "", "string", "", true, false); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Mo-Su.Periods." + period; await CreateStates4Period(id); } } else if (parseInt(parentAdapter.config.ProfileType, 10) === 2) { await CreateDatapoint(id1 + ".Mo-Fr", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Mo-Fr.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Mo-Fr.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Mo-Fr.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Sa-Su", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Sa-Su.Periods", "channel", "", "string", "", true, false); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Sa-Su.Periods." + period; await CreateStates4Period(id); } } else if (parseInt(parentAdapter.config.ProfileType, 10) === 3) { await CreateDatapoint(id1 + ".Mon", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Mon.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Mon.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Mon.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Tue", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Tue.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Tue.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Tue.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Wed", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Wed.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Wed.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Wed.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Thu", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Thu.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Thu.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Thu.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Fri", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Fri.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Fri.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Fri.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Sat", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Sat.Periods", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Sat.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Sat.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint(id1 + ".Sun", "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".Sun.Periods", "channel", "", "string", "", true, false); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Sun.Periods." + period; await CreateStates4Period(id); } } let decreaseMode = false; if (parseInt(parentAdapter.config.TemperatureDecrease) === 1) {// relative id1 += ".relative"; decreaseMode = true; } else if (parseInt(parentAdapter.config.TemperatureDecrease) === 2) {// absolutue id1 += ".absolute"; decreaseMode = true; } if (decreaseMode) { await CreateDatapoint(id1, "channel", "", "string", "", true, false); await CreateDatapoint(id1 + ".GuestIncrease", "state", "value", "number", "°C", true, true); await CreateDatapoint(id1 + ".PartyDecrease", "state", "value", "number", "°C", true, true); await CreateDatapoint(id1 + ".WindowOpenDecrease", "state", "value", "number", "°C", true, true); await CreateDatapoint(id1 + ".AbsentDecrease", "state", "value", "number", "°C", true, true); await CreateDatapoint(id1 + ".VacationAbsentDecrease", "state", "value", "number", "°C", true, true); if (parentAdapter.config.UseFireplaceMode) { await CreateDatapoint(id1 + ".FireplaceModeDecrease", "state", "value", "number", "°C", true, true); } } } } } //=================================================================================== //pittini vis if (parentAdapter.config.UseVisFromPittini) { await CreateDatapoint("vis", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes", "channel", "", "string", "", true, false); if (parseInt(parentAdapter.config.NumberOfProfiles, 10) > 1) { await CreateDatapoint("vis.ProfileTypes.CopyProfile", "state", "button", "boolean", "", false, true); await CreateDatapoint("vis.ProfileTypes.CopyProfileRoom", "state", "button", "boolean", "", false, true); } if (parseInt(parentAdapter.config.ProfileType, 10) === 1) { await CreateDatapoint("vis.ProfileTypes.Mo-Su", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Mo-Su.Periods", "channel", "", "string", "", true, false); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Mo-Su.Periods." + period; await CreateStates4Period(id); } } else if (parseInt(parentAdapter.config.ProfileType, 10) === 2) { await CreateDatapoint("vis.ProfileTypes.Mo-Fr", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Mo-Fr.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Mo-Fr.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Mo-Fr.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Sa-Su", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Sa-Su.Periods", "channel", "", "string", "", true, false); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Sa-Su.Periods." + period; await CreateStates4Period(id); } } else if (parseInt(parentAdapter.config.ProfileType, 10) === 3) { await CreateDatapoint("vis.ProfileTypes.Mon", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Mon.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Mon.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Mon.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Tue", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Tue.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Tue.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Tue.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Wed", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Wed.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Wed.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Wed.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Thu", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Thu.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Thu.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Thu.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Fri", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Fri.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Fri.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Fri.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Sat", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Sat.Periods", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Sat.CopyPeriods", "state", "button", "boolean", "", false, true); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Sat.Periods." + period; await CreateStates4Period(id); } await CreateDatapoint("vis.ProfileTypes.Sun", "channel", "", "string", "", true, false); await CreateDatapoint("vis.ProfileTypes.Sun.Periods", "channel", "", "string", "", true, false); for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = "vis.ProfileTypes.Sun.Periods." + period; await CreateStates4Period(id); } } await CreateDatapoint("vis.TempDecreaseValues", "channel", "", "string", "", true, false); await CreateDatapoint("vis.TempDecreaseValues.AbsentDecrease", "state", "value", "number", "°C", true, true); await CreateDatapoint("vis.TempDecreaseValues.GuestIncrease", "state", "value", "number", "°C", true, true); await CreateDatapoint("vis.TempDecreaseValues.PartyDecrease", "state", "value", "number", "°C", true, true); await CreateDatapoint("vis.TempDecreaseValues.VacationAbsentDecrease", "state", "value", "number", "°C", true, true); if (parentAdapter.config.UseFireplaceMode) { await CreateDatapoint("vis.TempDecreaseValues.FireplaceModeDecrease", "state", "value", "number", "°C", true, true); } await CreateDatapoint("vis.TempDecreaseValues.WindowOpenDecrease", "state", "value", "number", "°C", true, true); await CreateDatapoint("vis.RoomValues", "channel", "", "string", "", true, false); await CreateDatapoint("vis.RoomValues.MinimumTemperature", "state", "level.temperature", "number", "°C", true, true); await CreateDatapoint("vis.RoomValues.TemperaturOverride", "state", "level.temperature", "number", "°C", true, true); await CreateDatapoint("vis.RoomValues.TemperaturOverrideTime", "state", "value", "string", "hh:mm", true, true); await CreateDatapoint("vis.RoomValues.WindowIsOpen", "state", "value", "boolean", "", true, false); await CreateDatapoint("vis.RoomValues.CurrentTimePeriod", "state", "value", "number", "", true, true); await CreateDatapoint("vis.RoomValues.StatusLog", "state", "value", "string", "", true, false); await CreateDatapoint("vis.RoomValues.TemperaturOverrideRemainingTime", "state", "value", "number", "min", true, false); await CreateDatapoint("vis.ChoosenRoom", "state", "value", "string", "", true, true); await CreateDatapoint("vis.ProfileValueListValue", "state", "value", "string", "", true, true); await CreateDatapoint("vis.ProfileValueListText", "state", "value", "string", "", true, true); await CreateDatapoint("vis.TempValueListValue", "state", "value", "string", "", true, true); await CreateDatapoint("vis.TempAddValueListText", "state", "value", "string", "", true, true); await CreateDatapoint("vis.OverrideTempValueListValue", "state", "value", "string", "", true, true); await CreateDatapoint("vis.OverrideTempValueListText", "state", "value", "string", "", true, true); await CreateDatapoint("vis.ProfileTempValueListValue", "state", "value", "string", "", true, true); await CreateDatapoint("vis.ProfileTempValueListText", "state", "value", "string", "", true, true); await CreateDatapoint("vis.TempDivValueListText", "state", "value", "string", "", true, true); await CreateDatapoint("vis.WindowStatesHtmlTable", "state", "value", "string", "", true, false); await CreateDatapoint("vis.WindowStatesHtmlTableVis2", "state", "value", "string", "", true, false); await CreateDatapoint("vis.OpenWindowRoomCount", "state", "value", "number", "", true, false); await CreateDatapoint("vis.RoomStatesHtmlTable", "state", "value", "string", "", true, false); await CreateDatapoint("vis.isActive", "state", "value", "boolean", "", true, false); //translated vis text //cardHzngFenster await CreateDatapoint("vis.translations.cardHzngFenster.WindowState", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngFenster.AllWindowsClosed", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngFenster.WindowOpen", "state", "value", "string", "", true, false); //cardHzngGlobals await CreateDatapoint("vis.translations.cardHzngGlobals.HeatingPeriodActive", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.PublicHolidayToday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.Present", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.PartyNow", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.Guests", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.HolidayAtHome", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.HolidayVacation", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.FireplaceMode", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.MaintenanceMode", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngGlobals.General", "state", "value", "string", "", true, false); //cardHzngMoFrSaSo await CreateDatapoint("vis.translations.cardHzngMoFrSaSu.Period", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoFrSaSu.MoFr", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoFrSaSu.From", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoFrSaSu.SaSu", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoFrSaSu.ZeitenWoche", "state", "value", "string", "", true, false); //cardHzngMoSu await CreateDatapoint("vis.translations.cardHzngMoSu.Period", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSu.MoSu", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSu.From", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSu.ZeitenWoche", "state", "value", "string", "", true, false); //cardHzngMoSuSeparat await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Period", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.From", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Monday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Tuesday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Wednesday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Thursday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Friday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Saturday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.Sunday", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngMoSuSeparat.ZeitenWoche", "state", "value", "string", "", true, false); //cardHzngProfilParam await CreateDatapoint("vis.translations.cardHzngProfilParam.GuestIncrease", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.GuestTemperature", "state", "level.temperature", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.PartyDecrease", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.PartyTemperature", "state", "level.temperature", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.AbsentDecrease", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.AbsentTemperature", "state", "level.temperature", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.VacationAbsentDecrease", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.VacationAbsentTemperature", "state", "level.temperature", "string", "", true, false); //translation always available //if (parentAdapter.config.UseFireplaceMode) { await CreateDatapoint("vis.translations.cardHzngProfilParam.FireplaceModeDecrease", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.FireplaceModeTemperature", "state", "level.temperature", "string", "", true, false); //} await CreateDatapoint("vis.translations.cardHzngProfilParam.WindowOpenDecrease", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.WindowOpenTemperature", "state", "level.temperature", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.OverrideFor", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.OverrideTemp", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.MinimalTemperature", "state", "level.temperature", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.HintNotEnabled", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.cardHzngProfilParam.Profilparam", "state", "value", "string", "", true, false); //tnav await CreateDatapoint("vis.translations.tnav.ActiveProfile", "state", "value", "string", "", true, false); await CreateDatapoint("vis.translations.tnav.Room", "state", "value", "string", "", true, false); //cardHzngRooms await CreateDatapoint("vis.translations.cardHzngRooms.RoomState", "state", "value", "string", "", true, false); //cardDateAndTime await CreateDatapoint("vis.translations.cardDateAndTime.Clock", "state", "value", "string", "", true, false); } DeleteUnusedDP(true); } catch (e) { parentAdapter.log.error("exception in CreateDatapoints [" + e + "]"); } parentAdapter.log.info("CreateDatapoints done"); } async function CreateStates4Period(id) { await CreateDatapoint(id, "channel", "", "string", "", true, false); await CreateDatapoint(id + ".time", "state", "value", "string", "hh:mm", true, true); await CreateDatapoint(id + ".Temperature", "state", "level.temperature", "number", "°C", true, true); } async function CreateDatapoint( key, type, common_role, common_type, common_unit, common_read, common_write, common_desc) { const names = key.split("."); let idx = names.length; let name = key; if (idx > 0) { idx--; name = names[idx]; } await parentAdapter.setObjectNotExistsAsync(key, { type: type, common: { name: name, role: common_role, type: common_type, unit: common_unit, read: common_read, write: common_write, desc: common_desc }, native: { id: key } }); const obj = await parentAdapter.getObjectAsync(key); if (obj != null) { if (obj.common.role != common_role || obj.common.type != common_type || obj.common.unit != common_unit || obj.common.read != common_read || obj.common.write != common_write || obj.common.name != name || obj.common.desc != common_desc ) { await parentAdapter.extendObject(key, { common: { name: name, role: common_role, type: common_type, unit: common_unit, read: common_read, write: common_write, desc: common_desc } }); } } } //******************************************************************* // async function SetDefaults() { parentAdapter.log.debug("start SetDefaults"); try { //=================================================================================== await SetDefault("LastProgramRun", ""); await SetDefault("CurrentProfile", 1); await SetDefault("HeatingPeriodActive", true); await SetDefault("PublicHolidyToday", false); await SetDefault("Present", true); await SetDefault("PartyNow", false); await SetDefault("GuestsPresent", false); await SetDefault("HolidayPresent", false); await SetDefault("VacationAbsent", false); await SetDefault("MaintenanceActive", false); await SetDefault("PowerInterruptionPeriodActive", false); if (parentAdapter.config.UseFireplaceMode) { await SetDefault("FireplaceModeActive", false); } if (parentAdapter.config.UseActors) { await SetDefault("ActorsOn", 0); } //=================================================================================== await SetDefault("info.UsedRooms", ""); await SetDefault("info.TemperatureDecreaseMode", "none"); await SetDefault("info.ProfileType", "Mo - Su"); await SetDefault("info.NumberOfProfiles", 1); await SetDefault("info.NumberOfPeriods", 5); await SetDefault("info.PublicHolidayLikeSunday", true); await SetDefault("info.UseMinTempPerRoom", false); await SetDefault("info.UseFixHeatingPeriod", false); if (parentAdapter.config.UseFixHeatingPeriod) { await SetDefault("info.FixHeatingPeriodStart", ""); await SetDefault("info.FixHeatingPeriodEnd", ""); } //=================================================================================== for (let room = 0; room < parentAdapter.config.rooms.length; room++) { if (parentAdapter.config.rooms[room].isActive) { const key = "Rooms." + parentAdapter.config.rooms[room].name; await SetDefault(key + ".CurrentTarget", 20); await SetDefault(key + ".ActiveTimeSlot", -1); await SetDefault(key + ".CurrentTimePeriodFull", ""); await SetDefault(key + ".CurrentTimePeriod", ""); await SetDefault(key + ".CurrentTimePeriodTime", ""); await SetDefault(key + ".CurrentTimePeriodTemperature", -99); await SetDefault(key + ".WindowIsOpen", false); await SetDefault(key + ".State", ""); await SetDefault(key + ".TemperaturOverride", 0); await SetDefault(key + ".TemperaturOverrideTime", "00:00"); await SetDefault(key + ".TemperaturOverrideRemainingTime", 0); await SetDefault(key + ".isActive", true); if (parentAdapter.config.ThermostatModeIfNoHeatingperiod == 1) { await SetDefault(key + ".TemperatureIfNoHeatingPeriod", 20); } if (parentAdapter.config.UseMinTempPerRoom) { await SetDefault(key + ".MinimumTemperature", 5); } //if (parseInt(parentAdapter.config.UseChangesFromThermostat) === 4) { //each room reparately // await SetDefault(key + ".ChangesFromThermostatMode", 0); //} if (parentAdapter.config.UseAddTempSensors) { await SetDefault(key + ".TemperatureOffset", 0); } if (parseInt(parentAdapter.config.regulatorType) == 2) { await SetDefault(key + ".Regulator.HysteresisOnOffset", 0.5); await SetDefault(key + ".Regulator.HysteresisOffOffset", 0.5); } } } //=================================================================================== for (let profile = 1; profile <= parseInt(parentAdapter.config.NumberOfProfiles, 10); profile++) { const key = "Profiles." + profile; for (let room = 0; room < parentAdapter.config.rooms.length; room++) { if (parentAdapter.config.rooms[room].isActive) { const id = key + "." + parentAdapter.config.rooms[room].name; let id1 = id; if (parseInt(parentAdapter.config.ProfileType, 10) === 1) { for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Mo-Su.Periods." + period; await SetDefault4Period(period,id); } } else if (parseInt(parentAdapter.config.ProfileType, 10) === 2) { for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Mo-Fr.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Sa-Su.Periods." + period; await SetDefault4Period(period, id); } } else if (parseInt(parentAdapter.config.ProfileType, 10) === 3) { for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Mon.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Tue.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Wed.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Thu.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Fri.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Sat.Periods." + period; await SetDefault4Period(period, id); } for (let period = 1; period <= parseInt(parentAdapter.config.NumberOfPeriods, 10); period++) { const id = id1 + ".Sun.Periods." + period; await SetDefault4Period(period, id); } } let decreaseMode = false; let decreaseTarget; if (parseInt(parentAdapter.config.TemperatureDecrease) === 1) {// relative id1 += ".relative"; decreaseTarget = 0; decreaseMode = true; } else if (parseInt(parentAdapter.config.TemperatureDecrease) === 2) {// absolutue id1 += ".absolute"; decreaseTarget = 20; decreaseMode = true; } if (decreaseMode) { await SetDefault(id1 + ".GuestIncrease", decreaseTarget); await SetDefault(id1 + ".PartyDecrease", decreaseTarget); await SetDefault(id1 + ".WindowOpenDecrease", decreaseTarget); await SetDefault(id1 + ".AbsentDecrease", decreaseTarget); await SetDefault(id1 + ".VacationAbsentDecrease", decreaseTarget); if (parentAdapter.config.UseFireplaceMode) { await SetDefault(id1 + ".FireplaceModeDecrease", decreaseTarget); } } } } } //=================================================================================== //pittini vis if (parentAdapter.config.UseVisFromPittini) { await SetDefault("vis.TempDecreaseValues.AbsentDecrease", 0); await SetDefault("vis.TempDecreaseValues.GuestIncrease", 0); await SetDefault("vis.TempDecreaseValues.PartyDecrease", 0); await SetDefault("vis.TempDecreaseValues.VacationAbsentDecrease", 0); if (parentAdapter.config.UseFireplaceMode) { await SetDefault("vis.TempDecreaseValues.FireplaceModeDecrease", 0); } await SetDefault("vis.TempDecreaseValues.WindowOpenDecrease", 0); await SetDefault("vis.RoomValues.MinimumTemperature", 5); await SetDefault("vis.RoomValues.TemperaturOverride", 0); await SetDefault("vis.RoomValues.TemperaturOverrideTime", "00:00"); await SetDefault("vis.RoomValues.WindowIsOpen", false); await SetDefault("vis.RoomValues.StatusLog", ""); await SetDefault("vis.RoomValues.CurrentTimePeriod", ""); await SetDefault("vis.RoomValues.TemperaturOverrideRemainingTime", 0); await SetDefaultVisTranslatedText(); } } catch (e) { parentAdapter.log.error("exception in SetDefaults [" + e + "]"); } parentAdapter.log.debug("SetDefaults done"); } const DefaultTargets = []; DefaultTargets[0] = ["05:00", 21]; DefaultTargets[1] = ["08:00", 23]; DefaultTargets[2] = ["12:00", 22]; DefaultTargets[3] = ["16:00", 21]; DefaultTargets[4] = ["21:00", 19]; async function SetDefault4Period(period, id){ let key = id + ".time"; let current = await parentAdapter.getStateAsync(key); //set default only if nothing was set before if (current === null || current.val === undefined) { await parentAdapter.setStateAsync(key, { ack: true, val: DefaultTargets[period-1][0] }); } key = id + ".Temperature"; current = await parentAdapter.getStateAsync(key); //set default only if nothing was set before if (current === null || current.val === undefined) { await parentAdapter.setStateAsync(key, { ack: true, val: DefaultTargets[period-1][1] }); } } async function SetDefault(key, value) { const current = await parentAdapter.getStateAsync(key); //set default only if nothing was set before if (current === null || current === undefined || current.val === undefined) { parentAdapter.log.info("set default " + key + " to " + value); await parentAdapter.setStateAsync(key, { ack: true, val: value }); } } async function SetDefaultVisTranslatedText() { //cardHzngFenster await parentAdapter.setStateAsync("vis.translations.cardHzngFenster.WindowState", { ack: true, val: GetTranslation(parentAdapter, "WindowState", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngFenster.AllWindowsClosed", { ack: true, val: GetTranslation(parentAdapter, "AllWindowsClosed", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngFenster.WindowOpen", { ack: true, val: GetTranslation(parentAdapter, "WindowOpen", SystemLanguage) }); //cardHzngGlobals await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.HeatingPeriodActive", { ack: true, val: GetTranslation(parentAdapter,"HeatingPeriodActive", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.PublicHolidayToday", { ack: true, val: GetTranslation(parentAdapter,"PublicHolidayToday", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.Present", { ack: true, val: GetTranslation(parentAdapter,"Present", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.PartyNow", { ack: true, val: GetTranslation(parentAdapter,"PartyNow", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.Guests", { ack: true, val: GetTranslation(parentAdapter,"Guests", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.HolidayAtHome", { ack: true, val: GetTranslation(parentAdapter,"HolidayAtHome", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.HolidayVacation", { ack: true, val: GetTranslation(parentAdapter,"HolidayVacation", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.FireplaceMode", { ack: true, val: GetTranslation(parentAdapter, "FireplaceMode", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.MaintenanceMode", { ack: true, val: GetTranslation(parentAdapter, "MaintenanceMode", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngGlobals.General", { ack: true, val: GetTranslation(parentAdapter, "General", SystemLanguage) }); //cardHzngMoFrSaSo await parentAdapter.setStateAsync("vis.translations.cardHzngMoFrSaSu.Period", { ack: true, val: GetTranslation(parentAdapter,"Period", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngMoFrSaSu.MoFr", { ack: true, val: GetTranslation(parentAdapter,"MoFr", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngMoFrSaSu.From", { ack: true, val: GetTranslation(parentAdapter,"From", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngMoFrSaSu.SaSu", { ack: true, val: GetTranslation(parentAdapter,"SaSu", SystemLanguage)}); await parentAdapter.setStateAsync("vis.translations.cardHzngMoFrSaSu.ZeitenWoche", { ack: true, val: GetTranslation(parentAdapter, "ZeitenWoche", SystemLanguage) }); //cardHzngMoSu await parentAdapter.setStateAsync("vis.translations.cardHzngMoSu.Period", { ack: true, val: GetTranslation(parentAdapter,"Period", SystemLanguage) }); await parentAdapter.setStateAsync("vis.translations.cardHzngMoSu.MoSu", { ack: true, val: GetTranslation(parentAdapte