Sorry about this fairly basic question. I have been reading TFM but finding it all a bit overwhelming for a first dive in - especially for a non-developer.
I have an Aeotec Multi-sensor 6 and a Fibaro dimmer 2. I believe I have included these correctly. I can control the dimmer from PaperUI or HABmin. The sensor is showing activity in the logs like this;
2018-03-11 23:47:33.354 [vent.ItemStateChangedEvent] - zwave_device_46feb3ec_node11_sensor_binary changed from OFF to ON
I want to create a very simple test rule just to show myself that I am starting to understand what is going on. I want the rule to be that activating the motion sensor turns the light off. The basic rule syntax seems fairly straightforward but where I am struggling the most is with naming the devices in the rules. I know I do not yet have a viable rule as I get the following error in the logs when I save the file;
2018-03-12 00:03:46.190 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test_motion.rules'
2018-03-12 00:03:46.206 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'test_motion.rules' is either empty or cannot be parsed correctly!
2018-03-12 00:03:46.319 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'test_motion.rules' has errors, therefore ignoring it: [3,67]: no viable alternative at input 'ON'
Here is my rule so far;
rule "Test motion sensor in spare room"
when
Thing "zwave:device:46feb3ec:node11:sensor_binary" changed to ON
then
"zwave:device:46feb3ec:node3:switch_dimmer".sendCommand(0)
end
Can someone explain what my misunderstandings are so far?
rule "Test motion sensor in spare room"
when
Thing zwave_device_46feb3ec_node11_sensor_binary changed to ON
then
zwave_device_46feb3ec_node3_switch_dimmer.sendCommand(0)
end
Your misunterstanding is declaring your Thing as String.
This is your when part: Thing "zwave:device:46feb3ec:node11:sensor_binary" changed to ON.
It should be zwave:device:46feb3ec:node11:sensor_binary (without qoutes) as @hr3 already mentioned.
In additon it would way easier to abstract your Thing Channel into items which could receive Commands via <ITEM_NAME>.sendCommand(ON).
rule "Test motion sensor in spare room"
when
Item SpareRoom_Motion_Sensor changed to ON
then
SpareRoom_Dimmer.sendCommand(0)
end
In the logs I now get;
2018-03-13 23:20:31.204 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'test_motion.rules'
2018-03-13 23:20:31.211 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'test_motion.rules' is either empty or cannot be parsed correctly!
2018-03-13 23:20:31.353 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test_motion.rules'
which looks better, but not yet ideal. The rule certainly doesnât seem to work.
I feel like my current implementation is correct, but obviously something is still lacking in my understanding. Can anyone help?
rule "Test motion sensor in spare room"
when
Item SpareRoom_Motion_Sensor changed to CLOSED
then
logInfo("_rule_","SpareRoom_Motion_Sensor")
SpareRoom_Dimmer.sendCommand(0)
end
A contact can only have the state OPEN or CLOSED.
You can ignore
Configuration model âtest_motion.rulesâ is either empty or cannot be parsed correctly!
Does the dimmer works, if you change the item-value manualy?
I get the same Configuration model 'test_motion.rules' is either empty or cannot be parsed correctly! error which you say I can ignore.
I can see the motion sensor being triggered in the log
2018-03-14 15:09:15.446 [vent.ItemStateChangedEvent] - zwave_serial_zstick_46feb3ec_serial_sof changed from 83882 to 83883
2018-03-14 15:09:15.466 [vent.ItemStateChangedEvent] - zwave_device_46feb3ec_node11_alarm_motion changed from OFF to ON
2018-03-14 15:09:15.582 [vent.ItemStateChangedEvent] - zwave_serial_zstick_46feb3ec_serial_sof changed from 83883 to 83884
2018-03-14 15:09:15.602 [vent.ItemStateChangedEvent] - zwave_device_46feb3ec_node11_alarm_tamper changed from OFF to ON
2018-03-14 15:09:17.741 [vent.ItemStateChangedEvent] - zwave_serial_zstick_46feb3ec_serial_sof changed from 83884 to 83885
2018-03-14 15:09:17.755 [vent.ItemStateChangedEvent] - zwave_device_46feb3ec_node11_sensor_binary changed from OFF to ON
but I donât see anything about the item itself changing state. (Should I?)
I also donât see any output from the loginfo command you added.
Iâm not sure what you mean by changing the item value manually, but if I create a sitemap with the dimmer item I can control the dimmer in BasicUI.
The fact that you donât see the logging implies the rule isnât firing.
Iâd also say that your motion sensor has an ON and OFF value rather than a OPEN or CLOSED value. Contact is more for window or door sensors. In fact, your log shows it is receiving ON or OFF, so you should probably use a switch then instead of a contact?
You could also try the rule as:
rule "Test motion sensor in spare room"
when
Item SpareRoom_Motion_Sensor changed
then
logInfo("_rule_","SpareRoom_Motion_Sensor")
// You have to see the above in the log, otherwise it means the
// rule was never triggered with the described condition.
if (SpareRoom_Motion_Sensor.state == ON)
{
SpareRoom_Dimmer.sendCommand(0)
}
end
For searching the problem you can define the items in a sitemap and changing the switch manually.
We know only that part of your configuration you have posted. Your z-wave definition und your items donât match. If isât a item you can use for example
Item zwave_device_46feb3ec_node11_sensor_binary changed to ON
You have already created the items through the paper UI.
Remove the SpareRoom_Motion_Sensor from you items file.
and try:
rule "Test motion sensor in spare room"
when
Item zwave_device_46feb3ec_node11_sensor_binary changed
then
logInfo("_rule_","SpareRoom_Motion_Sensor")
// You have to see the above in the log, otherwise it means the
// rule was never triggered with the described condition.
if (SpareRoom_Motion_Sensor.state == ON)
{
SpareRoom_Dimmer.sendCommand(0)
}
end
Thanks everyone for so many helpful replies.
Changing the item from a contact to a switch solved it. Thanks @SkyyStorm. It is great to finally see my system spring to life, even if itâs just a toy example.
This gives me a working demonstration to further develop from. Hopefully Iâll be able to be independent for a little while at least now. Iâm sure Iâll be back though.
Does this really work. If I use it I get an error in log.
I want to get a rule triggered if the thing gets an update but this rule is never triggered. Only difference is, that I use the thing not the item.
when
Thing zwave_device_15a7a49f3a6_node3 received update
then
...
2018-03-14 10:08:23.011 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'einstellungen.rules' has errors, therefore ign
oring it: [20,3]: no viable alternative at input 'zwave_device_15a7a49f3a6_node3'
This one will work, but never triggered:
when
Thing 'zwave_device_15a7a49f3a6_node3' received update
then
...
even if a log message indicates this:
2018-03-14 10:06:42.146 [me.event.ThingUpdatedEvent] - Thing 'zwave:device:15a7a49f3a6:node3' has been updated.
The triggers for rules are things channels and items not the things themselves, I donât think thatâs possible.
Define an item for a channel of the thing and use the item to trigger the rule.
@hr3
Thanks for teh reply. Can you guide me what I should do:
Should I do this? Without any channel? Because I cannot use a channel because this channel is not triggered only the thing itself. and if yes w hich item type should I user?