Problem with second timer within one rule

Hello community,

I’m working on a rule which offers multiplie function by using one switch. The Switch is an LCN-switch, witch drives to virtual relays - one toggles each time, the switch is pressed short, the other will be ‘ON’ if the switch is pressed long and will be released to ‘OFF’ when the switch is no mor pressed. This actions drive a HUE color lamp …

Within the rule I first detect wheater a key was pressed twice or only on time … so I got swtich states for (pressed once short, pressd once long, pressed short twice, pressed short plus long and relase) → (keyPressedShort, Long, DoubleShort, ShortPlusLong, Released).

Do discover the double press action I use one timer (KeyTimer) and measure the time between to trigger actions … so far so good, this works pretty well.

In the second part of the rule I handle the ‘actionState’ … means interpreting what the user have done with the switch (single pressed, double pressed …). For the states i defined the following

DoubleShort … shitch between brightness- and color-mode
long … change brightess (this part works) or change color (won’t work)

So now we come to the problem … the color change. For this I planed to use a second timer, which should be retriggered until the long pressed switch will be released. Within the rule I increment or decrement the current color (hue) - you can find this part of the code within the switch statement in the case ‘Long’. My problem is, that it seams that the timer will not start and I dispair, becouse I don’t understand why. I think this is a simple problem, but I’m not able to see whats going wrong.

var keyPressedShort         = 'Module11KGStef_Relais7';
var keyPressedLongOrRelease = 'Module11KGStef_Relais8';
var doublePressedTime       = 600 ; // Unit = ms
var hueLightItem            = 'Huecolorlamp2TestLeuchte_Farbe' ;
var hueLightAddress         = 'hue:0210:02648f68d9:2';
var DIM_TIME                = 4000;  // defines the time for an dim-cycle from 0 to 100%
var defaultBrightness       = 60;   // Unit = %
var hueStepTime             = 50 ; // Unit = ms
var hueChangeStep           = 5 ;  // Unit = degree


var triggerTime             = Java.type('java.time.Instant') ;
var lastActionTime, currentActionTime, deltaActionTime lastBrigthness;
var actionState

// Brightness/Color Dimmer VARs
var things                  = Java.type('org.openhab.core.model.script.actions.Things');
var currentHueState         = Java.type('org.openhab.core.library.types.HSBType');

var Brightness, Saturation, Hue, dimDirection, dimTime, fadeToBrightness, HSBstring;
var BrightnessShort, SaturationShort, HueShort ;
var dimmerMode;
var currentState;

var instantTime             = Java.type('java.time.Instant') ;
var zdt                     = Java.type('java.time.ZonedDateTime');

var scriptExecution         = Java.type('org.openhab.core.model.script.actions.ScriptExecution');
var hueScriptExecution      = Java.type('org.openhab.core.model.script.actions.ScriptExecution');

if (typeof this.timers === 'undefined') {
  this.timers = [];
}

// Initialize VARs once
if (lastActionTime == NaN) lastActionTime = 0;
if (lastBrigthness == NaN) lastBrigthness = defaultBrightness;
if ((dimmerMode != 'brightness') && (dimmerMode != 'color')) dimmerMode = 'brightness';

// estimate the time between to trigger-events
currentActionTime = triggerTime.now().toEpochMilli() ;
deltaActionTime = currentActionTime - lastActionTime ;
lastActionTime = currentActionTime ;

