iobroker.alexa-timer-vis
Advanced tools
Comparing version 2.0.7 to 2.0.8
@@ -27,3 +27,3 @@ "use strict"; | ||
var import_logging = require("./logging"); | ||
const decomposeInputValue = async (voiceString) => { | ||
const decomposeInputValue = (voiceString) => { | ||
const store = (0, import_store.useStore)(); | ||
@@ -35,3 +35,3 @@ const _this = store._this; | ||
inputDecomposed = inputDecomposed[0].split(" "); | ||
const { timerString, name, deleteVal, inputString } = await (0, import_filter_info.filterInfo)(inputDecomposed); | ||
const { timerString, name, deleteVal, inputString } = (0, import_filter_info.filterInfo)(inputDecomposed); | ||
stringToEval = timerString; | ||
@@ -44,3 +44,3 @@ return { name, timerSec: eval(timerString), deleteVal, inputString }; | ||
_this, | ||
value: "Input: " + voiceString + " TimerString: " + stringToEval | ||
value: `Input: ${voiceString} TimerString: ${stringToEval}` | ||
}); | ||
@@ -47,0 +47,0 @@ return { name: "", timerSec: 0, deleteVal: 0, inputString: "" }; |
@@ -28,2 +28,3 @@ "use strict"; | ||
var import_store = require("../store/store"); | ||
var import_logging = require("./logging"); | ||
const removeTimerInLastTimers = () => { | ||
@@ -34,3 +35,5 @@ const store = (0, import_store.useStore)(); | ||
const delTimer = (timer) => { | ||
(0, import_reset.resetValues)(import_timer_data.timerObject.timer[timer], timer); | ||
(0, import_reset.resetValues)(import_timer_data.timerObject.timer[timer], timer).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in delTimer", error: e, _this: (0, import_store.useStore)()._this }); | ||
}); | ||
import_timer_data.timerObject.timerActive.timer[timer] = false; | ||
@@ -37,0 +40,0 @@ removeTimerInLastTimers(); |
@@ -28,3 +28,3 @@ "use strict"; | ||
var import_timer_data = require("./timer-data"); | ||
const filterInfo = async (input) => { | ||
const filterInfo = (input) => { | ||
const store = (0, import_store.useStore)(); | ||
@@ -53,3 +53,3 @@ const _this = store._this; | ||
timerString += ")*3600+"; | ||
inputString += (0, import_global.firstLetterToUpperCase)(element) + " "; | ||
inputString += `${(0, import_global.firstLetterToUpperCase)(element)} `; | ||
} else if (data.minute.indexOf(element) >= 0) { | ||
@@ -65,3 +65,3 @@ timerString += ")*60+"; | ||
} | ||
timerString += "*" + import_timer_data.timerObject.brueche1[element] + ")*60"; | ||
timerString += `*${import_timer_data.timerObject.brueche1[element]})*60`; | ||
} else if (import_timer_data.timerObject.brueche2[element] > 0) { | ||
@@ -71,24 +71,26 @@ if (timerString.charAt(timerString.length - 1) == "") { | ||
} | ||
timerString += "*" + import_timer_data.timerObject.brueche2[element] + ")*3600"; | ||
timerString += `*${import_timer_data.timerObject.brueche2[element]})*3600`; | ||
} else if (import_timer_data.timerObject.zahlen[element] > 0) { | ||
if (import_timer_data.timerObject.ziffern.indexOf(timerString.charAt(timerString.length - 1)) == -1) { | ||
if ((timerString.charAt(timerString.length - 1) != "*3600+" || timerString.charAt(timerString.length - 1) != "*60+") && timerString.charAt(timerString.length - 3) != "(") { | ||
timerString += "(" + import_timer_data.timerObject.zahlen[element]; | ||
timerString += `(${import_timer_data.timerObject.zahlen[element]}`; | ||
} else { | ||
timerString += import_timer_data.timerObject.zahlen[element]; | ||
} | ||
inputString += import_timer_data.timerObject.zahlen[element] + " "; | ||
inputString += `${import_timer_data.timerObject.zahlen[element]} `; | ||
} else if (element == "hundert") { | ||
timerString += "*" + import_timer_data.timerObject.zahlen[element]; | ||
inputString += import_timer_data.timerObject.zahlen[element] + " "; | ||
timerString += `*${import_timer_data.timerObject.zahlen[element]}`; | ||
inputString += `${import_timer_data.timerObject.zahlen[element]} `; | ||
} else { | ||
timerString += "+" + import_timer_data.timerObject.zahlen[element]; | ||
inputString += import_timer_data.timerObject.zahlen[element] + " "; | ||
timerString += `+${import_timer_data.timerObject.zahlen[element]}`; | ||
inputString += `${import_timer_data.timerObject.zahlen[element]} `; | ||
} | ||
} else if (parseInt(element)) { | ||
const number = parseInt(element); | ||
if (timerString == "") | ||
if (timerString == "") { | ||
timerString = "("; | ||
if (timerString.endsWith("+")) | ||
} | ||
if (timerString.endsWith("+")) { | ||
timerString += "("; | ||
} | ||
timerString += number; | ||
@@ -108,3 +110,3 @@ inputString += number; | ||
if ((0, import_global.countOccurrences)(timerString, ")") > (0, import_global.countOccurrences)(timerString, "(")) { | ||
timerString = "(" + timerString; | ||
timerString = `(${timerString}`; | ||
} | ||
@@ -111,0 +113,0 @@ return { timerString, name, deleteVal, inputString }; |
@@ -67,9 +67,15 @@ "use strict"; | ||
if (!store.questionAlexa) { | ||
if (import_timer_data.timerObject.timerActive.timerCount == 1 && import_timer_data.timerObject.timerActive.timer[element] === true) { | ||
if (import_timer_data.timerObject.timerActive.timerCount == 1 && import_timer_data.timerObject.timerActive.timer[element]) { | ||
timerFound.timer.push(element); | ||
} else if (countMatchingTime == 1 && import_timer_data.timerObject.timer[element]["voiceInputAsSeconds"] == sec && sec !== 0) { | ||
} else if (countMatchingTime == 1 && import_timer_data.timerObject.timer[element].voiceInputAsSeconds == sec && sec !== 0) { | ||
timerFound.timer.push(element); | ||
} else if (countMatchingTime == 1 && import_timer_data.timerObject.timer[element]["voiceInputAsSeconds"] == sec) { | ||
} else if ( | ||
// _this.log.debug("Wenn nur einer gestellt ist mit der der gewünschten Zeit"); | ||
countMatchingTime == 1 && import_timer_data.timerObject.timer[element].voiceInputAsSeconds == sec | ||
) { | ||
timerFound.timer.push(element); | ||
} else if (import_timer_data.timerObject.timer[element]["name"] == name && name !== "" && countMatchingName == 1) { | ||
} else if ( | ||
// Einer, mit genauem Namen | ||
import_timer_data.timerObject.timer[element].name == name && name !== "" && countMatchingName == 1 | ||
) { | ||
timerFound.timer.push(element); | ||
@@ -86,3 +92,6 @@ } | ||
} | ||
} else if (countMatchingInputDevice != import_timer_data.timerObject.timerActive.timerCount && value.indexOf("ja") != -1) { | ||
} else if ( | ||
// Alle, von allen Geräten | ||
countMatchingInputDevice != import_timer_data.timerObject.timerActive.timerCount && value.indexOf("ja") != -1 | ||
) { | ||
for (const element2 in import_timer_data.timerObject.timerActive.timer) { | ||
@@ -89,0 +98,0 @@ timerFound.timer.push(element2); |
@@ -33,3 +33,3 @@ "use strict"; | ||
const { string: lengthTimer } = result; | ||
const timeString1 = hour + ":" + minutes + ":" + seconds + getTimeUnit(timeLeftSec, store); | ||
const timeString1 = `${hour}:${minutes}:${seconds}${getTimeUnit(timeLeftSec, store)}`; | ||
const { timeString } = isShorterThanAMinute( | ||
@@ -59,3 +59,3 @@ isShorterThanSixtyMinutes( | ||
function setTimerNameIfNotExist(name) { | ||
if (name == "" || name == null || name == void 0) { | ||
if (name == "" || !name) { | ||
return "Timer"; | ||
@@ -70,4 +70,5 @@ } | ||
minutes = ""; | ||
if (seconds === "00") | ||
if (seconds === "00") { | ||
seconds = ""; | ||
} | ||
} | ||
@@ -79,3 +80,3 @@ } | ||
if (parseInt(minutes) == 0) { | ||
return { timeString: seconds + " " + store.unitSecond3 }; | ||
return { timeString: `${seconds} ${store.unitSecond3}` }; | ||
} | ||
@@ -92,3 +93,3 @@ return { timeString }; | ||
if (parseInt(hour) === 1 && parseInt(minutes) <= 5) { | ||
const timeString2 = hour + ":" + minutes + ":" + seconds + " " + store.unitHour3; | ||
const timeString2 = `${hour}:${minutes}:${seconds} ${store.unitHour3}`; | ||
return { timeString: timeString2, hour, minutes, seconds, store }; | ||
@@ -106,3 +107,3 @@ } | ||
if (parseInt(hour) == 0) { | ||
const timeString2 = minutes + ":" + seconds + " " + store.unitMinute3; | ||
const timeString2 = `${minutes}:${seconds} ${store.unitMinute3}`; | ||
return { timeString: timeString2, hour, minutes, seconds, store }; | ||
@@ -114,3 +115,3 @@ } | ||
if (parseInt(hour) > 1 || parseInt(hour) === 1 && parseInt(minutes) > 5) { | ||
const timeString = hour + ":" + minutes + ":" + seconds + " " + store.unitHour3; | ||
const timeString = `${hour}:${minutes}:${seconds} ${store.unitHour3}`; | ||
return { timeString, hour, minutes, seconds, store }; | ||
@@ -117,0 +118,0 @@ } |
@@ -25,7 +25,5 @@ "use strict"; | ||
isAlexaSummaryStateChanged: () => isAlexaSummaryStateChanged, | ||
isCreateNewTimer: () => isCreateNewTimer, | ||
isIobrokerValue: () => isIobrokerValue, | ||
isString: () => isString, | ||
isStringEmpty: () => isStringEmpty, | ||
isVoiceInputNotSameAsOld: () => isVoiceInputNotSameAsOld, | ||
secToHourMinSec: () => secToHourMinSec, | ||
@@ -70,5 +68,5 @@ sortArray: () => sortArray, | ||
return { | ||
hourString: ("0" + hour).slice(-2), | ||
minutesString: ("0" + minutes).slice(-2), | ||
secondsString: ("0" + seconds).slice(-2) | ||
hourString: `0${hour}`.slice(-2), | ||
minutesString: `0${minutes}`.slice(-2), | ||
secondsString: `0${seconds}`.slice(-2) | ||
}; | ||
@@ -110,8 +108,2 @@ } | ||
} | ||
function isCreateNewTimer(voiceInput) { | ||
return (voiceInput.indexOf("timer") >= 0 || voiceInput.indexOf("stelle") >= 0 || voiceInput.indexOf("stell") >= 0) && voiceInput.indexOf("wecker") == -1; | ||
} | ||
function isVoiceInputNotSameAsOld(voiceInput, voiceInputOld) { | ||
return voiceInput !== voiceInputOld && voiceInput !== ""; | ||
} | ||
function doesAlexaSendAQuestion(voiceInput) { | ||
@@ -129,3 +121,3 @@ const store = (0, import_store.useStore)(); | ||
const result = obj && obj.val !== null && obj.val !== void 0; | ||
return result ? true : false; | ||
return !!result; | ||
} | ||
@@ -146,7 +138,5 @@ function sortArray(array) { | ||
isAlexaSummaryStateChanged, | ||
isCreateNewTimer, | ||
isIobrokerValue, | ||
isString, | ||
isStringEmpty, | ||
isVoiceInputNotSameAsOld, | ||
secToHourMinSec, | ||
@@ -153,0 +143,0 @@ sortArray, |
@@ -29,2 +29,3 @@ "use strict"; | ||
var import_store = require("../store/store"); | ||
var import_logging = require("./logging"); | ||
const interval = (sec, timerBlock, inputString, name, timer, int, onlyOneTimer) => { | ||
@@ -48,15 +49,9 @@ const store = (0, import_store.useStore)(); | ||
} | ||
interval( | ||
sec, | ||
timerBlock, | ||
inputString, | ||
name, | ||
timer, | ||
import_timer_data.timerObject.timer[timerBlock].timerInterval, | ||
true | ||
); | ||
interval(sec, timerBlock, inputString, name, timer, import_timer_data.timerObject.timer[timerBlock].timerInterval, true); | ||
} | ||
if (timeLeftSec <= 0 || import_timer_data.timerObject.timerActive.timer[timerBlock] == false) { | ||
if (timeLeftSec <= 0 || !import_timer_data.timerObject.timerActive.timer[timerBlock]) { | ||
import_timer_data.timerObject.timerActive.timerCount--; | ||
(0, import_reset.resetValues)(timer, timerBlock); | ||
(0, import_reset.resetValues)(timer, timerBlock).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in interval", error: e, _this }); | ||
}); | ||
_this.log.debug("Timer stopped"); | ||
@@ -63,0 +58,0 @@ if (import_timer_data.timerObject.interval) { |
@@ -30,3 +30,3 @@ "use strict"; | ||
}) => { | ||
_this.log.error(text + ": " + JSON.stringify(error || "")); | ||
_this.log.error(`${text}: ${JSON.stringify(error || "")}`); | ||
_this.log.error(JSON.stringify(value || "")); | ||
@@ -33,0 +33,0 @@ _this.log.error(JSON.stringify(error.stack || "")); |
@@ -29,3 +29,3 @@ "use strict"; | ||
var import_write_state = require("./write-state"); | ||
const resetValues = (timer, index) => { | ||
const resetValues = async (timer, index) => { | ||
const { _this, getAlexaTimerVisInstance, valHourForZero, valMinuteForZero, valSecondForZero } = (0, import_store.useStore)(); | ||
@@ -58,3 +58,3 @@ try { | ||
timer.endTimeNumber = 0; | ||
_this.setObjectAsync(getAlexaTimerVisInstance() + index, { | ||
await _this.setObjectAsync(getAlexaTimerVisInstance() + index, { | ||
type: "device", | ||
@@ -70,4 +70,8 @@ common: { name: `` }, | ||
Object.keys(import_timer_data.timerObject.timer).forEach((el) => { | ||
resetValues(import_timer_data.timerObject.timer[el], el); | ||
(0, import_write_state.writeState)({ reset: true }); | ||
resetValues(import_timer_data.timerObject.timer[el], el).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in resetAllTimerValuesAndState", error: e, _this }); | ||
}); | ||
(0, import_write_state.writeState)({ reset: true }).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in resetAllTimerValuesAndState", error: e, _this }); | ||
}); | ||
}); | ||
@@ -74,0 +78,0 @@ _this.setStateChanged("all_Timer.alive", false, true); |
@@ -35,3 +35,3 @@ "use strict"; | ||
_this.log.info("Alexa State was found"); | ||
_this.setState("info.connection", true, true); | ||
await _this.setState("info.connection", true, true); | ||
await (0, import_state.createState)(4); | ||
@@ -38,0 +38,0 @@ }; |
@@ -66,3 +66,3 @@ "use strict"; | ||
const key = Object.keys(import_timer_data.timerObject.timerActive.timer)[i]; | ||
if (import_timer_data.timerObject.timerActive.timer[key] === false) { | ||
if (!import_timer_data.timerObject.timerActive.timer[key]) { | ||
import_timer_data.timerObject.timerActive.timer[key] = true; | ||
@@ -75,3 +75,3 @@ return key; | ||
if ((0, import_global.isString)(timerBlock)) { | ||
await _this.setObjectAsync("alexa-timer-vis.0." + timerBlock, { | ||
await _this.setObjectAsync(`alexa-timer-vis.0.${timerBlock}`, { | ||
type: "device", | ||
@@ -78,0 +78,0 @@ common: { name: `${store.deviceName}` }, |
@@ -43,3 +43,3 @@ "use strict"; | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".percent", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.percent`, { | ||
type: "state", | ||
@@ -56,3 +56,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".percent2", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.percent2`, { | ||
type: "state", | ||
@@ -69,3 +69,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".alive", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.alive`, { | ||
type: "state", | ||
@@ -82,3 +82,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".hour", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.hour`, { | ||
type: "state", | ||
@@ -95,3 +95,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".minute", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.minute`, { | ||
type: "state", | ||
@@ -108,3 +108,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".second", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.second`, { | ||
type: "state", | ||
@@ -121,3 +121,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".string", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.string`, { | ||
type: "state", | ||
@@ -134,3 +134,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".string_2", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.string_2`, { | ||
type: "state", | ||
@@ -147,3 +147,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".name", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.name`, { | ||
type: "state", | ||
@@ -160,3 +160,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".TimeStart", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.TimeStart`, { | ||
type: "state", | ||
@@ -173,3 +173,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".TimeEnd", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.TimeEnd`, { | ||
type: "state", | ||
@@ -186,3 +186,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".InputDeviceName", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.InputDeviceName`, { | ||
type: "state", | ||
@@ -199,3 +199,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".Reset", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.Reset`, { | ||
type: "state", | ||
@@ -212,3 +212,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".lengthTimer", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.lengthTimer`, { | ||
type: "state", | ||
@@ -225,3 +225,3 @@ common: { | ||
}); | ||
await _this.setObjectNotExistsAsync("timer" + i + ".json", { | ||
await _this.setObjectNotExistsAsync(`timer${i}.json`, { | ||
type: "state", | ||
@@ -228,0 +228,0 @@ common: { |
@@ -29,6 +29,8 @@ "use strict"; | ||
var import_global = require("./global"); | ||
var import_logging = require("./logging"); | ||
var import_store = require("../store/store"); | ||
const timerAdd = (decomposeName, timerSec, decomposeInputString) => { | ||
var _a; | ||
const { _this } = (0, import_store.useStore)(); | ||
const name = decomposeName; | ||
const inputString = decomposeInputString; | ||
if (timerSec && timerSec != 0) { | ||
@@ -39,9 +41,11 @@ let nameExist = false; | ||
nameExist = true; | ||
break; | ||
} | ||
break; | ||
} | ||
if (!nameExist) { | ||
import_timer_data.timerObject.timerActive.timerCount++; | ||
(0, import_state.createState)(import_timer_data.timerObject.timerActive.timerCount); | ||
const timer = "timer" + import_timer_data.timerObject.timerActive.timerCount; | ||
(0, import_state.createState)(import_timer_data.timerObject.timerActive.timerCount).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in timerAdd", error: e, _this }); | ||
}); | ||
const timer = `timer${import_timer_data.timerObject.timerActive.timerCount}`; | ||
if (import_timer_data.timerObject.timerActive.timer[timer] === void 0) { | ||
@@ -51,3 +55,5 @@ import_timer_data.timerObject.timerActive.timer[timer] = false; | ||
} | ||
(0, import_start_timer.startTimer)(timerSec, name, inputString); | ||
(0, import_start_timer.startTimer)(timerSec, name, decomposeInputString).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in timerAdd", error: e, _this }); | ||
}); | ||
(0, import_write_state_interval.writeStateIntervall)(); | ||
@@ -54,0 +60,0 @@ } |
@@ -28,3 +28,4 @@ "use strict"; | ||
var import_store = require("../store/store"); | ||
const timerDelete = (decomposeName, timerSec, voiceInput, deleteVal) => { | ||
var import_logging = require("./logging"); | ||
const timerDelete = async (decomposeName, timerSec, voiceInput, deleteVal) => { | ||
const store = (0, import_store.useStore)(); | ||
@@ -47,11 +48,16 @@ const _this = store._this; | ||
} | ||
(0, import_find_timer.findTimer)(timerAbortSec, name, deleteTimerIndex, voiceInput).then((timers) => { | ||
if (timers.timer) { | ||
timers.timer.forEach((element) => { | ||
(0, import_delete_timer.delTimer)(element); | ||
}); | ||
} else if (timers.oneOfMultiTimer) { | ||
const a = timers.oneOfMultiTimer; | ||
if (typeof a[0] == "string" && typeof a[1] == "number" && typeof a[2] == "string" && typeof a[3] == "string") | ||
(0, import_one_timer_to_delete.oneOfMultiTimerDelete)(a[0], a[1], a[2], a[3]); | ||
await (0, import_find_timer.findTimer)(timerAbortSec, name, deleteTimerIndex, voiceInput).then((timers) => { | ||
try { | ||
if (timers.timer) { | ||
timers.timer.forEach((element) => { | ||
(0, import_delete_timer.delTimer)(element); | ||
}); | ||
} else if (timers.oneOfMultiTimer) { | ||
const a = timers.oneOfMultiTimer; | ||
if (typeof a[0] == "string" && typeof a[1] == "number" && typeof a[2] == "string" && typeof a[3] == "string") { | ||
(0, import_one_timer_to_delete.oneOfMultiTimerDelete)(a[0], a[1], a[2], a[3]); | ||
} | ||
} | ||
} catch (e) { | ||
(0, import_logging.errorLogging)({ text: "Error in timerDelete", error: e, _this }); | ||
} | ||
@@ -58,0 +64,0 @@ }); |
@@ -45,5 +45,5 @@ "use strict"; | ||
valueExtend = voiceInput.slice(voiceInput.indexOf("um") + 2).split(" "); | ||
const { timerString } = await (0, import_filter_info.filterInfo)(firstPartOfValue); | ||
const { timerString } = (0, import_filter_info.filterInfo)(firstPartOfValue); | ||
extendTime = eval(timerString); | ||
const { timerString: string2 } = await (0, import_filter_info.filterInfo)(valueExtend); | ||
const { timerString: string2 } = (0, import_filter_info.filterInfo)(valueExtend); | ||
extendTime2 = eval(string2); | ||
@@ -72,3 +72,3 @@ } | ||
const timerSeconds = sec; | ||
if (timerObject2.timerActive.timer[timer] == true) { | ||
if (timerObject2.timerActive.timer[timer]) { | ||
timerObject2.timer[timer].extendOrShortenTimer = true; | ||
@@ -75,0 +75,0 @@ timerObject2.timer[timer].endTimeNumber += timerSeconds * 1e3 * addOrSub2; |
@@ -35,4 +35,6 @@ "use strict"; | ||
} | ||
store.interval = _this.setInterval(async () => { | ||
(0, import_write_state.writeState)({ reset: false }); | ||
store.interval = _this.setInterval(() => { | ||
(0, import_write_state.writeState)({ reset: false }).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in writeStateIntervall", error: e, _this }); | ||
}); | ||
if (import_timer_data.timerObject.timerActive.timerCount === 0) { | ||
@@ -39,0 +41,0 @@ _this.setStateChanged("all_Timer.alive", false, true); |
@@ -30,3 +30,3 @@ "use strict"; | ||
var import_logging = require("./logging"); | ||
function writeState({ reset }) { | ||
async function writeState({ reset }) { | ||
const store = (0, import_store.useStore)(); | ||
@@ -43,23 +43,23 @@ const _this = store._this; | ||
if (reset) { | ||
(0, import_reset.resetValues)(timer, element); | ||
await (0, import_reset.resetValues)(timer, element); | ||
alive = false; | ||
} | ||
_this.setStateChanged( | ||
element + ".alive", | ||
`${element}.alive`, | ||
import_timer_data.timerObject.timerActive.timer[element], | ||
true | ||
); | ||
_this.setStateChanged(element + ".hour", timer.hour, true); | ||
_this.setStateChanged(element + ".minute", timer.minute, true); | ||
_this.setStateChanged(element + ".second", timer.second, true); | ||
_this.setStateChanged(element + ".string", timer.stringTimer, true); | ||
_this.setStateChanged(element + ".string_2", timer.stringTimer2, true); | ||
_this.setStateChanged(element + ".TimeStart", timer.startTimeString, true); | ||
_this.setStateChanged(element + ".TimeEnd", timer.endTimeString, true); | ||
_this.setStateChanged(element + ".InputDeviceName", timer.inputDevice, true); | ||
_this.setStateChanged(element + ".lengthTimer", timer.lengthTimer, true); | ||
_this.setStateChanged(element + ".percent2", timer.percent2, true); | ||
_this.setStateChanged(element + ".percent", timer.percent, true); | ||
_this.setStateChanged(element + ".name", getTimerName(timer), true); | ||
_this.setStateChanged(element + ".json", getJson(timer), true); | ||
_this.setStateChanged(`${element}.hour`, timer.hour, true); | ||
_this.setStateChanged(`${element}.minute`, timer.minute, true); | ||
_this.setStateChanged(`${element}.second`, timer.second, true); | ||
_this.setStateChanged(`${element}.string`, timer.stringTimer, true); | ||
_this.setStateChanged(`${element}.string_2`, timer.stringTimer2, true); | ||
_this.setStateChanged(`${element}.TimeStart`, timer.startTimeString, true); | ||
_this.setStateChanged(`${element}.TimeEnd`, timer.endTimeString, true); | ||
_this.setStateChanged(`${element}.InputDeviceName`, timer.inputDevice, true); | ||
_this.setStateChanged(`${element}.lengthTimer`, timer.lengthTimer, true); | ||
_this.setStateChanged(`${element}.percent2`, timer.percent2, true); | ||
_this.setStateChanged(`${element}.percent`, timer.percent, true); | ||
_this.setStateChanged(`${element}.name`, getTimerName(timer), true); | ||
_this.setStateChanged(`${element}.json`, getJson(timer), true); | ||
_this.setStateChanged("all_Timer.alive", alive, true); | ||
@@ -78,6 +78,6 @@ } | ||
if (timer.alexaTimerName) { | ||
return (0, import_global.firstLetterToUpperCase)(timer.alexaTimerName + " Timer"); | ||
return (0, import_global.firstLetterToUpperCase)(`${timer.alexaTimerName} Timer`); | ||
} | ||
if (timer.name !== "Timer") { | ||
return (0, import_global.firstLetterToUpperCase)(timer.name) + " Timer"; | ||
return `${(0, import_global.firstLetterToUpperCase)(timer.name)} Timer`; | ||
} | ||
@@ -84,0 +84,0 @@ return "Timer"; |
@@ -54,3 +54,3 @@ "use strict"; | ||
/** | ||
* @param {Partial<utils.AdapterOptions>} [options={}] | ||
* @param [options] - See {@link | ||
*/ | ||
@@ -73,3 +73,3 @@ constructor(options = {}) { | ||
store._this = this; | ||
this.setState("info.connection", false, true); | ||
await this.setState("info.connection", false, true); | ||
if (this.adapterConfig && "_id" in this.adapterConfig) { | ||
@@ -100,14 +100,3 @@ store.alexaTimerVisInstance = (_a = this.adapterConfig) == null ? void 0 : _a._id.replace("system.adapter.", ""); | ||
try { | ||
let checkForTimerName = function(_this, id2) { | ||
if (!(0, import_global.isIobrokerValue)(state) || state.val === "[]") { | ||
return; | ||
} | ||
const lastTimer = store.lastTimer; | ||
if (lastTimer.id === id2) { | ||
(0, import_delete_timer.removeTimerInLastTimers)(); | ||
(0, import_timer_name.getNewTimerName)(state, lastTimer.timerSelector); | ||
_this.unsubscribeForeignStatesAsync(id2); | ||
} | ||
}; | ||
checkForTimerName(this, id); | ||
await checkForTimerName(this, id); | ||
if ((0, import_global.isAlexaSummaryStateChanged)(state, id) && isTimerAction(state)) { | ||
@@ -122,3 +111,3 @@ this.log.debug("Alexa state changed"); | ||
voiceInput = res == null ? void 0 : res.val; | ||
this.log.debug("VoiceInput: " + voiceInput); | ||
this.log.debug(`VoiceInput: ${voiceInput}`); | ||
} | ||
@@ -138,7 +127,7 @@ if (import_timer_data.timerObject.timerActive.data.abortWords.find((word) => voiceInput.includes(word))) { | ||
inputString: decomposeInputString | ||
} = await (0, import_decompose_input_value.decomposeInputValue)(voiceInput); | ||
} = (0, import_decompose_input_value.decomposeInputValue)(voiceInput); | ||
if (!doNothingByNotNotedElement || store.isDeleteTimer()) { | ||
(0, import_global.doesAlexaSendAQuestion)(voiceInput); | ||
if (store.isDeleteTimer()) { | ||
(0, import_timer_delete.timerDelete)(decomposeName, timerSec, voiceInput, deleteVal); | ||
await (0, import_timer_delete.timerDelete)(decomposeName, timerSec, voiceInput, deleteVal); | ||
return; | ||
@@ -151,3 +140,3 @@ } | ||
if (store.isExtendTimer() || store.isShortenTimer()) { | ||
(0, import_timer_extend_or_shorten.extendOrShortTimer)({ voiceInput, decomposeName }); | ||
await (0, import_timer_extend_or_shorten.extendOrShortTimer)({ voiceInput, decomposeName }); | ||
return; | ||
@@ -168,2 +157,13 @@ } | ||
} | ||
async function checkForTimerName(_this, id2) { | ||
if (!(0, import_global.isIobrokerValue)(state) || state.val === "[]") { | ||
return; | ||
} | ||
const lastTimer = store.lastTimer; | ||
if (lastTimer.id === id2) { | ||
(0, import_delete_timer.removeTimerInLastTimers)(); | ||
(0, import_timer_name.getNewTimerName)(state, lastTimer.timerSelector); | ||
await _this.unsubscribeForeignStatesAsync(id2); | ||
} | ||
} | ||
} catch (e) { | ||
@@ -179,3 +179,5 @@ (0, import_logging.errorLogging)({ text: "Error in stateChange", error: e, _this: this }); | ||
this.log.info("Adapter shuts down"); | ||
(0, import_write_state.writeState)({ reset: true }); | ||
(0, import_write_state.writeState)({ reset: true }).catch((e) => { | ||
(0, import_logging.errorLogging)({ text: "Error in onUnload", error: e, _this: this }); | ||
}); | ||
this.clearTimeout(timeout_1); | ||
@@ -208,3 +210,3 @@ this.clearTimeout(debounceTimeout); | ||
function isAlexaTimerVisResetButton(state, id) { | ||
return (0, import_global.isIobrokerValue)(state) && state.val && id.includes("Reset") ? true : false; | ||
return !!((0, import_global.isIobrokerValue)(state) && state.val && id.includes("Reset")); | ||
} | ||
@@ -211,0 +213,0 @@ function buildTextCommand(timerOb) { |
{ | ||
"common": { | ||
"name": "alexa-timer-vis", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"news": { | ||
"2.0.8": { | ||
"en": "CHORE: Update dependencies\nCHORE: Migration to ESLint 9 and @iobroker/eslint-config", | ||
"de": "CHORE: Aktualisieren von Abhängigkeiten\nCHORE: Migration auf ESLint 9 und @iobroker/eslint-config", | ||
"ru": "CHORE: зависимости от обновления\nCHORE: Migration to ESLint 9 and @iobroker/eslint-config", | ||
"pt": "CHORE: Atualizar dependências\nCHORE: Migração para ESLint 9 e @iobroker/eslint-config", | ||
"nl": "Afhankelijkheden bijwerken\nCHORE: migratie naar ESLint 9 en @iobroker/eslint-config", | ||
"fr": "CHORE : Mise à jour des dépendances\nCHORE: Migration vers ESLint 9 et @iobroker/eslint-config", | ||
"it": "CHORE: dipendenze di aggiornamento\nCHORE: Migrazione a ESLint 9 e @iobroker/eslint-config", | ||
"es": "CHORE: Actualizar las dependencias\nCHORE: Migración a ESLint 9 y @iobroker/eslint-config", | ||
"pl": "CHORE: Uaktualnij zależności\nCHORE: Migracja do ESLint 9 i @ iobroker / eslint- config", | ||
"uk": "CHORE: Оновити залежності\nCHORE: Міграція до ESLint 9 і @iobroker/eslint-config", | ||
"zh-cn": "CHORE: 更新依赖性\nCHORE: 迁移到ESLint 9 和 @iobroster/eslint-config" | ||
}, | ||
"2.0.7": { | ||
@@ -83,15 +96,2 @@ "en": "FIX: #157 Add size attribute xl for text in jsonConfig\nFIX: #156 Error in decomposeInputValue", | ||
"zh-cn": "FIX: # 130 Sting_2 仍然为空" | ||
}, | ||
"2.0.1": { | ||
"en": "FIX: #128 Timer creating error", | ||
"de": "FIX: #128 Timer Fehler erstellen", | ||
"ru": "FIX: #128 Таймер, создающий ошибку", | ||
"pt": "FIX: #128 Temporizador criando erro", | ||
"nl": "FIX: #128 Timer aanmaken fout", | ||
"fr": "FIX: #128 Chronomètre créant une erreur", | ||
"it": "FIX: #128 Timer crea errore", | ||
"es": "FIX: #128 Timer creating error", | ||
"pl": "FIX: # 128 Czas tworzenia błędu", | ||
"uk": "FIX: #128 Таймер створення помилки", | ||
"zh-cn": "FIX: # 128 计时器生成错误" | ||
} | ||
@@ -98,0 +98,0 @@ }, |
{ | ||
"name": "iobroker.alexa-timer-vis", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Alexa Timer ausgeben um in der Vis anzuzeigen", | ||
@@ -34,28 +34,20 @@ "author": { | ||
"@iobroker/adapter-dev": "^1.3.0", | ||
"@iobroker/testing": "^4.1.3", | ||
"@iobroker/eslint-config": "^1.0.0", | ||
"@iobroker/testing": "^5.0.0", | ||
"@tsconfig/node18": "^18.2.4", | ||
"@types/chai": "^4.3.16", | ||
"@types/chai-as-promised": "^7.1.8", | ||
"@types/eslint-config-prettier": "^6.11.3", | ||
"@types/eslint-plugin-prettier": "^3.1.3", | ||
"@types/mocha": "^10.0.8", | ||
"@types/node": "^22.8.6", | ||
"@types/prettier": "^3.0.0", | ||
"@types/node": "^22.10.1", | ||
"@types/proxyquire": "^1.3.31", | ||
"@types/sinon": "^17.0.3", | ||
"@types/sinon-chai": "^3.2.12", | ||
"@typescript-eslint/eslint-plugin": "^7.15.0", | ||
"@typescript-eslint/parser": "^7.15.0", | ||
"chai": "^4.4.1", | ||
"chai-as-promised": "^7.1.2", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"mocha": "^10.7.3", | ||
"prettier": "^3.3.3", | ||
"proxyquire": "^2.1.3", | ||
"sinon": "^17.0.1", | ||
"sinon": "^19.0.2", | ||
"sinon-chai": "^3.7.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.7.2" | ||
}, | ||
@@ -83,3 +75,3 @@ "main": "build/main.js", | ||
"check": "tsc --noEmit", | ||
"lint": "eslint --ext .ts src/ --fix", | ||
"lint": "eslint -c eslint.config.mjs .", | ||
"translate": "translate-adapter", | ||
@@ -86,0 +78,0 @@ "release": "release-script" |
148
README.md
@@ -12,7 +12,10 @@  | ||
**Tests:**  | ||
**Tests: | ||
**  | ||
## alexa-timer-vis adapter for ioBroker | ||
This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers. For more details and for information how to disable the error reporting see Sentry-Plugin Documentation! Sentry reporting is used starting with js-controller 3.0. | ||
This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers. For more | ||
details and for information how to disable the error reporting see Sentry-Plugin Documentation! Sentry reporting is used | ||
starting with js-controller 3.0. | ||
@@ -31,26 +34,27 @@ Output Alexa timer to display in the vis | ||
A timer or several by voice input, is created via Alexa, this is evaluated by the adapter and written in states in order to make them visible in the Vis. So you have a better overview if you have several timers active at the same time. | ||
A timer or several by voice input, is created via Alexa, this is evaluated by the adapter and written in states in order | ||
to make them visible in the Vis. So you have a better overview if you have several timers active at the same time. | ||
- ---- Alexa2 Adapter is needed ---- | ||
- The Vis Widget isn´t yet integrated | ||
- Every Timer has a button, to stop it. Stops the Timer in Alexa and in the Adapter | ||
- Unlimited timers can be created with Alexa by voice command. | ||
- When the adapter is started, 4 folders are created with all of the states. | ||
- Additional folders will be created as soon as a 5th and more timers are created via Alexa's voice input. | ||
- It works with German input | ||
- ---- Alexa2 Adapter is needed ---- | ||
- The Vis Widget isn´t yet integrated | ||
- Every Timer has a button, to stop it. Stops the Timer in Alexa and in the Adapter | ||
- Unlimited timers can be created with Alexa by voice command. | ||
- When the adapter is started, 4 folders are created with all of the states. | ||
- Additional folders will be created as soon as a 5th and more timers are created via Alexa's voice input. | ||
- It works with German input | ||
### Timer add ( Examples ) | ||
- Alexa, Timer 5 minutes | ||
- Alexa, fries Timer 9 minutes | ||
- Alexa, set a timer for 1 hour and 30 minutes | ||
- Alexa, set a Timer for 2 hours | ||
- Alexa, Timer for 120 minutes | ||
- Alexa, Timer 9 minutes Spaghetti | ||
- Alexa, Timer 5 minutes | ||
- Alexa, fries Timer 9 minutes | ||
- Alexa, set a timer for 1 hour and 30 minutes | ||
- Alexa, set a Timer for 2 hours | ||
- Alexa, Timer for 120 minutes | ||
- Alexa, Timer 9 minutes Spaghetti | ||
### Timer delete ( Examples ) | ||
- Alexa, delete all Timers | ||
- Alexa, delete fries Timer | ||
- Alexa, delete 5 minutes Timer | ||
- Alexa, delete all Timers | ||
- Alexa, delete fries Timer | ||
- Alexa, delete 5 minutes Timer | ||
@@ -65,141 +69,147 @@ ### If you have any suggestions for improving something or adding other functions, feel free to contact us | ||
--> | ||
### 2.0.8 (2024-12-04) | ||
- CHORE: Update dependencies | ||
- CHORE: Migration to ESLint 9 and @iobroker/eslint-config | ||
### 2.0.7 (2024-11-19) | ||
- FIX: #157 Add size attribute xl for text in jsonConfig | ||
- FIX: #156 Error in decomposeInputValue | ||
- FIX: #157 Add size attribute xl for text in jsonConfig | ||
- FIX: #156 Error in decomposeInputValue | ||
### 2.0.6 (2024-10-19) | ||
- FEAT: #151 Responsive Design | ||
- FEAT: #151 Responsive Design | ||
### 2.0.5 (2024-09-26) | ||
- FIX: #142 Timeout error | ||
- FIX: #137 Reset timer name | ||
- FEAT: Add json state | ||
- FIX: #142 Timeout error | ||
- FIX: #137 Reset timer name | ||
- FEAT: Add json state | ||
### 2.0.4 (2024-09-18) | ||
- FIX: #132 Second timer button reset deletes timer one | ||
- FIX: #132 Second timer button reset deletes timer one | ||
### 2.0.3 (2024-09-13) | ||
- FIX: #133 Timer names are not correct | ||
- FIX: #134 All timer alive at start | ||
- FIX: #133 Timer names are not correct | ||
- FIX: #134 All timer alive at start | ||
### 2.0.2 (2024-09-12) | ||
- FIX: #130 Sting_2 remains empty | ||
- FIX: #130 Sting_2 remains empty | ||
### 2.0.1 (2024-09-10) | ||
- FIX: #128 Timer creating error | ||
- FIX: #128 Timer creating error | ||
### 2.0.0 (2024-09-08) | ||
- FIX: #119 Error "has no existing object" on first start | ||
- FEAT: Use Typescript | ||
- FEAT: #118 get name from activeTimerList | ||
- FIX: #117 createDevice is deprecated | ||
- FIX: #119 Error "has no existing object" on first start | ||
- FEAT: Use Typescript | ||
- FEAT: #118 get name from activeTimerList | ||
- FIX: #117 createDevice is deprecated | ||
### 1.0.0 (2024-08-09) | ||
- Js-controller >=5.0.19 is required | ||
- Js-controller >=5.0.19 is required | ||
### 0.3.0 (2023-12-23) | ||
- FIX: #82 Delete Timer by Button | ||
- FIX: #74 Start time | ||
- FEAT: #71 Name of Echo in data tree | ||
- FEAT: #75 Percent from 0% to 100% | ||
- Breaking change: minimal supported node.js version is 16.x | ||
- FEAT: #58 Another String Variation | ||
- FIX: #82 Delete Timer by Button | ||
- FIX: #74 Start time | ||
- FEAT: #71 Name of Echo in data tree | ||
- FEAT: #75 Percent from 0% to 100% | ||
- Breaking change: minimal supported node.js version is 16.x | ||
- FEAT: #58 Another String Variation | ||
### 0.2.0 (2023-07-27) | ||
- create Timer with Alexa2 TextCommand, fixed | ||
- lengthen and shorten timers | ||
- create Timer with Alexa2 TextCommand, fixed | ||
- lengthen and shorten timers | ||
### 0.1.15 (22.09.2022) | ||
- Include creation time to avoid creating duplicate timers | ||
- Include creation time to avoid creating duplicate timers | ||
### 0.1.14 (17.07.2022) | ||
- Added debouncing in the adapter configuration | ||
- Added debouncing in the adapter configuration | ||
### 0.0.13 (06.03.2022) | ||
- Delete of Timers with the same value, fixed | ||
- Delete of Timers with the same value, fixed | ||
### 0.1.12 (15.02.2022) | ||
- Delete of Timer fixed | ||
- Delete of Timer fixed | ||
### 0.1.11 (12.02.2022) | ||
- Delete of Timer with same Inputvalue, fixed | ||
- User can set the Intervall in admin | ||
- Delete of Timer with same Inputvalue, fixed | ||
- User can set the Intervall in admin | ||
### 0.1.9 (30.1.2022) | ||
- Bugfix | ||
- Bugfix | ||
### 0.1.8 (28.01.2022) | ||
- Bugfix | ||
- Button added to stop the Timer | ||
- Bugfix | ||
- Button added to stop the Timer | ||
### 0.1.7 (22.06.2022) | ||
- New State, "Input Device" | ||
- New State, "Input Device" | ||
### 0.1.6 (17.01.2022) | ||
- numbers from 1-9 are always displayed as two digits, 1 => 01 | ||
- When you update to this or a newer Version, please delete the timer folders or delete the whole adapter, otherwise errors will occur | ||
- numbers from 1-9 are always displayed as two digits, 1 => 01 | ||
- When you update to this or a newer Version, please delete the timer folders or delete the whole adapter, otherwise | ||
errors will occur | ||
### 0.1.5 (08.01.2022) | ||
- New keywords added | ||
- New keywords added | ||
### 0.1.4 (05.01.2022) | ||
- States will be reset on adapter unload | ||
- Bugfix | ||
- States will be reset on adapter unload | ||
- Bugfix | ||
### 0.1.3 (02.01.2022) | ||
- Start and EndTime added | ||
- Start and EndTime added | ||
### 0.1.2 (31.12.2021) | ||
- Bugfix (A double created Intervall, fixed) | ||
- Bugfix (A double created Intervall, fixed) | ||
### 0.1.1 (29.12.2021) | ||
- Adaptation to the English language (experimental) | ||
- Anpassung an die Englische Sprache (experimentell) | ||
- Adaptation to the English language (experimental) | ||
- Anpassung an die Englische Sprache (experimentell) | ||
### 0.1.0 (28.12.021) | ||
- Fixed bug when deleting intervals and timeouts after shutdown | ||
- Fehler beim Löschen von Intervallen und Timeouts nach dem Shutdown, behoben | ||
- Fixed bug when deleting intervals and timeouts after shutdown | ||
- Fehler beim Löschen von Intervallen und Timeouts nach dem Shutdown, behoben | ||
### 0.0.4 (27.12.2021) | ||
- Adaptation to various options for entering a timer | ||
- Anpassung an verschiedener Möglichkeiten der Eingabe eines Timers | ||
- Adaptation to various options for entering a timer | ||
- Anpassung an verschiedener Möglichkeiten der Eingabe eines Timers | ||
### 0.0.3 (26.12.2021) | ||
- Bugfix | ||
- Bugfix | ||
### 0.0.2 (26.12.2021) | ||
- Bugfix | ||
- Bugfix | ||
### 0.0.1 (25.12.2021) | ||
- initial release | ||
- initial release | ||
@@ -206,0 +216,0 @@ ## License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
422484
23
2876
236