-
Platform information:
- Hardware: i5 3570K/32Gb/SSD
- OS: Windows 10 pro x64
- Java Runtime Environment: openjdk version “11.0.19” 2023-04-18 LTS
OpenJDK Runtime Environment Zulu11.64+19-CA (build 11.0.19+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.64+19-CA (build 11.0.19+7-LTS, mixed mode)
-
openHAB version: 3.4.4
-
Issue of the topic: I have just recently started using openhab and am trying to get my first rules working so I can automate the filling of a water tank via a pump. So a level switch goes on or off and the pump starts or stops, should be simple or so I thought but I cannot get any rule to run from the shelly uni input status. If I run the rule using the play button the latest logic I have built in blockly works. I have tried many different triggers and I am not having much success. All the tutorials I have seen don’t appear to do anything differently than I am BUT mine is just not triggering. I was hoping to get this working roughly yesterday to finish off today but I am getting nowhere fast. Should the attached rule work everytime the input status changes from on to off??? Any help would be greatly appreciated.
-
Please post configurations (if applicable):
- Rules code related to the issue
note: I have not bothered with the blockly script in the rule shown above, I can’t even get it to work
Screen shots are hard to read but from what I can tell yes, the rule should trigger when the InputButton_1 changes from "on"
to "off"
.
In the future, click on the code tab and post the YAML you find there. Use code fences.
```
code goes here
```
Anyway, back to the problem. I deliberately put the on and off in quotes above because, as written, that’s what it’s checking for, the literal string "on"
and "off"
. But presumably InputButton_1 is a Swtich Item. In addition to NULL and UNDEF, which any Item can carry, Switch Items can only be either ON
or OFF
. "on"
is not the same as ON
. Case matters.
For more on what states are valid for each Item type see Items | openHAB but as a general rule, Items which take an enumeration’s state will always be all caps. And when using these in rule triggers or conditions like this, if it doesn’t match one of the enumerated types, it’s assumed to be a String.
Thanks for replying rlkoshak, I did try all the different case options over the last day of messing with it. BUT, I just found that it was just my patience that was catching me out. I have just changed the status to look for ON and OFF and after 20-40 seconds it worked as expected. I expected that if I could see the status change on screen that the rule would run soon after but apparently not. Any idea if it is normal for that sort of time to pass before a rule will run?? Not that it matters in this case, I’m just interested.
Thanks again. Now I can get some more serious rules under way.
See below for the code as it is now.
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Tank_Area_Uni_1_19216808_InputButton_1
state: OFF
previousState: ON
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
itemName: Tank_Area_Uni_1_19216808_Power_2
command: OFF
type: core.ItemCommandAction
It should be instantly but there could be two things happening.
- When you interact with an item in the UI it sends a command. A command means “please do this”. A command does not change the state of the item. Something needs to process that command. In the ideal case, the binding receives the command, sends it to the device, and only when the device sends a message back that is in a new state does the binding update the item. This can take some time.
But in the UI, when you toggle the item widget, it shows you’ve toggled it so it may not accurately show the current state of the device until something updates the Item. It’s a compromise between UX and accuracy occurs here.
- The first time a rule runs it needs to be loaded and parsed. On slow machines this can take some time.
Keep an eye on the logs. events.log will show the item commands and change events. openhab.log will show errors.
Thanks for the great explanation, that clears it up.
Thanks for your time. Cheers