Simple rule not working on Synology setup

My first post here!

I installed openHAB on my Synology NAS (iosafe 218) and everything seems to work beside some minors glitches. I can control the items states by the web interface and see status of most of them.

I experimented success with the experimental rules engine but wanted to go farther by using the text file rules that you insert in the rules folder. Up to now, no rule has worked…

Here is the rule I have in the rules folder, it doesn’t work:

rule "Plant Timer Link On"
when
	Item Light_Desk changed from OFF to ON
then
	Plug_in_onoff_Module.sendCommand(ON)
end

rule "Plant Timer Link Off"
when
	Item Light_Desk received command OFF
then
	Plug_in_onoff_Module.sendCommand(OFF)
end

-I can see rule file in HABmin Automation Rules.
-The name of the Item I use is the “Label” field in the things list.
-openhab.log: load and refresh rule
-events.log: just show the event of the switch I activate and not the slave that should follow with the rule.

I don’t know what I am doing wrong and where to search now…

Robin

What do the logs say?
HABmin is not recommended for rules.
Either use text files or the beta NGRE (Next Generation Rules Engine) addon for Paper UII,

Welcome to the OpenHAB community Robin!
The first rule has no end
When you edit a file and save it, have a look at the log. If there is a mistake in the rule, you will see a message in the log that the file has errors and ignoring it. If it is mistake free, you will see a message that the rule file was refreshed. EVERY time you save a rules file, verify that it loaded

Also when posting your rules, put them in code fences by placing three tilde like this ~~~
on a line before and after your code so it looks like this

File1----------------

rule “Plant Timer On”
when
Time cron “0 0 8 1/1 * ? *”
then
Plug_in_onoff_Module.sendCommand(ON)

rule “Plant Timer Off”
when
Time cron “0 0 23 1/1 * ? *”
then
Plug_in_onoff_Module.sendCommand(OFF)

end
1 Like

