«
Rule languages supports item update trigger
type | name | group | state |
---|---|---|---|
Number | Alarm_Mode | AlarmModes | 7 |
Number | Alarm_Mode_Other | AlarmModes | 7 |
rule 'Execute rule when item is updated to any value' do
updated Alarm_Mode
run { logger.info("Alarm Mode Updated") }
end
rule 'Execute rule when item is updated to specific number' do
updated Alarm_Mode, to: 7
run { logger.info("Alarm Mode Updated") }
end
update | log | |
---|---|---|
7 | should | |
14 | should not |
rule 'Execute rule when item is updated to one of many specific states' do
updated Alarm_Mode, to: [7,14]
run { logger.info("Alarm Mode Updated")}
end
update | log | |
---|---|---|
7 | should | |
14 | should | |
10 | should not |
rule 'Execute rule when group is updated to any state' do
updated AlarmModes
triggered { |item| logger.info("Group #{item.id} updated")}
end
rule 'Execute rule when member of group is changed to any state' do
updated AlarmModes.members
triggered { |item| logger.info("Group item #{item.id} updated")}
end
rule 'Execute rule when member of group is changed to one of many states' do
updated AlarmModes.members, to: [7,14]
triggered { |item| logger.info("Group item #{item.id} updated")}
end
update | log | |
---|---|---|
7 | should | |
14 | should | |
10 | should not |
type | name | state |
---|---|---|
Number | Alarm_Mode | <initial> |
rule 'Execute rule with range conditions' do
updated Alarm_Mode, <conditions>
run { |event| logger.info("Alarm Mode: Updated to #{event.state}") }
end
initial | conditions | change | should | |
---|---|---|---|---|
4 | to: 8..10 | 9 | should | |
11 | to: 4..12 | 14 | should not |
type | name | state |
---|---|---|
Number | Alarm_Mode | <initial> |
rule 'Execute rule with proc conditions' do
updated Alarm_Mode, <conditions>
run { |event| logger.info("Alarm Mode: Updated to #{event.state}") }
end
initial | conditions | change | should | |
---|---|---|---|---|
4 | to: ->t { (8..10).include? t } | 9 | should | |
11 | to: ->t { (4..12).include? t } | 14 | should not |
initial | conditions | change | should | |
---|---|---|---|---|
4 | to: proc { |t|(8..10).include? t } | 9 | should | |
11 | to: proc { |t|(4..12).include? t } | 14 | should not |