HFM
(Henning F. Mettge)
March 4, 2018, 9:44am
1
Hi,
everything was fine for months then I restarted openHAB and my javascript rules stopped working.
The error in the log
Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/jslib/triggersAndConditions.js': ReferenceError: "TriggerHandlerFactory" is not defined in <eval> at line number 12
Anyone an idea?
@lewie : Something you can explain?
Thanks in advance!
HFM
HFM
(Henning F. Mettge)
March 4, 2018, 10:52am
3
Hi Harry,
every rule stopped working, so it is nut rule specific.
The following rule is an example:
JSRule({
name: "Music Mode",
description: "",
triggers: [
//IS WORKING: TimerTrigger("0/15 * * * * ?")
//IS WORKING: ChangedEventTrigger("testItemSwitch", "ON", "OFF")
//IS WORKING: UpdatedEventTrigger("testItemSwitch"),
//IS WORKING: CommandEventTrigger("testItemSwitch")
CommandEventTrigger("MusicMode")
],
execute: function( module, input){
logInfo("MusicMode", "MusicMode Switched");
var receivedCommand = getTriggeredData(input).receivedCommand;
var Box_Kitchen_Mode = getItem("Box_Kitchen_Mode");
logInfo("MusicMode", "MusicMode Activated");
if (receivedCommand == 2) {
logInfo("MusicMode", "MusicMode 2a " + Box_Kitchen_Mode.state);
if (Box_Kitchen_Mode.state != 8) {
sendCommand("Box_Kitchen_Mode", 8)
}
logInfo("MusicMode", "MusicMode 2b " + Box_Kitchen_Mode.state);
}
else {
logInfo("MusicMode", "MusicMode 1a " + Box_Kitchen_Mode.state);
if (Box_Kitchen_Mode.state != 0) {
sendCommand("Box_Kitchen_Mode", 0)
}
logInfo("MusicMode", "MusicMode 1b " + Box_Kitchen_Mode.state);
}
}
});
The item in the sitemap:
Switch
item=MusicMode
label="Musik-Modus"
visibility=[Scene_Music_1==1, Scene_Music_1==2, Scene_Music_1==3]
mappings=[1=" 📻 ", 2=" 🌐 "]
icon="scene"
The item itself is configured in Paper UI.
Thanks!
HFM
1 Like
lewie
(Helmut Lehmeyer)
March 4, 2018, 2:04pm
4
There is no error in your script. Did you change another script anyhow, which blocks now the others?
I would move all scripts to a backup folder and copy one after the other back to the the rule folder.
I have no idea!
HFM
(Henning F. Mettge)
March 4, 2018, 4:43pm
5
Hi lewie,
no scripts in folder (except jslib) and still the same evaluation error (from above).
I installed some libraries and installed another version of python in parallel. Could that be the problem?
HFM
HFM
(Henning F. Mettge)
March 4, 2018, 4:55pm
6
Hi lewie,
me again.
I followed your advise and move all scripts away and put them into the folder one after another (there are 3 files). After the first file I put in the second file and I got a strange message:
`org.eclipse.smarthome.automation.type.TriggerType with key 'jsr223.StartupTrigger' already exists! Failed to add a second with the same UID!`
The same with the 3rd file.
The GOOD NEWS: It started working!!!
So my problem is solved.
Thanks again for the hint although I don’t know what was the problem.
1 Like
HFM
(Henning F. Mettge)
March 5, 2018, 6:14pm
7
Hi @lewie ,
unfortunately the error appeared again after restart. It helped to refill the directory with the files.
Can I set the log level somehow to get more debug info? Because it is very annoying to do this procedure after each restart…
Bye
HFM
lewie
(Helmut Lehmeyer)
March 6, 2018, 5:14am
8
That sounds like another problem:
For more detailed debug on specific classes use: log:set LEVEL package.subpackage
https://docs.openhab.org/administration/logging.html