//switch (triggerItemName = event.itemName) {
switch (event.itemName) {
  case keyPressedShort          : if (deltaActionTime < doublePressedTime){
                                    // Timer is running/defined --> second time pressed within the doublePressedTime
                                    if (typeof this.timers['KeyTimer'] !== 'undefined') {
                                      this.timers['KeyTimer'].cancel();
                                      this.timers['KeyTimer'] = undefined;
                                      actionState = 'DoubleShort' ;
                                    }
                                  } else {
                                    // Not running Timer --> first hit ... so start a timer for doublePressedTime
                                    if ((typeof this.timers['KeyTimer'] === 'undefined') || (this.timers['KeyTimer'].hasTerminated())) {
                                      actionState = 'FirstAction';
                                      this.timers['KeyTimer'] = scriptExecution.createTimer(zdt.now().plusNanos(doublePressedTime*1000000), function () {
                                        if (typeof this.timers['KeyTimer'] !== 'undefined') {
                                          this.timers['KeyTimer'].cancel();
                                          this.timers['KeyTimer'] = undefined;
                                          actionState = 'Short' ;
                                          print ('. ') ;                                                                   // DEBUG !!!!!!!!!!!!!!!!
                                          
                                          var currentState    = itemRegistry.getItem(hueLightItem).getState();
                                          var HueShort        = currentState.getHue();
                                          var BrightnessShort = currentState.getBrightness();
                                          var SaturationShort = currentState.getSaturation();
                                          
                                          if (BrightnessShort == 0) {
                                            Brightness = lastBrigthness;
                                            events.sendCommand(hueLightItem, HueShort.toString() + "," + SaturationShort.toString() + "," + Brightness.toString());
                                          } else {
                                            events.sendCommand(hueLightItem, HueShort.toString() + "," + SaturationShort.toString() + ", 0");
                                            lastBrigthness = BrightnessShort;
                                          }
                                        }
                                      })
                                    } else {
                                      this.timers['KeyTimer'].cancel();
                                      this.timers['KeyTimer'] = undefined;
                                      actionState = 'TimerProblems' ;
                                    }
                                  }
                                  break ;
    
  case keyPressedLongOrRelease  : if (actionState == 'FirstAction') {
                                    if ((typeof this.timers['KeyTimer'] !== 'undefined') && ((this.timers['KeyTimer'].isRunning()) || this.timers['KeyTimer'].hasTerminated())) {
                                      this.timers['KeyTimer'].cancel();
                                      this.timers['KeyTimer'] = undefined;
                                    }

                                    if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                      actionState = 'ShortPlusLong' ;
                                    } else {
                                      actionState = "'Don't Know" ;
                                    }
                                  } else {
                                    if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                      actionState = 'Long' ;
                                    } else {
                                      actionState = 'Released' ;
                                    }
                                  }
                                  break ;
    
  default                       : break ;
};

switch (actionState) {
  case 'DoubleShort'    : {print('..')} ;                                                                              // DEBUG !!!!!!!!!!!!!!!!
                          if (dimmerMode == 'color') {
                            dimmerMode = 'brightness' ;
                          } else {
                            dimmerMode = 'color' ;
                          }
                          print (dimmerMode) ;                                                                        // DEBUG !!!!!!!!!!!!!!!!
                          break ;
  
  case 'ShortPlusLong'  : {print('.-')} ;
                          break ;
 
  case 'Long'           : {print('- ')} ;
                          currentState = itemRegistry.getItem(hueLightItem).getState();
                          Hue        = currentState.getHue();
                          Brightness = currentState.getBrightness();
                          Saturation = currentState.getSaturation();
    
                          print (dimmerMode);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                          if (dimmerMode == 'brightness') {
                            print('BRI') ;                                                                            // DEBUG !!!!!!!!!!!!!!!!
                            if ((Brightness == 0) || (dimDirection == 'up')){
                              fadeToBrightness = 100 ;
                              dimTime          = (100-Brightness)*DIM_TIME/100 ;
                            } else {
                              fadeToBrightness = 0 ;
                              dimTime          = Brightness*DIM_TIME/100 ;
                            }
                            startTime = instantTime.now().toEpochMilli() ;

                            things.getActions('hue',hueLightAddress).fadingLightCommand("color", new PercentType(fadeToBrightness), new DecimalType(dimTime));    
                          } else {
                            print('COL') ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                            if ((typeof this.timers['hueTimer'] === 'undefined') || (this.timers['hueTimer'].hasTerminated())) {
                              this.timers['hueTimer'] = hueScriptExecution.createTimer(zdt.now().plusNanos(hueStepTime*1000000), function () {
                                if (dimDirection == 'up') {
                                  if ((Hue += hueChangeStep) > 359) {
                                    Hue = 0 ;
                                  }
                                } else {
                                  if ((Hue -= hueChangeStep) < 0) {
                                    Hue = 359 ;
                                  }
                                }
                                print(Hue);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                                events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());

                                if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                  print('Reschedule');                                                              // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000)) ;
                                } else {
                                  print ('Cancel');                                                                 // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].cancel();
                                  this.timers['hueTimer'] = undefined;
                                }
                                print('TheEnd');                                                                    // DEBUG !!!!!!!!!!!!!!!!
                              })
                            } else {
                              print ('Reschedule2');                                                                // DEBUG !!!!!!!!!!!!!!!!
                              this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000));
                            }
                          }
                          break ;
 
  case 'Released'       : {print('**')} ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                          if (dimmerMode == 'brightness') {
                            deltaTime = (instantTime.now().toEpochMilli() - startTime)/DIM_TIME * 100;
                            if (dimDirection == 'up') {
                              dimDirection = 'down' ;
                              if ((Brightness = Brightness + deltaTime) > 100) Brightness = 100 ;
                            } else {
                              dimDirection = 'up' ;
                              if ((Brightness = Brightness - deltaTime) < 0) Brightness = 0 ;
                            }
                            events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());
                          } else {
                            if (dimDirection == 'up') {
                              dimDirection = 'down' ;
                            } else
                              dimDirection = 'up';
                          }
                          break ;

  default               : break ;
}

I hope that someone of you can help me with a simple … “this ist wrong, you have to do it that what …”

Okay, thanks for your help
Stef

Without reading through everything I can only recommend to add some kind of loging prior to all switch and if/else blocks, that you always know how the expression are executing and don’t have to guess. This will solve 90% of the issues, as actual script behavior and expected behavior is different

Thanks Matthias … using Log-Infos is a problem, because I use openhab within a docker container on mit server. What I can do, and did, is using print statements you can see inside of the code, with a comment //DEBUG. And with them I can see that the part if code with the repeating timer will only entered once.

  case 'Long'           : {print('- ')} ;
                          currentState = itemRegistry.getItem(hueLightItem).getState();
                          Hue        = currentState.getHue();
                          Brightness = currentState.getBrightness();
                          Saturation = currentState.getSaturation();
    
                          print (dimmerMode);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                          if (dimmerMode == 'brightness') {
                            print('BRI') ;                                                                            // DEBUG !!!!!!!!!!!!!!!!
                            if ((Brightness == 0) || (dimDirection == 'up')){
                              fadeToBrightness = 100 ;
                              dimTime          = (100-Brightness)*DIM_TIME/100 ;
                            } else {
                              fadeToBrightness = 0 ;
                              dimTime          = Brightness*DIM_TIME/100 ;
                            }
                            startTime = instantTime.now().toEpochMilli() ;

                            things.getActions('hue',hueLightAddress).fadingLightCommand("color", new PercentType(fadeToBrightness), new DecimalType(dimTime));    
                          } else {
                            print('COL') ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                            if ((typeof this.timers['hueTimer'] === 'undefined') || (this.timers['hueTimer'].hasTerminated())) {
                              this.timers['hueTimer'] = hueScriptExecution.createTimer(zdt.now().plusNanos(hueStepTime*1000000), function () {
                                if (dimDirection == 'up') {
                                  if ((Hue += hueChangeStep) > 359) {
                                    Hue = 0 ;
                                  }
                                } else {
                                  if ((Hue -= hueChangeStep) < 0) {
                                    Hue = 359 ;
                                  }
                                }
                                print(Hue);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                                events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());

                                if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                  print('Reschedule');                                                              // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000)) ;
                                } else {
                                  print ('Cancel');                                                                 // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].cancel();
                                  this.timers['hueTimer'] = undefined;
                                }
                                print('TheEnd');                                                                    // DEBUG !!!!!!!!!!!!!!!!
                              })
                            } else {
                              print ('Reschedule2');                                                                // DEBUG !!!!!!!!!!!!!!!!
                              this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000));
                            }
                          }
                          break ;

Above is the part of the code, which includes the second timer (huerTimer) …

If the part of code with the timer is only executed once, but you expect to run it twice, than the issue is before in another part of the code (assuming that the rule of actually running twice, what you would verify).

You are using two switch statements and I would log / print the variable that impacts the switch statement.

E.g. for

switch (actionState)

I would add a

print(actionState)

before. (Same for all if blocks accordingly)

Most likely the actionState or any other variable have an unexpected value and you need to investigate, why your variable is set with the unexpected value and fix this.

Without seeing logs or prints and as there is no way to debug the code we can only guess.

A still have print assigments within each case state … so I can still see which state ist entered. What I see with the pront assigments, that the correct state is entered an within the state, the correct if section is entered (‘COL’). After that the timer will be setup and I can see the next Hue-value. Sofar everything is fine. But exactly this prints should occur until I release the switch. Every path within this code as print assigments, but none of them will be printed out.

                            print('COL') ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                            if ((typeof this.timers['hueTimer'] === 'undefined') || (this.timers['hueTimer'].hasTerminated())) {
                              this.timers['hueTimer'] = hueScriptExecution.createTimer(zdt.now().plusNanos(hueStepTime*1000000), function () {
                                if (dimDirection == 'up') {
                                  if ((Hue += hueChangeStep) > 359) {
                                    Hue = 0 ;
                                  }
                                } else {
                                  if ((Hue -= hueChangeStep) < 0) {
                                    Hue = 359 ;
                                  }
                                }
                                print(Hue);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                                events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());

                                if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                  print('Reschedule');                                                              // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000)) ;
                                } else {
                                  print ('Cancel');                                                                 // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].cancel();
                                  this.timers['hueTimer'] = undefined;
                                }
                                print('TheEnd');                                                                    // DEBUG !!!!!!!!!!!!!!!!
                              })
                            } else {
                              print ('Reschedule2');                                                                // DEBUG !!!!!!!!!!!!!!!!
                              this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000));
                            }

