Qball's Weblog
IfThenElse: RFID card interaction.
A while back I bought a small USB rfid reader, after I got it, it turned out to be utter crap.
While in theory being very nice, it turned out to be a bit dissapointing. So I left it in lying in a box.
Yesterday I thought, lets use it for my domotica box. Now I can use the (few) RFID cards I have to enable/disable light/music/stereo.
To accomplish this I added a module to IfThenElse that can watch output and activate a specific branch depending on input, the script now looks as follow:
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 |
[RFRead] type=MultiOutputWatch cmd=bash -c "while read input; do echo $input | tr -d \\r ; done < /dev/ttyUSB1" fire_regex=.4E000477427F;.4500F6A0C6D5;.4E00044A6A6A;.4500F6A26978;.4E00047E3400 action=StereoOn;PlayMusic;LightOn;AllOff;Other [StereoOn] type=ExternalToolAction cmd=stereo.sh on [PlayMusic] type=ExternalToolAction cmd=mpc -h squeeze play [LightOn] type=ExternalToolAction cmd=remote b 1 1 [AllOff] type=ExternalToolAction cmd=bash -c "switch_lights.sh all off; mpc -h squeeze stop; stereo.sh off" [Other] type=ExternalToolAction cmd=mpc -h squeeze toggle |
Now with a bit of creativety I could make ifthenelse branches being enabled/disabled based on the selected card . (I need to figure out how todo this propperly)
To be continued.</pre>