Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Script Engine v.4.1.3 - Blockly - Timeout - timeout is not defined #334

Closed
Reelfan opened this issue Feb 23, 2019 · 5 comments
Closed

Comments

@Reelfan
Copy link

Reelfan commented Feb 23, 2019

Bei der Nutzung von Timeout in einem Blockly Script "fehlt" am Anfang eine Definition für Timeout, das wiederum führt zum Fehler "Error in callback: ReferenceError: timeout is not defined".

Anbei ein Muster:
grafik

on({id: 'shelly.0.SHSW-1#32786F#1.Relay0.Switch', change: "ne"}, function (obj) {
  var value = obj.state.val;
  var oldValue = obj.oldState.val;
  if (getState("shelly.0.SHSW-1#32786F#1.Relay0.Switch").val == true && getState("zigbee.0.00158d0001ad6a7d.occupancy").val == true) {
    (function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
  } else if (getState("zigbee.0.00158d0001ad6a7d.occupancy").val == false) {
    (function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
    timeout = setTimeout(function () {
      setState("shelly.0.SHSW-1#32786F#1.Relay0.Switch"/*Switch*/, false);
    }, 60000);
  }
});
@S401967
Copy link

S401967 commented Feb 23, 2019

In den alten (vorhandenen) Blockly's ist das Timeout noch als Variable deklariert.

`var timeout;

on({id: "sonoff.0.Treppenlicht.POWER"/Treppenlicht POWER/, change: "ne"}, function (obj) {
var value = obj.state.val;
var oldValue = obj.oldState.val;
if (getState("sonoff.0.Treppenlicht.POWER").val == true) {
(function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
timeout = setTimeout(function () {
if (getState("sonoff.0.Treppenlicht.POWER").val == true) {
setState("sonoff.0.Treppenlicht.POWER"/Treppenlicht POWER/, false);
}
}, 600000);
}
});`

erst wenn man eine Variable dazu tut, funktioniert das Script wieder und wird am Anfang des Script angezeigt.

image

@S401967
Copy link

S401967 commented Feb 23, 2019

In der Version 4.1.4 funktioniert es wieder

@Reelfan
Copy link
Author

Reelfan commented Feb 23, 2019

Danke habe auch gerade den fix gesehen, hast Du vom github installiert ?

@Reelfan
Copy link
Author

Reelfan commented Feb 23, 2019

Kann auch bestätigen 4.1.4 löst das Problem

@S401967
Copy link

S401967 commented Feb 23, 2019

Ja nach dem installieren der Version von github, (4.1.4) war der Eintrag der Variable wieder vorhanden.

@Reelfan Reelfan closed this as completed Feb 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants