I have been at this all day and I am at a point at which I am not sure anymore what to expect.
I have OpenHAB running on a Synology with a Z-Wave setup. As far as bindings, things and items are concerned everything works. So I jumped into rules. The rules binding is not available for some reason so I went straight to Visual Studio Code with the OpenHAB plug-in.
I do get code coloring and I do get something presented to me when I press Ctrl+Space but it is utterly useless and does not seem to make much sense in the context. I find mainly words I typed earlier in that list, no properties or methods related to the object before the dot.
So… Is code completion not working or is it just useless?
Here’s my settings.json file. I made sure it is the same for user and workspace because I do not understand the difference.
{
"openhab.useRestApi": true,
"openhab.host": "192.168.1.102",
"openhab.port": 8080,
"openhab.username": "MyUserName",
"openhab.password": "MyPassword",
"workbench.iconTheme": "openhab",
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false
}
I do see my things and items under the OpenHAB tab. I just cannot make any rule work because I can only guess what conversion options I have when I simply want to pull a value from an item object to compare to a constant number. I can inspect the openhab.log file for errors and this, although a poor way of debugging, did get me a couple of steps further but it does not get me beyond this:
[ntime.internal.engine.RuleEngineImpl] - Rule 'OverVoltage Response': An error occurred during the script execution: index=1, size=1
Much to my surprise I cannot find any example of what I would have expected to be a very common scenario: when an item value is updated I want to see if the value exceeds some number and if so, act on it.
I realize I am asking two question but to me they are strongly related: the lack of IDE support inhibits me to write correct rules. I hope there is something wrong with my setup because the way it is behaving on my system, the plug-in is quite useless.
This is the rule (the latest thing I tried). I am struggling with the conditional expression that compares the item value with the number 252. I expect to be able to get a number from the item by doing something like Output_Voltage.state.value or Output_Voltage.value or Output_Voltage.AsNumber. The IDE is not helping me, I have no object browser and I do not know where my item definitions are (I created them using the paper UI).
rule "OverVoltage Response"
when
Item Output_Voltage received update
then
var voltage = Output_Voltage.state.toString()
if (voltage > "252.0")
{
logInfo("Over voltage detected > 252 Volt), => switching load ON.")
}
else
{
logInfo("All well, voltage is under 252 Volt.")
}
end