[Solved] HABmin rule designer, can't get it to work


(Michael Tøttrup) #1

Hi.
I have tried to make a rule manually in a .rule file. But I could not work this way, I do not get any log in. So I have tried to use the rule designer in HabMIN. But I can not work this either, so I get the following message in log:

2018-11-23 06:35:42.185 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘(1)_neato_autostart.rules’ has errors, therefore ignoring it: [13,1]: no viable alternative at input ‘then’

It’s a simple rule that sends a CLEAN command to my Neato vacuum cleaner. Monday, Wednesday,Thursday, Friday at 8.00, but only if the alarm in the house is armed. (Then, do not start if we go on a day off and sleep long).
Attached is a screenshot from HabMIN and error message from log.

I can’t understand, why this has to be that difficult, and what i am doing wrong? :frowning:


(Angelos) #2

I am not sure, since I don’t use HABmin for rules…
You should restructure your rule and follow this logic:
when time cron is …
then
if AlarmStatus is OFF
set item Neato to clean

Can you switch to </> Source view and post the source code?

By the way: You have 3 main options for building automation rules:

  1. Flat text files (*.rules) with the assistance of VS Code
  2. HABmin rules engine (the one that you are using now)
  3. PaperUI Next Gen Rules Engine

Since you would like to use a graphical environment, you may want to look into nodeRed also


(Rich Koshak) #3

Habmin’s Rule editor has not been updated since before OH 1.x. It does not produce Rules that are compatible with OH 2.x. Since the developer is also the developer for the zwave binding and zibgee binding I wouldn’t hold my breath that it will be updated anytime soon.

Dim’s suggestions are your best bet.


(Michael Tøttrup) #4

I tried .rules textfile instead. I created following rule:

rule “Neato Autostart”
when
time cron “0 55 10 ? * MON,WED,THU,FRI,SAT *”
then
if AlarmStatus_Hus = OFF
sendCommand(Neato_SendCommand,“CLEAN”)
end

But i get this error in the log. I’m new to this coding, so i think i am missing something somewhere?

2018-11-24 11:27:47.500 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘(1)_neato_autostart.rules’ has errors, therefore ignoring it: [4,6]: no viable alternative at input ‘time’

[6,6]: missing ‘(’ at ‘AlarmStatus_Hus’

[7,6]: missing ‘)’ at ‘sendCommand’


(Angelos) #5

capital Time :slight_smile:

You can use a cool tool for syntax validation: openHAB VS Code Extension 0.3.5

rule "Neato Autostart"
when
	Time cron "0 55 10 ? * MON,WED,THU,FRI,SAT *"
then
	if (AlarmStatus_Hus = OFF) {
	Neato_SendCommand.sendCommand("CLEAN")
    }
end

(Michael Tøttrup) #6

Thank you very much, it seems to work now. No error message in log file. I changes the time, and now i am waiting to hear the sound of the vacuum cleaner starting - fingers crossed :slight_smile:


(Angelos) #7

You can test your rule by setting up a dummy Item, put it in your sitemap and toggle it

*.items

Switch	Rule_Trig	"Testing Rules"

*.rules

rule "Neato Autostart"
when
	Time cron "0 55 10 ? * MON,WED,THU,FRI,SAT *" or
	Item Rule_Trig changed from OFF to ON
then
	if (AlarmStatus_Hus = OFF) {
	logInfo("Neato.rule","Alarm is OFF, Time triggered, sending CLEAN Command to Neato")
	Neato_SendCommand.sendCommand("CLEAN")
    }
end

(Michael Tøttrup) #8

Hmm… Now i get this, when it time for the rule to trigger:

2018-11-24 11:42:00.339 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘Neato Autostart’: An error occurred during the script execution: Couldn’t invoke ‘assignValueTo’ for feature JvmVoid: (eProxyURI: (1)_neato_autostart.rules#|::0.2.0.2.0.0.0::0::/1)


(Angelos) #9

I fixed some typos in the rule above.
try to copy it again

can you post your Neato_SendCommand Item definition?


(Michael Tøttrup) #10

Stil getting this:

2018-11-24 11:50:00.151 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘Neato Autostart’: An error occurred during the script execution: Couldn’t invoke ‘assignValueTo’ for feature JvmVoid: (eProxyURI: neato_autostart.rules#|::0.2.0.2.0.0.0::0::/1)

.Item file:

Number Neato_BatteryLevel “Batteriniveau [%.0f %%]” {channel=""}
String Neato_CurrentState “Status [%s]” {channel=""}
String Neato_CurrentAction “Nuværende aktion [%s]” {channel=""}
Switch Neato_IsDocked “I Dock [%s]” {channel=""}
Switch Neato_IsCharging “Lader [%s]” {channel=""}
String Neato_Error “Fejl [%s]” {channel=""}
String Neato_SendCommand “Send Komando”

I linked the items via the binding in paper UI. In my sitemap i created a mapping switch, and that one is working, when i press the clean button.

Switch item=Neato_SendCommand mappings=[CLEAN=“Clean”,STOP=“Stop”,PAUSE=“Pause”,RESUME=“Resume”, DOCK=“Send to dock”]


(Angelos) #11

oops sorry… more errors in the rule…

rule "Neato Autostart"
when
	Time cron "0 55 10 ? * MON,WED,THU,FRI,SAT *" or
	Item Rule_Trig changed from OFF to ON
then
	if (AlarmStatus_Hus.state == OFF) {
		logInfo("Neato.rule","Alarm is OFF, Time triggered, sending CLEAN Command to Neato")
		Neato_SendCommand.sendCommand("CLEAN")
    }
end

what is the Item definition of AlarmStatus_Hus ? is it a Switch?


(Michael Tøttrup) #12

Yes, a switch. ON/OFF


(Angelos) #13

I have update the rule here
it should? work :slight_smile:


(Michael Tøttrup) #14

Nothing is happening? :frowning: And i don’t see anything at all in the log, when the time reach the trigger point


(Angelos) #15

i haven’t validated your cron expression… i can’t find now the online tool that checks it…

did you use a Rule_Trig Item? (no need to wait for the time to trigger)


(Michael Tøttrup) #16

I did. Nothing happens.

2018-11-24 12:16:36.302 [ome.event.ItemCommandEvent] - Item ‘Rule_Trig’ received command ON

2018-11-24 12:16:36.333 [vent.ItemStateChangedEvent] - Rule_Trig changed from OFF to ON

I don’t get any info in log about the rule bin trigged, just that i changed the rule trig item from off to on.


(Angelos) #17

then there must be some error with the cron expression

try to remove it and see if the rule fires when using only the dummy Item as a trigger

rule "Neato Autostart"
when
	Item Rule_Trig changed from OFF to ON
then
	if (AlarmStatus_Hus.state == OFF) {
		logInfo("Neato.rule","Alarm is OFF, Time triggered, sending CLEAN Command to Neato")
		Neato_SendCommand.sendCommand("CLEAN")
    }
end

(Michael Tøttrup) #18

Still the same, nothing happens when i delete the cron and fires the rule trigger


(Angelos) #19

check the if condition
what is the current state of the AlarmStatus_Hus Item?
If it’s ON: nothing will happen when the rule triggers :slight_smile:


(Michael Tøttrup) #20

The AlarmStatus_Hus was “NULL”, it helped when i first trigged it to on, then off. Why was it not updated, and had state:NULL?