iobroker.alexa-timer-vis
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -26,6 +26,5 @@ "use strict"; | ||
var import_global = require("./global"); | ||
var import_timer_data = require("./timer-data"); | ||
const generateValues = (timer, sec, index, inputString, name) => { | ||
const store = (0, import_store.useStore)(); | ||
const timeLeft = import_timer_data.timerObject.timer[index].endTime - (/* @__PURE__ */ new Date()).getTime(); | ||
const timeLeft = timer.endTime - (/* @__PURE__ */ new Date()).getTime(); | ||
const timeLeftSec = Math.round(timeLeft / 1e3); | ||
@@ -36,6 +35,7 @@ const result = (0, import_global.secToHourMinSec)(timeLeftSec, true); | ||
const timeString1 = hour + ":" + minutes + ":" + seconds + getTimeUnit(timeLeftSec, store); | ||
let timeString2 = isGreaterThanSixtyFiveMinutes(hour, minutes, seconds, store); | ||
timeString2 = isShorterOrEqualToSixtyFiveMinutes(hour, minutes, seconds, store, timeString2); | ||
timeString2 = isShorterThanSixtyMinutes(hour, minutes, seconds, store, timeString2); | ||
timeString2 = isShorterThanAMinute(minutes, seconds, store, timeString2); | ||
const { timeString } = isShorterThanAMinute( | ||
isShorterThanSixtyMinutes( | ||
isShorterOrEqualToSixtyFiveMinutes(isGreaterThanSixtyFiveMinutes(hour, minutes, seconds, store)) | ||
) | ||
); | ||
if (!timer.changeValue) { | ||
@@ -49,3 +49,3 @@ timer.onlySec = sec; | ||
timer.string_Timer = timeString1; | ||
timer.string_2_Timer = timeString2; | ||
timer.string_2_Timer = timeString; | ||
timer.timeLeftSec = timeLeftSec; | ||
@@ -57,4 +57,3 @@ timer.index = index; | ||
timer.lengthTimer = lengthTimer; | ||
name = setTimerNameIfNotExist(name); | ||
import_timer_data.timerObject.timer[index].name = name; | ||
timer.name = setTimerNameIfNotExist(name); | ||
return timeLeftSec; | ||
@@ -79,25 +78,40 @@ }; | ||
} | ||
function isShorterThanAMinute(minutes, seconds, store, timeString) { | ||
function isShorterThanAMinute({ minutes, seconds, store, timeString }) { | ||
if (parseInt(minutes) == 0) { | ||
return seconds + " " + store.unitSecond3; | ||
return { timeString: seconds + " " + store.unitSecond3 }; | ||
} | ||
return timeString; | ||
return { timeString }; | ||
} | ||
function isShorterOrEqualToSixtyFiveMinutes(hour, minutes, seconds, store, timeString) { | ||
function isShorterOrEqualToSixtyFiveMinutes({ | ||
hour, | ||
minutes, | ||
seconds, | ||
store, | ||
timeString | ||
}) { | ||
if (parseInt(hour) === 1 && parseInt(minutes) <= 5) { | ||
return (parseInt(minutes) + 60).toString() + ":" + seconds + " " + store.unitMinute3; | ||
const timeString2 = hour + ":" + minutes + ":" + seconds + " " + store.unitHour3; | ||
return { timeString: timeString2, hour, minutes, seconds, store }; | ||
} | ||
return timeString; | ||
return { timeString, hour, minutes, seconds, store }; | ||
} | ||
function isShorterThanSixtyMinutes(hour, minutes, seconds, store, timerString) { | ||
function isShorterThanSixtyMinutes({ | ||
hour, | ||
minutes, | ||
seconds, | ||
store, | ||
timeString | ||
}) { | ||
if (parseInt(hour) == 0) { | ||
return minutes + ":" + seconds + " " + store.unitMinute3; | ||
const timeString2 = minutes + ":" + seconds + " " + store.unitMinute3; | ||
return { timeString: timeString2, hour, minutes, seconds, store }; | ||
} | ||
return timerString; | ||
return { timeString, hour, minutes, seconds, store }; | ||
} | ||
function isGreaterThanSixtyFiveMinutes(hour, minutes, seconds, store) { | ||
if (parseInt(hour) > 1 || parseInt(hour) === 1 && parseInt(minutes) > 5) { | ||
return hour + ":" + minutes + ":" + seconds + " " + store.unitHour3; | ||
const timeString = hour + ":" + minutes + ":" + seconds + " " + store.unitHour3; | ||
return { timeString, hour, minutes, seconds, store }; | ||
} | ||
return ""; | ||
return { timeString: "", hour, minutes, seconds, store }; | ||
} | ||
@@ -104,0 +118,0 @@ function getTimeUnit(timeLeftSec, store) { |
@@ -38,3 +38,4 @@ "use strict"; | ||
continue; | ||
} else if (arraysTodo[string].includes(element)) { | ||
} | ||
if (arraysTodo[string].includes(element)) { | ||
foundValue = string; | ||
@@ -41,0 +42,0 @@ abortLoop = true; |
@@ -60,3 +60,3 @@ "use strict"; | ||
}; | ||
function resetAllTimerValuesAndState() { | ||
function resetAllTimerValuesAndState(_this) { | ||
Object.keys(import_timer_data.timerObject.timer).forEach((el) => { | ||
@@ -66,2 +66,3 @@ resetValues(import_timer_data.timerObject.timer[el], el); | ||
}); | ||
_this.setStateChanged("all_Timer.alive", false, true); | ||
} | ||
@@ -68,0 +69,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -113,3 +113,2 @@ "use strict"; | ||
serialNumber: "", | ||
timerInput: "", | ||
timerInterval: 0, | ||
@@ -138,3 +137,2 @@ endTime: 0, | ||
serialNumber: "", | ||
timerInput: "", | ||
timerInterval: 0, | ||
@@ -163,3 +161,2 @@ endTime: 0, | ||
serialNumber: "", | ||
timerInput: "", | ||
timerInterval: 0, | ||
@@ -188,3 +185,2 @@ endTime: 0, | ||
serialNumber: "", | ||
timerInput: "", | ||
timerInterval: 0, | ||
@@ -191,0 +187,0 @@ endTime: 0, |
@@ -28,5 +28,4 @@ "use strict"; | ||
var import_timer_data = require("./timer-data"); | ||
const oldJson = []; | ||
let oldJson = []; | ||
const getNewTimerName = (newJsonString, timerSelector) => { | ||
var _a; | ||
const { _this } = (0, import_store.useStore)(); | ||
@@ -38,5 +37,3 @@ let newJson = []; | ||
} | ||
if (!oldJson || oldJson.length === 0 && newJson.length) { | ||
import_timer_data.timerObject.timer[timerSelector].nameFromAlexa = (_a = newJson[0]) == null ? void 0 : _a.label; | ||
} | ||
onlyOneTimerIsActive(newJson, timerSelector); | ||
for (let i = 0; i < newJson.length; i++) { | ||
@@ -47,2 +44,3 @@ const elementExist = oldJson.find((oldElement) => { | ||
} | ||
return false; | ||
}); | ||
@@ -53,2 +51,3 @@ if (!elementExist) { | ||
} | ||
oldJson = newJson; | ||
} catch (e) { | ||
@@ -75,2 +74,8 @@ _this.log.error("Error in checkForNewTimerInObject: " + JSON.stringify(e)); | ||
}; | ||
function onlyOneTimerIsActive(newJson, timerSelector) { | ||
var _a; | ||
if (newJson.length === 1) { | ||
import_timer_data.timerObject.timer[timerSelector].nameFromAlexa = (_a = newJson[0]) == null ? void 0 : _a.label; | ||
} | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -77,0 +82,0 @@ 0 && (module.exports = { |
@@ -91,3 +91,3 @@ "use strict"; | ||
await (0, import_set_adapter_status.setAdapterStatusAndInitStateCreation)(); | ||
(0, import_reset.resetAllTimerValuesAndState)(); | ||
(0, import_reset.resetAllTimerValuesAndState)(this); | ||
let voiceInputOld = null; | ||
@@ -138,15 +138,18 @@ let voiceInput; | ||
} | ||
} else if (id != `alexa-timer-vis.${this.instance}.info.connection` && state && state.val !== false && id != "alexa2.0.History.summary") { | ||
} else if ((0, import_global.isIobrokerValue)(state) && state.val && id.includes("Reset")) { | ||
try { | ||
const timer = id.split(".")[2]; | ||
const timerOb = import_timer_data.timerObject.timer[timer]; | ||
let alexaCommandState; | ||
if ((timerOb == null ? void 0 : timerOb.serialNumber) != void 0) { | ||
alexaCommandState = `alexa2.${store.getAlexaInstanceObject().instance}.Echo-Devices.${timerOb.serialNumber}.Commands.textCommand`; | ||
const alexaCommandState = `alexa2.${store.getAlexaInstanceObject().instance}.Echo-Devices.${timerOb.serialNumber}.Commands.textCommand`; | ||
let name = ""; | ||
if (timerOb.name != "Timer") | ||
if (timerOb.name != "Timer") { | ||
name = timerOb.name; | ||
const alexaTextToCommand = `stoppe ${name} ${timerOb.timerInput} Timer`; | ||
} | ||
(0, import_delete_timer.delTimer)(timer); | ||
this.setForeignState(alexaCommandState, alexaTextToCommand, false); | ||
this.setForeignState( | ||
alexaCommandState, | ||
`stoppe ${timerOb.inputString} ${timerOb.nameFromAlexa && timerOb.nameFromAlexa !== "" ? timerOb.nameFromAlexa : name} Timer`, | ||
false | ||
); | ||
} | ||
@@ -153,0 +156,0 @@ } catch (e) { |
{ | ||
"common": { | ||
"name": "alexa-timer-vis", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"news": { | ||
"2.0.3": { | ||
"en": "FIX: #132 Second timer button reset deletes timer one\nFIX: #133 Timer names are not correct\nFIX: #134 All timer alive at start", | ||
"de": "FIX: #132 Zweite Timer-Taste zurücksetzen Löscht Timer ein\nFIX: #133 Timernamen sind nicht korrekt\nFIX: #134 Alle Timer am Anfang am Leben", | ||
"ru": "FIX: #132 Вторая кнопка таймера удаляет таймер один\nFIX: #133 Имя таймера неправильно\n#134 Все таймеры живы на старте", | ||
"pt": "FIX: #132 Segundo temporizador botão reset exclui temporizador um\nFIX: #133 Os nomes do temporizador não estão corretos\nFIX: #134 Todo o temporizador vivo no início", | ||
"nl": "FIX: #132 Tweede timer knop reset verwijdert timer een\nFIX: #133 Timer namen zijn niet correct\nFIX: #134 Alle timer levend bij het begin", | ||
"fr": "FIX: #132 Deuxième bouton minuterie réinitialise supprime timer un\nFIX: #133 Les noms des minuteurs ne sont pas corrects\nFIXE: #134 Tout le temps vivant au début", | ||
"it": "FIX: #132 Ripristino del secondo timer cancella il timer uno\nFIX: #133 I nomi Timer non sono corretti\nFIX: #134 Tutto il timer vivo all'inizio", | ||
"es": "FIX: #132 El reinicio del botón del temporizador segundo elimina el temporizador uno\nFIX: #133 Timer names are not correct\nFIX: #134 Todo el tiempor vivo al principio", | ||
"pl": "FIX: # 132 Drugi przycisk timer reset usuwa timer jeden\nFIX: # 133 Nazwy czasu nie są poprawne\nFIX: # 134", | ||
"uk": "FIX: #132 Другий таймер кнопка скидання видаляє таймер один\nFIX: #133 Ім'я таймера не виправити\nFIX: #134 Всі таймер живий на старті", | ||
"zh-cn": "FIX: # 132 第二计时器按钮重置删除定时器 1\nFIX: #133 计时器名称不正确\nFIX: #134 所有计时器在开始时还活着" | ||
}, | ||
"2.0.2": { | ||
@@ -83,15 +96,2 @@ "en": "FIX: #130 Sting_2 remains empty", | ||
"zh-cn": "alexa2案文Command的时间限制\n时间长短" | ||
}, | ||
"0.1.15": { | ||
"en": "Include creation time to avoid creating duplicate timers", | ||
"de": "Fügen Sie die Erstellungszeit hinzu, um die Erstellung doppelter Timer zu vermeiden", | ||
"ru": "Включите время создания, чтобы избежать создания повторяющихся таймеров", | ||
"pt": "Inclua o tempo de criação para evitar a criação de cronômetros duplicados", | ||
"nl": "Voeg aanmaaktijd toe om dubbele timers te voorkomen", | ||
"fr": "Inclure l'heure de création pour éviter de créer des minuteries en double", | ||
"it": "Includi l'ora di creazione per evitare di creare timer duplicati", | ||
"es": "Incluya el tiempo de creación para evitar la creación de temporizadores duplicados", | ||
"pl": "Uwzględnij czas utworzenia, aby uniknąć tworzenia zduplikowanych liczników czasu", | ||
"uk": "Включіть час створення, щоб уникнути дублювання таймерів", | ||
"zh-cn": "包括创建时间以避免创建重复的计时器" | ||
} | ||
@@ -98,0 +98,0 @@ }, |
{ | ||
"name": "iobroker.alexa-timer-vis", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Alexa Timer ausgeben um in der Vis anzuzeigen", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -61,2 +61,8 @@ ![Logo](admin/alexa-timer-vis.png) | ||
--> | ||
### 2.0.3 (2024-09-13) | ||
- FIX: #132 Second timer button reset deletes timer one | ||
- FIX: #133 Timer names are not correct | ||
- FIX: #134 All timer alive at start | ||
### 2.0.2 (2024-09-12) | ||
@@ -63,0 +69,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
414039
75
2810
206