«
Rule languages supports changed item features
type | name | label | state |
---|---|---|---|
Number | Alarm_Mode | Alarm Mode | <from> |
Number | Alarm_Delay | Alarm Delay | 5 |
rule 'Execute rule when item is changed to specific number for specified duration' do
<trigger>, for: <delay>
run { logger.info("Alarm Mode Updated")}
end
from | to | trigger | delay | should | |
---|---|---|---|---|---|
8 | 14 | changed Alarm_Mode | 5.seconds | should | |
8 | 14 | changed Alarm_Mode | Alarm_Delay | should | |
8 | 14 | changed Alarm_Mode, to: 14 | 5.seconds | should | |
8 | 10 | changed Alarm_Mode, to: 14 | 5.seconds | should not | |
8 | 14 | changed Alarm_Mode, from: 8, to: 14 | 5.seconds | should | |
8 | 10 | changed Alarm_Mode, from: 10, to: 14 | 5.seconds | should not | |
8 | 14 | changed Alarm_Mode, to: [10, 14] | 5.seconds | should | |
8 | 14 | changed Alarm_Mode, from: [8, 10], to: 14 | 5.seconds | should | |
8 | 14 | changed Alarm_Mode, from: [8, 10], to: [11, 14] | 5.seconds | should | |
8 | 12 | changed Alarm_Mode, from: [8, 10], to: [11, 14] | 5.seconds | should not | |
8 | 14 | changed Alarm_Mode, from: [9, 10], to: [11, 14] | 5.seconds | should not |
type | name | label |
---|---|---|
Number | Alarm_Mode | Alarm Mode |
rule "Execute rule when item is changed and is modified during specified duration" do
changed Alarm_Mode, for: 20.seconds
triggered { |item| logger.info("Alarm Mode Updated to #{item}")}
end
type | name | label |
---|---|---|
Number | Alarm_Mode | Alarm Mode |
rule "Execute rule when item is changed and is modified during specified duration" do
changed Alarm_Mode, to: 14, for: 10.seconds
triggered { |item| logger.info("Alarm Mode Updated to #{item}")}
end
type | name | label | group | state |
---|---|---|---|---|
Number | Alarm_Mode | Alarm Mode | Modes | 0 |
Number | Alarm_Two_Mode | Alarm Two Mode | Modes | <from> |
rule "Execute rule when group item is changed" do
<trigger>, for: 5.seconds
triggered { |item| logger.info("#{item.id} Changed")}
end
from | to | trigger | should | |
---|---|---|---|---|
8 | 14 | changed Modes.members | should | |
8 | 14 | changed Modes.members, to: 14 | should | |
8 | 10 | changed Modes.members, to: 14 | should not | |
8 | 14 | changed Modes.members, from: 8, to: 14 | should | |
8 | 10 | changed Modes.members, from: 10, to: 14 | should not |
type | name | function | params |
---|---|---|---|
Switch | Switches | OR | ON,OFF |
type | name | label | group | state |
---|---|---|---|---|
Switch | Switch_One | Switch One | Switches | OFF |
Switch | Switch_Two | Switch Two | Switches | <from> |
rule "Execute rule when group is changed" do
<rule>, for: 5.seconds
triggered { |item| logger.info("#{item.id} Changed")}
end
from | to | rule | should | |
---|---|---|---|---|
OFF | ON | changed Switches | should | |
OFF | ON | changed Switches, to: ON | should | |
ON | OFF | changed Switches, to: ON | should not | |
OFF | ON | changed Switches, from: OFF, to: ON | should | |
OFF | ON | changed Switches, from: ON, to: ON | should not |
type | name | label | group | state |
---|---|---|---|---|
Switch | Switch_One | Switch One | OFF | |
Switch | Switch_Two | Switch Two | OFF |
rule 'A rule with multiple changed duration triggers' do
changed Switch_One, to: ON, for: 4.seconds
changed Switch_Two, to: ON, for: 8.seconds
triggered do |item|
logger.info("#{item.name} changed")
end
end
type | name | label | group | state |
---|---|---|---|---|
Switch | Switch_One | Switch One | OFF |
rule 'A rule with a changed duration and a condition' do
changed Switch_One, to: ON, for: 1.second
only_if { <condition> }
triggered { |item| logger.info("Rule #{item.name} changed") }
end
condition | should | |
---|---|---|
false | should not | |
true | should |
type | name | label | state |
---|---|---|---|
String | String_One | String One | ONE |
rule 'Changed String' do
changed String_One, to: 'TWO', for: 2.seconds
triggered do |item|
logger.info("Changed rule: #{item.name} changed")
end
end
type | name | label | state |
---|---|---|---|
String | String_One | String One | ONE |
rule 'Changed String' do
changed String_One, to: 'TWO', for: 5.seconds
triggered do |item|
logger.info("Trigger Delay Fired")
end
end
type | name | state |
---|---|---|
Number | Alarm_Mode | <initial> |
rule 'Execute rule with range conditions' do
changed Alarm_Mode, <conditions>, for: 5.seconds
run { |event| logger.info("Alarm Mode: Changed from #{event.was} to #{event.state}") }
end
initial | conditions | change | should | |
---|---|---|---|---|
10 | from: 8..10 | 14 | should | |
15 | from: 4..12 | 14 | should not |
initial | conditions | change | should | |
---|---|---|---|---|
4 | to: 8..10 | 9 | should | |
11 | to: 4..12 | 14 | should not |
initial | conditions | change | should | |
---|---|---|---|---|
4 | from: 2..5, to: 8..10 | 9 | should | |
4 | from: 5..6, to: 8..10 | 9 | should not | |
4 | from: 2..5, to: 8..12 | 14 | should not |
type | name | state |
---|---|---|
Number | Alarm_Mode | <initial> |
rule 'Execute rule with range conditions' do
changed Alarm_Mode, <conditions>, for: 5.seconds
run { |event| logger.info("Alarm Mode: Changed from #{event.was} to #{event.state}") }
end
initial | conditions | change | should | |
---|---|---|---|---|
10 | from: ->f { f == 10 } | 14 | should | |
15 | from: ->f { f == 10 } | 14 | should not |
initial | conditions | change | should | |
---|---|---|---|---|
4 | to: ->t { t == 9 } | 9 | should | |
11 | to: ->t { t == 13} | 14 | should not |
initial | conditions | change | should | |
---|---|---|---|---|
4 | from: ->f { f == 4 }, to: ->t { t == 9 } | 9 | should | |
4 | from: ->f { f == 4 }, to: ->t { t == 8 } | 9 | should not | |
4 | from: ->f { f == 94 }, to: ->t { t == 9 } | 9 | should not |