I guess the reason is the semicolon at the end of the âlogInfoâ lines, that should not be there. I did some other improvements to your rule as well. Try:
var OnOffType newState
if (bathroom_water_temperature_p.state < 25) {
if (now.getHour() < 24 && now.getHour() > 9) {
newState = ON
}
} else if (bathroom_water_temperature_p.state > 45) {
newState = OFF
}
bathroom_boiler_p.sendCommand(newState)
logInfo("myrule", "hoursnow: " + now.getHour())
Script execution of rule with UID 'aaa326cc5f' failed: <eval>:1:14 Expected ; but found newState
var OnOffType newState
^ in <eval> at line number 1 at column number 14
Hmm I donât have any experience using UI, all my configurations are in text files. My example works fine in a .rules file. You could try that, or wait until someone with more UI experience has an alternative.
Iâm having the same error.
And with all that is said in this thread, itâs still unclear to me on how to instruct OH3 to log a string containing the value of a parameter using dsl rules.
Iâm trying to rework my config using the UI as much as possible as I read thatâs the recommendation but so far, Iâm having trouble finding decent info on how to do that.
So what would be the correct line of code in dsl to log the state of an item switch named Gar_sch_Licht?
I tried all kind of things: the last one is taken from here: Docs » Logging on github where they talk about LogAction. But if I select the Rules DSL tab, I get to see only this as the code which I know doesnât work.
okâŠbeen searching for days, the moment I post this message the logging starts workingâŠ
I donât know what has changed but at least Iâve made progress again.
That is: the error changed, so itâs maybe no longer the best thread to keep adding to but Iâve a feeling that there might still be a mixup between javascript & DSL in play so here goes:
WHEN
When â a trigger channel fires
Channel â dimmer_switch_event (Dimmer Switch Event)
Event â
THEN
Execute a given script (dsl):
logInfo("DimmerTest", "receivedEvent from remote = {}", ChannelTriggeredEvent.getEvent().toString)
Iâd like to continue working with that event data in a switch - case rule after having it loggedâŠ
The error now reads:
Script execution of rule with UID âd804b360b2â failed: logInfo(âDimmerTestâ, âreceivedEvent from remote = nullâ, ___ ChannelTriggeredEvent.getEvent().toString)
The method or field ChannelTriggeredEvent is undefined; line 1, column 56, length 21
so now not logInfo but ChannelTriggeredEvent is undefined.