«
Automation is executed in triggered blocks
type | name | label | state |
---|---|---|---|
Switch | TestSwitch | Test Switch | OFF |
rule 'Triggered has access directly to item triggered' do
changed TestSwitch
triggered { |item| logger.info("#{item.id} triggered") }
end
type | name | label | state | group |
---|---|---|---|---|
Switch | Switch1 | Switch Number One | OFF | Switches |
Switch | Switch2 | Switch Number Two | OFF | Switches |
rule 'Triggered item is item changed when a group item is changed.' do
changed Switches.members
triggered { |item| logger.info("Switch #{item.id} changed to #{item}")}
end
type | name | label | state | group |
---|---|---|---|---|
Switch | Switch1 | Switch Number One | OFF | Switches |
Switch | Switch2 | Switch Number Two | OFF | Switches |
rule 'Turn off any switch that changes' do
changed Switches.members
triggered(&:off)
end
type | name | label | state | group |
---|---|---|---|---|
Switch | Switch1 | Switch Number One | OFF | Switches |
Switch | Switch2 | Switch Number Two | OFF | Switches |
rule 'Turn a switch off and log it, 5 seconds after turning it on' do
changed Switches.members, to: ON
delay 5.seconds
triggered(&:off)
triggered {|item| logger.info("#{item.label} turned off") }
end