- Platform information:
- Hardware: Raspberry Pi 3 Model 3 B+
- OS: Openhabian Linux 4.19.66-v7+ #1253
- Java Runtime Environment: “I still have to learn how to see this”
- openHAB version: 2.5.0-1
- Issue of the topic: I want to disable an expire rule as long as the chromecast is online and I am getting an error in the log file that prevents the rules file to be loaded.
- Please post configurations (if applicable):
- Items configuration related to the issue
Things:
Thing zwave:device:bfd6ea92:node3 “Vardagsrum_Dimmer” @ “Vardagsrum”
Thing chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb “Vardagsrum_TV_Chromecast” @ “Vardagsrum”
Items:
Switch Vardagsrum_Timer “Vardagsrum Timer” (Vardagsrum) { expire=“15m,command=OFF” }
Dimmer Vardagsrum_Dimmer “Vardagsrum Dimmer” (Vardagsrum) [“Lighting”] {channel=“zwave:device:bfd6ea92:node3:switch_dimmer”}
- Sitemap configuration related to the issue
- Rules code related to the issue
rule “Turn off the Dimmer when Timer goes off”
when
Item Vardagsrum_Timer changed from ON to OFF
then
if(Thing “chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb” != ONLINE) return
Vardagsrum_Dimmer.sendCommand(OFF)
end
- Services configuration related to the issue
addons.cfg:
package = standard
remote = true
legacy = true
binding = chromecast , expire1 , kodi, mqtt , ntp , zwave
ui = basic , classic , habpanel , paper
persistence = rrd4j
transformation = map
misc = openhabcloud , ruleengine
- If logs where generated please post these here using code fences:
Configuration model ‘default.rules’ has errors, therefore ignoring it: [29,8]: no viable alternative at input ‘Thing’ [29,14]: missing ‘)’ at ‘“chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb”’
- Items configuration related to the issue
Please use code fences so formatting does not get altered by the forum software.
How to use code fences - Tutorials & Examples - openHAB Community
I have been using code fences around all the extracts
If you did, tis line would look like
if(Thing “chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb” != ONLINE) return
with a horozontal scroll bar, if needed
That’s nonsense.
Perhaps getThingStatusInfo()
is what you need here.
- Platform information:
- Hardware: Raspberry Pi 3 Model 3 B+
- OS: Openhabian Linux 4.19.66-v7+ #1253
- Java Runtime Environment: “I still have to learn how to see this”
- openHAB version: 2.5.0-1
- Issue of the topic: I want to disable an expire rule as long as the chromecast is online and I am getting an error in the log file that prevents the rules file to be loaded.
- Please post configurations (if applicable):
- Items configuration related to the issue
Things:
Thing zwave:device:bfd6ea92:node3 “Vardagsrum_Dimmer” @ “Vardagsrum”
Thing chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb “Vardagsrum_TV_Chromecast” @ “Vardagsrum”
Items:
Switch Vardagsrum_Timer “Vardagsrum Timer” (Vardagsrum) { expire=“15m,command=OFF” }
Dimmer Vardagsrum_Dimmer “Vardagsrum Dimmer” (Vardagsrum) [“Lighting”] {channel=“zwave:device:bfd6ea92:node3:switch_dimmer”}
- Sitemap configuration related to the issue
- Rules code related to the issue
rule “Turn off the Dimmer when Timer goes off”
when
Item Vardagsrum_Timer changed from ON to OFF
then
if(Thing “chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb” != ONLINE) return
Vardagsrum_Dimmer.sendCommand(OFF)
end
- Services configuration related to the issue
addons.cfg:
package = standard
remote = true
legacy = true
binding = chromecast , expire1 , kodi, mqtt , ntp , zwave
ui = basic , classic , habpanel , paper
persistence = rrd4j
transformation = map
misc = openhabcloud , ruleengine
- If logs where generated please post these here using code fences:
Configuration model ‘default.rules’ has errors, therefore ignoring it: [29,8]: no viable alternative at input ‘Thing’ [29,14]: missing ‘)’ at ‘“chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb”’
Where should I put this? In the Rule or in the beginning of the Rule file? How would that help solving the error with the missing ‘)’ ?
Because, as rossko57 indicates,
if(Thing “chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb” != ONLINE)
is meaningless. But Thing is a reserved word that has a meaning but it doesn’t belong there so it is expecting something that doesn’t exist.
In short, that line is all kinds of wrong and the Rules parser doesn’t have a clue what to do with it.
Searching the docs for “getThingStatus” brings you to Actions | openHAB with a full description of how to use it.
I changed the rule to:
rule "Turn off the dimmer when Timer goes off"
when
Item Vardagsrum_Timer changed from ON to OFF
then
var thingStatusInfo = getThingStatusInfo("chromecast:chromecast:19a5f0d6d095e5c457bee08d5c7505fb")
if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) return
Vardagsrum_Dimmer.sendCommand(OFF)
end
And now I get this error instead:
Validation issues found in configuration model 'default.rules', using it anyway:
Void functions cannot return a value.
It’s just a warning so the Rule should run if not actually work.
Normally, you need to add a ; to the end of a return statement. That might cause this error.
return;