Actually backticks ``` or use the menu bar.

image

well the tilde seems to work?
that what I used

tilde version

my rule here

back tick version

my rule here

Ok…

How to use code fences - Tutorials & Examples - openHAB Community

Bruce:
-I only use Habmin to see the rules.
-I am already in text files that I put in the rules folder.
-I used NGRE with success but want to move to text file to build more complex rules and being better organized.

Andrew:
-Added a second end on the rule
-Since my installation is on Synology, I am learning to be able to see the real time log.
-Edited my first post as per your recommendations.

Now I am stuck at real time log (Karaf). Since I am not sure if I can have a direct console on the NAS I opened a console on my pc and tried a few things without success up to now:

PS C:\WINDOWS\system32> ssh -p 8101 openhab
ssh: Could not resolve hostname openhab: No such host is known.
PS C:\WINDOWS\system32> ssh -p 8101 openhab2@192.168.1.221
ssh: connect to host 192.168.1.221 port 8101: Connection refused
PS C:\WINDOWS\system32> ssh -p 8101 openhab2@192.168.1.221
ssh: connect to host 192.168.1.221 port 8101: Connection refused

The log file in userdata\logs doesn’t seem to be up to date when I push the dimmer button to see if the rules works.

Which one? Of interest are events.log, which gives info about Item changes and commands, and openhab.log with other useful things - like the message that confirms your rules files were loaded successfully.

openhab.log:

2020-03-18 09:15:31.205 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘Plant Timer Link - Copy.rules’
2020-03-18 09:15:32.556 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Plant Timer Link - Copy.rules’
2020-03-18 09:15:50.031 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘Desk and Kitchen Link.rules’
2020-03-18 09:17:46.323 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Desk and Kitchen Link.rules’
2020-03-18 11:24:13.328 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘Plant Timer.rules’
2020-03-18 11:39:38.102 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing ‘lgwebos:WebOSTV:98bbbf40-5ce6-4c3f-8a16-e8b498eb6342’ to inbox.
2020-03-18 12:26:17.796 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Plant Timer Link.rules’ has errors, therefore ignoring it: [10,2]: no viable alternative at input ‘:’

2020-03-18 12:27:26.029 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Plant Timer Link.rules’ has errors, therefore ignoring it: [10,2]: no viable alternative at input ‘:’
[12,7]: mismatched input ‘:’ expecting ‘end’

2020-03-18 12:34:23.664 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Plant Timer Link.rules’ has errors, therefore ignoring it: [10,2]: no viable alternative at input ‘Item’

None of the 3 rules works.

Okay, are going to do anything about the errors? We don’t know what file it refers to.

-I don’t understand why 2 of 3 rules has no error and still does nothing.
-What is the [10,2]?
-Will the system log gives me error if name of items are wrong?

Couldn’t say. We don’t know which rules files have loaded correctly. You do.

You’d to wait on the clock for 8am or 11pm to see if your cron rules work, of course.

Line number and character position in the offending file.
You have to take the messages with a pinch of salt, often an error at one point will cause more errors later because a sequence has been broken.

When the rules run, yes, you’ll get a log for sending a command to a non-existent Item or suchlike.

Couldn’t say. We don’t know which rules files have loaded correctly. You do.

I was under the impression that log file found no problem:
“2020-03-18 09:15:50.031 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘Desk and Kitchen Link.rules
2020-03-18 09:17:46.323 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Desk and Kitchen Link.rules’’”

You’d to wait on the clock for 8am or 11pm to see if your cron rules work, of course.

That is why I created the 2 other rules:)

So my new error is:
2020-03-18 13:02:54.041 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Plant Timer Link.rules’ has errors, therefore ignoring it: [10,2]: no viable alternative at input ‘Light_Room_Back’

Don’t know how to interpret “no viable alternative at input”

That usually means you have an open quote with no closing quote or something like that. It is telling you there is a syntax error somewhere in the file
post the rule file in it’s entirety and we’ll look

rule "Plant Timer Link On"
when
	Item Light_Desk changed from OFF to ON
then
	Plug_in_onoff_Module.sendCommand(ON)
end

rule "Plant Timer Link Off"
when
	Light_Desk changed received command OFF
then
	Plug_in_onoff_Module.sendCommand(OFF)
end	

There it is Robin

when
	Light_Desk changed received command OFF

needs to be

when
	Item Light_Desk received command OFF

you didn’t have Item first and you had changed and received

I now have

rule “Plant Timer Link On”
when
Item Light_Desk changed from OFF to ON
then
Plug_in_onoff_Module.sendCommand(ON)
end

rule “Plant Timer Link Off”
when
Item Light_Desk received command OFF
then
Plug_in_onoff_Module.sendCommand(OFF)
end

and the openhab log:

2020-03-18 13:43:32.850 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Plant Timer Link.rules'
2020-03-18 13:43:54.143 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'Plant Timer Link.rules'

And still all the rules doesn’t work (I edited the first post with the current rules syntax.

The event log shows this:

2020-03-18 13:45:01.968 [vent.ItemStateChangedEvent] - zwave_serial_zstick_7a2a2811_serial_sof changed from 965 to 966
2020-03-18 13:45:04.910 [ome.event.ItemCommandEvent] - Item 'zwave_device_7a2a2811_node7_switch_dimmer' received command ON
2020-03-18 13:45:04.916 [nt.ItemStatePredictedEvent] - zwave_device_7a2a2811_node7_switch_dimmer predicted to become ON
2020-03-18 13:45:04.924 [vent.ItemStateChangedEvent] - zwave_device_7a2a2811_node7_switch_dimmer changed from 0 to 100

What means “predicted”? Node 7 is the Light_Kitche of the file3 (rules #3 in first post)

Sure, but we do not know which rules might be in Desk and Kitchen Link.rules. You have not told us. You have to be explicit. Look back at your first post - “File1” etc.

Nothing referred to in your event log have anything to do with any of the Items mentioned in your rules.
What were you expecting to happen?

No events.log shown for that Item. There is nothing for the rule to do.

The actual error (missing Item keyword) was in line 10 of your rules file, as suggested by the [10,2]: in the error message. There is sense in the chaos, trust us :wink:

Ok to simplify I removed 2 rules to keep just one. I did a test with this one:

rule “Plant Timer Link On”
when
Item Light_Desk changed from OFF to ON
then
Plug_in_onoff_Module.sendCommand(ON)
end

rule “Plant Timer Link Off”
when
Item Light_Desk received command OFF
then
Plug_in_onoff_Module.sendCommand(OFF)
end

rule “Plant Timer Link Onn”
when
Item zwave_device_7a2a2811_node22_switch_dimmer changed from OFF to ON
then
zwave_device_7a2a2811_node4_switch_binary.sendCommand(ON)
end

Rule “Plant Timer Ling Onn” is there because the name of the things in the log where differents that the label so I did a test with the name in the event log. I use first “Plant Timer Link On”

openhab.log:

2020-03-18 21:48:39.433 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Plant Timer Link.rules’

events.log:

2020-03-18 21:49:04.683 [vent.ItemStateChangedEvent] - zwave_serial_zstick_7a2a2811_serial_sof changed from 1712 to 1713
2020-03-18 21:49:04.694 [vent.ItemStateChangedEvent] - zwave_device_7a2a2811_node22_switch_dimmer changed from 0 to 100
2020-03-18 21:53:15.752 [vent.ItemStateChangedEvent] - zwave_serial_zstick_7a2a2811_serial_sof changed from 1713 to 1714

No trace of a rule file with error, no trace of rule file executed.

I don’t know where to go now!

But I learned to see a log in real time from a a pc on a synology installation:)