My first rules where made by the “experimental rule engine” (PaperUI -> AddOns -> Misc ->
Rule Engine (Experimental)) … and they work fine as far. But now i like to enhance the logics a bit.
Unfortunaly my rule do not work - maybe someone can help to find my mistake:
i’ve place a rule named “DashButtonGilette.rules” in the folder “./etc/openhab2/rules/”. The rule is a simple build like this:
rule "DashButton pressed"
when
Channel "amazondashbutton:dashbutton:xx-xx-xx-xx-ed-1c:press" triggered
then
Hue_lightstrip.sendCommand(ON)
end
“Hue_lightstrip” is the exact name of the thing; the Channel is straight from the channel below the thing “DashButtonGillette” (just anonymous here).
…what mistake has happened to me?
regards
Tom
PS:little addition: i’ve noticed that there is another rules folder: ./srv/openhab2-conf/rules/ … here i’ve found my rule too (mirrored?) … i don’t think this is a important information … just for completion.
Which version do you use?
openhabian is v1.3 currently, but it provides both stable (openHAB2.1) and unstable (openHAB2.2) version.
In case of openHAB2.1 I’m pretty sure that the file-based rules engine does not provide channel triggers yet, you have to use items as triggers instead, so just create an item and link it to the dash button channel, then use this item to trigger the rule.
my.items:
You are probably not going to be happy with this setup. A Pi 1 is really underpowered and has too little RAM to comfortably run OH. People do it so if you don’t give OH too much to do or expect too quick of a response you might be OK.
Do you really mean /etc/openab2/rules or is etc under some other folder as implied by the .?
You need to reference an Item linked to a Channel on a Thing. Not a Thing directly.
I’m not sure either but I think Dash has been around since before 2.1 Release and it has always used Channel triggers like this. It is, to my knowledge the very first binding to use Thing triggers, beating Astro by several months.
openHAB2.2 is installed on my System. And im quite sure that like Rich Koshak said it should work - because of this manual: http://onesmarthome.de/smart-home-openhab-2-dash-button/ chapter “openHAB 2 Dash Button – Software – Paper UI Dash Button Binding” (german only)
Yes, i think there is the problem - Just now i’ve checked the doc http://docs.openhab.org/configuration/items.html / Chapter “Paper UI Linking”. First step there descripe to create an Item under “configuration” -> “items”. … but under configuration there is no such “chapter”. Under Configuration ist only …
System
Bindings
Services
Things
where can i link channels to items (by paper ui if possible).
You must create the Items in PaperUI. Then you can link the Items to a Channel by browsing to the Thing, click on the up/down arrows to the right of the desired channel, and click the + next to Linked Items.
If there is no Items chapter, your openHAB system is configured to Simple mode Item linking (See Configuration->System->Item Linking->Simple Mode)
openHAB will automatically create one Item for each channel of each thing, but the name of this item will be … complex. Each item name will contain a uuid. Just take a look at Configuration->Things->Your thing->Channel->Linked Items (the arrows at the very right column)
Yeeesss … it worked! At least the first step “switch ON Hue with dash Button”.
unfortunaley the second step “switch on AND OFF Hue with dash Button” failed. Maybe i should go to bed and think about it tomorrow… but here’s (not working) coding for the on/off-switch:
rule "Dash button pressed"
when
Channel "amazondashbutton:dashbutton:xx-xx-xx-xx-xx-xx:press" triggered
then
if ( hue_0210_XXXXXXXXXX_4_color.state.toString == "ON") {
hue_0210_XXXXXXXXXX_4_color.sendCommand(OFF)
} else {
hue_0210_XXXXXXXXXX_4_color.sendCommand(ON)
} end
only the “item” ist named “…xxx_4_color”. I think this preconfigured name point out, that i use the mulitcolor bulbs (not the “hue white”-bulbs).
mmmh, i think the “check the log-files” is the next step … Udo (or anyone else): any idea why my events.log is empty? is there an events.log in a other folder or do i have to activate the logging? i’ve checked this: http://docs.openhab.org/administration/logging.html … but with no result - have i failed to see something relevant?
If you are using the openhabian distro, the you can use the frontail viewer, which is an indispensable tool for development - you may call it in a web browser via:
http://<ip-of-your-installation>:9001/
Since openhabian 1.3 that should be a default component, otherwise you might have to install it via
Please see the table at the top of the Items doc. While an Item can receive a command from any of the Types listed in the right hand column, it internally stores its state only as one of them. In the case of Color it stores its state as an HSBType. An HSBType will never == ON.
This is further explained at the end of the doc here.
Finally, there is a little known feature of Items that I fairly recently discovered that lets you get the state of a type as another compatible type. For your HSBType example you can use:
Add some logging. Maybe it thinks the light is ON when you think it should be OFF…
Put the following line before your if statement. Then check openhab.log for what it printed after the rule triggers.
logInfo("lighting", "Hue Light State = " + hue_0210_XXXXXXXXXX_4_color.state.toString + " ON status is " + hue_0210_XXXXXXXXXX_4_color.getStateAs(OnOffType))
rule "Dash button pressed"
when
Channel "amazondashbutton:dashbutton:xx-xx-xx-xx-xx-1c:press" triggered
then
logInfo("lighting", "Hue Light State = "
+ hue_0210_XXXXXXXXXX_4_color.state.toString + " ON status is " +
hue_0210_XXXXXXXXXX_4_color.getStateAs(OnOffType))
if (hue_0210_XXXXXXXXXX_4_color.getStateAs(OnOffType) == "ON") {
hue_0210_XXXXXXXXXX_4_color.sendCommand(OFF)
} else {
hue_0210_XXXXXXXXXX_4_color.sendCommand(ON)
}
end
… then there ist no loggin information in /var/log/openhab2 (I’ve checked the Files “Openhab.log” and “events.log” by…
Then either you have an error and your .rules file is not being correctly loaded (should see an error in openhab.log when you save the file) or your rule is not triggering.