Qball's Weblog
IfThenElse and Domotica..
I created the following IfThenElse script:
What this does it the following:
- MPD: If my MPD box is playing, power on stereo, wait 5 seconds and switch to the right channel.
- XBMC: If xbmc is playing (or a remote pc (aka desktop) outputs audio via the local pulseaudio server) power on stereo, wait 5 seconds and switch to right channel.
- Neither MPD and XBMC are playing, turn off stereo.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
[Timeout] type=TimerTrigger timeout=15 action=MultiAction [MultiAction] type=MultiAction action=MpcCheck;PulseCheck [MpcCheck] type=ExternalToolCheck cmd=mpc -h 192.150.0.104 status compare-old-state=true output-compare=(playing|paused) then_action=CombineOnMPD else_action=CombineOff [PulseCheck] type=ExternalToolCheck cmd=pacmd list-sink-inputs compare-old-state=true output-compare=RUNNING then_action=CombineOnXBMC else_action=CombineOff [CombineOnMPD] type=MultiAction action=StereoOn;CombineOnMPDReal [CombineOnMPDReal] type=TimerTrigger timeout=5 repeat=false action=CombineOnMPDReal2 [CombineOnMPDReal2] type=ExternalToolAction kill_child=false cmd=irsend SEND_ONCE NAD_SR6 video-1 [CombineOnXBMC] type=MultiAction action=StereoOn;CombineOnXBMCReal [CombineOnXBMCReal] type=TimerTrigger timeout=5 repeat=false action=CombineOnXBMCReal2 [CombineOnXBMCReal2] type=ExternalToolAction kill_child=false cmd=irsend SEND_ONCE NAD_SR6 disc [StereoOn] type=MultiCombine action=StereoOnReal [StereoOnReal] type=ExternalToolAction kill_child=false cmd=stereo.sh on [CombineOff] type=AndCombine action=CombineOffReal [CombineOffReal] type=ExternalToolAction kill_child=false cmd=stereo.sh off |