So from my point of view, the timer won’t start … or I have a completly misunderstanding of the usage of timers. For that I implemented the importend lines bith blockly and verified the generated code with mine … and Iit locks quide equal …

Not sure if I understood correct what you want and what’s working / not working.

If you say

But exactly this prints should occur until I release the switch.

You want to have a timer that will run & reschedule as long as the item state of keyPressedLongOrRelease is on? Or do you want to have the entire rule to run again as long as the item is ON (= you press keep the button pressed)?

Also not sure about the following

After that the timer will be setup and I can see the next Hue-value.

Vs

So from my point of view, the timer won’t start

If you see the result of print(hue) [what’s part of the code executed while the timer is running], than that’s the proof that the timer is working at least once.

Maybe increase for testing your hueStepTme, so that the timer will only run e.g. after 2 seconds instead of 20x within one second, what would make it easier to see if the timer is running or not.

Okay I try to explain the problem in a better way, relating to the code …

The second switch startement

switch (actionState) {

will be entered and the

case 'Long'           : {print('- ')} ;

case will successfully entered. I see the printe "- " in my logviewer. Inside of the state I can follow the execution until the timer should start …

                          } else {
                            print('COL') ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                            if ((typeof this.timers['hueTimer'] === 'undefined') || (this.timers['hueTimer'].hasTerminated())) {
                              this.timers['hueTimer'] = hueScriptExecution.createTimer(zdt.now().plusNanos(hueStepTime*1000000), function () {
                                if (dimDirection == 'up') {
                                  if ((Hue += hueChangeStep) > 359) {
                                    Hue = 0 ;
                                  }
                                } else {
                                  if ((Hue -= hueChangeStep) < 0) {
                                    Hue = 359 ;
                                  }
                                }
                                print(Hue);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                                events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());

also here I can see the new ‘Hue’-value, which ist printed to the loging output. So now the timer should run and this part of the code should be entered until


                                if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                  print('Reschedule');                                                              // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000)) ;
                                } else {
                                  print ('Cancel');                                                                 // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].cancel();
                                  this.timers['hueTimer'] = undefined;
                                }
                                print('TheEnd');                                                                    // DEBUG !!!!!!!!!!!!!!!!

the switch is not released which should result in a reschedul or the state or the switch is released an the timer will be terminated. BUT … I cant see any further logging outputs, which includes I can’t see the ‘TheEnd’ log, which is part of the code the should be executed within the timer-routine.
The next log-output I can see is the release of the key/switch which shoul appear because the state of the switch has changed an the rule will be triggered again.

  case 'Released'       : {print('**')} ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                          if (dimmerMode == 'brightness') {
                            deltaTime = (instantTime.now().toEpochMilli() - startTime)/DIM_TIME * 100;
                            if (dimDirection == 'up') {
                              dimDirection = 'down' ;
                              if ((Brightness = Brightness + deltaTime) > 100) Brightness = 100 ;
                            } else {
                              dimDirection = 'up' ;
                              if ((Brightness = Brightness - deltaTime) < 0) Brightness = 0 ;
                            }
                            events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());
                          } else {
                            if (dimDirection == 'up') {
                              dimDirection = 'down' ;
                            } else
                              dimDirection = 'up';
                          }
                          break ;

My Log looks like that:

- 
brightness
BRI
**
..
color
- 
color
COL
73
**
- 
color
COL
68
**
- 
color
COL
73

What did I do? I press the switch LONG → '- ’ + ‘brightness’ + ‘BRI’ were logged. Than I release the switch and '** ’ was logged. Then I pressed the switch two times short which results in the log with ‘…’ and the mode change to ‘color’.
Then I’ve pressed the switch long again an see '- ’ + ‘color’ + ‘COL’ + ‘73’ which is the Hue-value. After a couple of seconds I release the switch again and a ‘**’ appears which informs that the switch is released.
So you can see that the piece of code which should repeat sometimes because of the rescheduling timer won’t be excuted as often …

                          } else {
                            print('COL') ;                                                                           // DEBUG !!!!!!!!!!!!!!!!
                            if ((typeof this.timers['hueTimer'] === 'undefined') || (this.timers['hueTimer'].hasTerminated())) {
                              this.timers['hueTimer'] = hueScriptExecution.createTimer(zdt.now().plusNanos(hueStepTime*1000000), function () {
                                if (dimDirection == 'up') {
                                  if ((Hue += hueChangeStep) > 359) {
                                    Hue = 0 ;
                                  }
                                } else {
                                  if ((Hue -= hueChangeStep) < 0) {
                                    Hue = 359 ;
                                  }
                                }
                                print(Hue);                                                                         // DEBUG !!!!!!!!!!!!!!!!
                                events.sendCommand(hueLightItem, Hue.toString() + "," + Saturation.toString() + "," + Brightness.toString());

                                if (itemRegistry.getItem(keyPressedLongOrRelease).getState() == 'ON') {
                                  print('Reschedule');                                                              // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000)) ;
                                } else {
                                  print ('Cancel');                                                                 // DEBUG !!!!!!!!!!!!!!!!
                                  this.timers['hueTimer'].cancel();
                                  this.timers['hueTimer'] = undefined;
                                }
                                print('TheEnd');                                                                    // DEBUG !!!!!!!!!!!!!!!!
                              })
                            } else {
                              print ('Reschedule2');                                                                // DEBUG !!!!!!!!!!!!!!!!
                              this.timers['hueTimer'].reschedule(zdt.now().plusNanos(hueStepTime*1000000));
                            }
                          }
                          break ;

