Als komplette Antwort kommt false bzw. true zurück.
Code: Alles auswählen
<e2powerstate>
<e2instandby> false </e2instandby>
</e2powerstate>
Moderator: seppy
Code: Alles auswählen
<e2powerstate>
<e2instandby> false </e2instandby>
</e2powerstate>
Code: Alles auswählen
(function(i) {
var status = ""
if(i.includes("true")) {
status = "OFF"
} else {
status = "ON"
}
return status;
})(input)
Code: Alles auswählen
Switch VuPower "Power [%s]" <switch> (gVu) {http="<[http://root:Passwort@10.10.10.10:80/web/powerstate:3000:JS(boolonoff.js)] >[*:GET:http://root:Passwort@10.10.10.10:80/web/remotecontrol?command=116]"}
Code: Alles auswählen
(function(i) {
return if(i.includes("true")) {"OFF"} else {"ON"};
})(input)
Code: Alles auswählen
org.openhab.core.transform.TransformationException: An error occurred while executing script. TypeError: i.includes is not a function in <eval> at line number 3
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]
2020-05-06 18:27:37.223 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(boolonoff.js)' threw an exception. [response=
<html>
<head><title>401 - Unauthorized</title></head>
<body>
<h1>Unauthorized</h1>
<p>401 Authentication required</p>
</body>
</html>
Code: Alles auswählen
org.openhab.core.transform.TransformationException: An error occurred while loading JavaScript. <eval>:2:11 Expected an operand but found if
return if(i.includes("true")) {"OFF"} else {"ON"};
^ in <eval> at line number 2 at column number 11
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]
2020-05-06 18:31:14.087 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(boolonoff.js)' threw an exception. [response=
<html>
<head><title>401 - Unauthorized</title></head>
<body>
<h1>Unauthorized</h1>
<p>401 Authentication required</p>
</body>
</html>