VIELEN DANK ^^ Funktioniert bestens.
Noch eine Frage nebenbei. Ich habe einen Datenpunkt als Zahl, die Unit habe ich leer gelassen, da nicht nötig. Min 0 Max 100. So kann ich sagen Alexa Stelle Stufe auf 7. Das komische ist, dass dann als Wert 7.0000001 übergeben wird. Aber warum??? Bei 3 ist es genau 3. Habe das im Code mit Math.round gelöst. Kann man einem Objekt im vorraus Nachkommastellen streichen lassen? Ist das mit der 1 am Ende ein Fehler von Alexa oder dem Cloud Adapter?
Falls noch jemand Infrarot Geräte hat und so ein Code benötigt:
! ````
var Stufe;
var interval;
var timer = null;
var anzahl;
function CountDownPlus(s) { //Funktion Taste Plus im Abstand 1 Sekunde drücken.
setState("broadlink.0.learnedSignals.Ventiplus",true);
s--;
timer = setInterval(function () {
if (s > 0) {
setState("broadlink.0.learnedSignals.Ventiplus",true);
s--;
} else {
if(timer) clearInterval(timer);
}
}, 1000);
}
! function CountDownMinus(s) { //Funktion Taste Minus im Abstand 1 Sekunde drücken.
setState("broadlink.0.learnedSignals.Ventiminus",true);
s--;
timer = setInterval(function () {
if (s > 0) {
setState("broadlink.0.learnedSignals.Ventiminus",true);
s--;
} else {
if(timer) clearInterval(timer);
}
}, 1000);
}
! on({id: "javascript.0.Wind"/javascript.0.Wind/, change: "any"},
! function (obj) {
var x = obj.state.val; //Übergebener Wert von der .Wind ID
x = Math.round(x); //Nachkommastellen wegkürzen
Stufe = (getState("javascript.0.Stufe").val); //Aktuelle Stufe
Stufe = Math.round(Stufe);
! if (Stufe < x) {
anzahl = x - Stufe;
! CountDownPlus(anzahl);
! Stufe = x;
setState("javascript.0.Stufe", Stufe); //Neue aktuelle Stufe
! } else if (Stufe > x) {
anzahl = Stufe - x;
CountDownMinus(anzahl);
Stufe = x; setState("javascript.0.Stufe", Stufe);}});