Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var int amp_power_slot=100
- var int radio_slot=200
- var int amp_select_slot=300
- var int tvset_slot=500
- var int projector_slot=700
- var int screen_slot=900
- rule "amplifier on"
- when
- Item amp_power received command
- then
- if (receivedCommand == ON) {
- createTimer(now.plusMillies(amp_power_slot), [ | amplifier.sendCommand("on") ])
- createTimer(now.plusMillis(radio_slot), [ | cubiepower.sendCommand(ON) ])
- if(amp_source.state.toString == "") {
- sendCommand(amp_source, "tv")
- }
- }
- if (receivedCommand == OFF) {
- createTimer(now.plusMillies(amp_power_slot), [ | amplifier.sendCommand("off") ])
- createTimer(now.plusMillis(radio_slot), [ | cubiepower.sendCommand(OFF) ])
- sendCommand(amp_source, "")
- sendCommand(proj_power, OFF)
- if(tv_power.state == ON) {
- sendCommand(tv_power, OFF)
- }
- }
- end
- rule "volume changed"
- when
- Item amp_vol received command
- then
- sendCommand(amplifier, receivedCommand.toString)
- postUpdate(triggeringItem, "")
- end
- rule "source changed"
- when
- Item amp_source received command
- then
- if (receivedCommand.toString != "") {
- if(amp_power.state != ON) {
- sendCommand(amp_power, ON)
- }
- createTimer(now.plusMillis(amp_select_slot), [ | amplifier.sendCommand(amp_source.state.toString) ])
- }
- end
- rule "transmitter changed"
- when
- Item tv_power received command
- then
- createTimer(now.plusMillis(tvset_slot), [ | tvtransmit.sendCommand("BOX_POWER") ])
- if(receivedCommand != tv_power.state) {
- postUpdate(triggeringItem, receivedCommand.toString)
- }
- if(receivedCommand == OFF && amp_source.state.toString == "dvd") {
- sendCommand(amp_source, "tv")
- }
- if(receivedCommand == ON && amp_source.state.toString != "dvd") {
- sendCommand(amp_source, "dvd")
- }
- end
- rule "projector changed"
- when
- Item proj_power received command
- then
- sendCommand(screen_proj, receivedCommand)
- if (receivedCommand==ON) {
- createTimer(now.plusMillis(projector_slot), [ | projector.sendCommand("KEY_POWER")])
- if(tv_power.state!=ON) {
- sendCommand(tv_power, ON)
- postUpdate(tv_power, ON)
- }
- if(amp_source.state.toString != "dvd") {
- sendCommand(amp_source, "dvd")
- }
- }
- if (receivedCommand==OFF) {
- createTimer(now.plusMillis(projector_slot), [ | projector.sendCommand("KEY_SUSPEND")])
- }
- end
- rule "screen moves"
- when
- Item screen_proj received command
- then
- if (receivedCommand==ON) {
- createTimer(now.plusMillis(screen_slot), [ |screen_command.sendCommand("down")])
- }
- if (receivedCommand==OFF) {
- createTimer(now.plusMillis(screen_slot), [ |screen_command.sendCommand("up")])
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement