An old phone, a raspberry pi, a handful of resistors and a simple python script make a very nice home control center.
The phone is a T65 TDK. It was very popular in the Netherlands in the 70’s and 80’s. It comes in a few colors, but preferably orange.
The phone now controls our Sonos audio system and our Philips Hue lights. The little black button rings the front door bell, great gimmick for the kids.
Button functions:
- 1: a radio station
- 2: volume up
- 3: another radio station
- 4: previous song
- 5: play / pause
- 6: next song
- 7: a playlist
- 8: volume down
- 9: another playlist
- *: Philips Hue off
- 0: Philips Hue dimmed
- #: Philips Hue bright
And the Python script
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 |
import RPi.GPIO as GPIO import urllib2, socket import iot # Use pin numbers (not GPIO numbers) # these are the inner rows with numbers in the circles # [3,5,7,8,10,11,12,13,15,16,18,19,21,22,23,24,26] def main_loop(): col1 = GPIO.input(10) col2 = GPIO.input(16) col3 = GPIO.input(26) row1 = GPIO.input(22) row2 = GPIO.input(8) row3 = GPIO.input(12) row4 = GPIO.input(24) but = GPIO.input(18) key = -1 if col1 == True and row1 == True: key = 1 elif col2 == True and row1 == True: key = 2 elif col3 == True and row1 == True: key = 3 elif col1 == True and row2 == True: key = 4 elif col2 == True and row2 == True: key = 5 elif col3 == True and row2 == True: key = 6 elif col1 == True and row3 == True: key = 7 elif col2 == True and row3 == True: key = 8 elif col3 == True and row3 == True: key = 9 elif col1 == True and row4 == True: key = 10 elif col2 == True and row4 == True: key = 11 elif col3 == True and row4 == True: key = 12 elif but == True: key = 13 if key <> -1: url = 'http://192.168.1.11:8002/casa/index.php?action=dial&device=10&dial=%d' % key try: response = urllib2.urlopen(url, timeout=5) except IOError: iot.iot_send_string(999,'T65 Orange time out: ' + url) GPIO.setmode(GPIO.BOARD) pins = [8,10,12,16,18,22,24,26] for pin in pins: GPIO.setup(pin, GPIO.IN) iot.iot_send_string(999,'T65 Orange booted') while 1: try: main_loop() except: iot.iot_send_trace() |
The script calls an URL on the home server: another raspberry pi which controls all connected devices. A description of this home server will be the subject for a future picnic.