Hello everyone -I’m new to rules outside Paper UI. I recently setup my sitemaps although I have no items because I haven’t added anything new. I was able to set my home.sitemap up using the location of the PaperUI item with no issues. Now I’m trying to make a rule to trigger based off outside temp. I can see the rule go through with no errors on the log file. But I dont see an actual change in the item I’m attempting to change. I’m running openhabian on a pi3. I’ve dumb’d down the rule a bit just to see what makes it tick, then I’ll build it up some. Here is what I have so far:
rule "MasterBedRoomAC"
when
Item LocalWeather_Current_ changed
then
if (LocalWeather_Current_.state <= 88) {
FrontRoomSmartEnergySwitch_Switch.sendCommand(OFF)
}
end
What am I missing? I’ve tried rearranging it every which way with no luck. Thanks in advance.
I could be wrong, but I don’t think you can end the name of an item with an underscore. Everything else in the rule looks good. Another thing to try is to add a log entry after the triggers, so that you know that the rule actually gets triggered. Something like…
I’ve taken off the underscore, item was added through PaperUi not sure why it did that. I couldn’t find where to modify the string name in json so I just deleted the item and remade it. Now its LocalWeather_Current. Also added the debut log, waiting for it to come around to see what it says.
nope didn’t fix it, I can see the rule trigger in logs and it shows the temp number it triggered on. The same item (frontroomsmartenergyswitch) is controllable from basic ui. Not sure what im missing. I might change the rule to trigger from say bathroom switch change so i can do more testing vs waiting for temp change.
Alittle confused right now, so I changed it up some to see what changes what. I did this rule:
This turns off my bathroom switch if I turn on/off my wood furnace blower. Name of xxxx.sendCommand(OFF) does absolutely nothing. It can be test.sendCommand(OFF) and bathroom still turns off. If I remove line 6 then nothing happens. What am I missing here?
rule "MasterBedRoomAC"
when
Item WoodFurnaceBlower_Switch changed
then
if (Bathroom_Switch.state = OFF) {
FrontRoomSmartEnergySwitch_Switch.sendCommand(OFF)
}
end```
Not sure if I have my rule correct for logging, fairly new to this all. I did the following which gave this log info out:
rule "Master Bedroom AC"
when
Item WoodFurnaceBlower_Switch received command
then
logDebug("Rules","MasterBedroomAC: rule started: WoodFurnaceBlower_Switch.state=[{}]",WoodFurnaceBlower_Switch.state.toString)
if (WoodFurnaceBlower_Switch.state = ON) {
logInfo(name, "Masterbedroom AC ON")
FrontRoomSmartEnergySwitch_Switch.sendCommand(ON)
}
if (WoodFurnaceBlower_Switch.state = OFF) {
logInfo(name, "Masterbedroom AC OFF")
FrontRoomSmartEnergySwitch_Switch.sendCommand(OFF)
}
end
2018-09-24 13:01:51.947 [DEBUG] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/WoodFurnaceBlower_Switch' with value 'ON'.
==> /var/log/openhab2/events.log <==
2018-09-24 13:01:51.956 [ome.event.ItemCommandEvent] - Item 'WoodFurnaceBlower_Switch' received command ON
==> /var/log/openhab2/openhab.log <==
2018-09-24 13:01:51.961 [DEBUG] [nternal.profiles.ProfileCallbackImpl] - Delegating command 'ON' for item 'WoodFurnaceBlower_Switch' to handler for channel 'zwave:device:c9fd3b4d:node8:switch_binary'
2018-09-24 13:01:51.962 [DEBUG] [ntime.internal.engine.RuleEngineImpl] - Executing rule 'Master Bedroom AC'
2018-09-24 13:01:51.966 [DEBUG] [nternal.common.InvocationHandlerSync] - Already in a safe-call context, executing 'ThingHandler.handleCommand()' directly on 'org.openhab.binding.zwave.handler.ZWaveThingHandler@e72531'.
2018-09-24 13:01:51.979 [DEBUG] [nternal.profiles.ProfileCallbackImpl] - Delegating update 'ON' for item 'WoodFurnaceBlower_Switch' to handler for channel 'zwave:device:c9fd3b4d:node8:switch_binary'
==> /var/log/openhab2/events.log <==
2018-09-24 13:01:51.981 [vent.ItemStateChangedEvent] - WoodFurnaceBlower_Switch changed from OFF to ON
==> /var/log/openhab2/openhab.log <==
2018-09-24 13:01:51.986 [DEBUG] [nternal.common.InvocationHandlerSync] - Already in a safe-call context, executing 'ThingHandler.handleUpdate()' directly on 'org.openhab.binding.zwave.handler.ZWaveThingHandler@e72531'.
2018-09-24 13:01:52.000 [DEBUG] [eclipse.smarthome.model.script.Rules] - MasterBedroomAC: rule started: WoodFurnaceBlower_Switch.state=[ON]
2018-09-24 13:01:51.999 [DEBUG] [.sitemap.internal.SitemapEventOutput] - Sent sitemap event for widget 0200 to subscription 9f5e8630-6638-4bc8-8c17-372be715020a.
==> /var/log/openhab2/events.log <==
2018-09-24 13:01:52.021 [vent.ItemStateChangedEvent] - WoodFurnaceBlower_Switch changed from ON to OFF
==> /var/log/openhab2/openhab.log <==
2018-09-24 13:01:52.028 [DEBUG] [.sitemap.internal.SitemapEventOutput] - Sent sitemap event for widget 0200 to subscription 9f5e8630-6638-4bc8-8c17-372be715020a.
==> /var/log/openhab2/events.log <==
2018-09-24 13:01:52.077 [vent.ItemStateChangedEvent] - WoodFurnaceBlower_Switch changed from OFF to ON
==> /var/log/openhab2/openhab.log <==
2018-09-24 13:01:52.081 [DEBUG] [.sitemap.internal.SitemapEventOutput] - Sent sitemap event for widget 0200 to subscription 9f5e8630-6638-4bc8-8c17-372be715020a.
==> /var/log/openhab2/events.log <==
2018-09-24 13:01:57.838 [vent.ItemStateChangedEvent] - ZoneMinderServer_CPULoad changed from 1.79 to 1.8
==> /var/log/openhab2/openhab.log <==
2018-09-24 13:02:00.153 [DEBUG] [cheduler.ExpressionThreadPoolManager] - Scheduling the task 'org.eclipse.smarthome.core.scheduler.RunnableWrapper@616a1d' to execute in 59999 ms
Got it working with this code, couldn’t make it work with one rules so I did two. Seems to work with a switch as a trigger, now how to make it work based off a temperature value. hmmm
rule "Master Bedroom AC"
when
Item WoodFurnaceBlower_Switch changed from OFF to ON
then
if(WoodFurnaceBlower_Switch.state == ON) {
FrontRoomSmartEnergySwitch_Switch.sendCommand(ON)
}
end
rule "Master Bedroom AC"
when
Item WoodFurnaceBlower_Switch changed from ON to OFF
then
if(WoodFurnaceBlower_Switch.state == OFF) {
FrontRoomSmartEnergySwitch_Switch.sendCommand(OFF)
}
end
It’s hard to read the logs with the events and openhab logs interlaced like that.
Have you edited your log4j config? It is odd that at least the logInfo statements are not shown.
That being said, the whole Rule could be simplified to:
rule "Master Bedroom AC"
when
Item WoodFurnaceBlower_Switch received command
then
logInfo(name, "Masterbedroom AC " + receivedCommand)
FrontRoomSmartEnergySwitch_Switch.sendCommand(receivedCommand)
end
rule "Temperature value"
when
Item Temperature changed
then
if(Temperature.state > someThreshold) {
// do something
}
else {
// do something else
}
end
I don’t see anything unexpected here except that the file looks truncated. I have all sorts of stuff after your last line in mine. In particular you are missing all the appenders. Without the appenders the logger won’t write anything.
Here is my full config. Note that I have added custom configs to put zwave, zigbee, and nest1 logs into their own files.