I hope that the problem now becomes a bit more clear. I think that the timer usage is part of the problem, but I can’t see a mistake … :weary:

I don’t understand why that is a problem. Doing any development on your system is going to be difficult without working logging.
It would be really helpful to have timestamps while you are investigating a timer issue, for example.

So if you do not get the reschedules that you expected, but the reschedule is conditional, maybe you should log out the condition?

Thanks, thats more clear now.
If one line of the code is executing but next line not, than something is wrong in the code. Either a typo or a function will throw an exception. Viewing the log file would help. You should be able to access the log file even using docker (e.g. using the terminal you can view the log files).

If the last part of code that is executed is the print(Hue); do you know if the command is successfully send to the item? You can use the event stream within the developer tools to check if the command was executed or not.

Also we do not know the state of the item you use for the if condition, and if the IF or ELSE part is executed. In the else part there is a space between print and the brackets, not sure if the engine will ignore it.

Yes, thats what I also would recommend, however there is also an ELSE part in the code and either IF or ELSE should get executed. But based on the print output non of the blocks is running.

Hello together … I checked whether I command (change of the light color) will be executed or not. To do this, I changed the colorStep from 5 to 100, to get a clear change. I don’t what happend then … but now it works, without any changes to the timer-code.

I am embarrassed, but I can’t explain what have changed too. After saving the rule the execution was stoppped first because of am missing comma, but this should happend also be for, but id didn’t. So, sorry, but I don’t know what happend …

Anyway, it changed the values for the hueStepTime back to 100ms (I changed them to 1s befor) and the hueChangeStep to 5 degrees as well.

My log looks now as aspected

0
Reschedule
TheEnd
5
Reschedule
TheEnd
10
Reschedule
TheEnd
15
Reschedule
TheEnd
20
Reschedule
TheEnd
25
Reschedule
TheEnd
30
Reschedule
TheEnd
35
Reschedule
TheEnd
**
30
Cancel

What is a bit unsatisfactory now is that I don’t know what the problem was.

Thanks for … what ever … :wink:

@rossko57 wrote:

I don’t understand why that is a problem. Doing any development on your system is going to be difficult without working logging.

Of course I can view the logging informations from openhap.log and events.log (tail -f openhab.log events.log), but code like this

logger.error('abc');
logger.warn('abc');
logger.info('abc');
logger.debug('abc');
logger.trace('abc');

won’t appear there. So I have to use the print command to show debug or logging informations inside the log window of my docker session.

Here too, I don’t know why logger.xxxx-commands won’t work as expected.

Me neither. They work for other people. You have to get a logger instance first - what have you tried for that?
Something like

var logger          = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.example');

Ups … I didn’t use … nothing. Then I looked to that what blockly do, copied the following line

var logger          = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

well … what should I see … it’s magic, I see log-messages … :wink:

Thanks this will make some things more easy.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.