EDIT: I think I have everything almost working. It is just my second loop keeps having an index failure... any ideas why my coms loop is failing?
I am currently trying to get the IR codes for my HD180x optomoa projector. It is turning into a really difficult problem.
I just need to be able to turn the power ON, nothing else.
I do not have an IR Sensor to capture the codes directly, and have taken it as a challenge to try and do it without one.
So far, it is impossible. I have tried several different approaches to getting the IR codes directly from the remote using a Raspberry Pi with no luck.
My next idea is to use an IR blaster and just cycle through all of the possible IR Power ON codes.
LIRC, which is only Pi IR software has a list of a lot of remotes: http://lirc.sourceforge.net/remotes/
What I would like to try and do is make a python script that just grabs all of the files from that list and then tries all of them. The goal is just to turn the projector on, so I can just let it run for as long as it takes and if it turns on I can find out which on did it.
So my pseudo code is as follows:
- download entire remote list.
- Index entire remote list. = RLISTINDEX[] 2a. Stop the LIRCD service.
- Replace /etc/lirc/lircd.conf with RLISTINDEX[] (move one file at a time) 3a. Start the LIRCD Service (this is so it can
- Get "Name" field from remote code files. = RNAME
- Get list of all possible codes in remote code files = IRCODE_ARRAY
- Run irsend SEND_ONCE RNAME IRCODE_ARRAY[] (cycling through the code array)
- Return to step 3.
The issues I am not sure how to do are to harvest the "Name" field and the "codes" fields from the configuration files.
Also, not sure how to send terminal commands through python.
Any ideas?
I was able to get the code to start sending and now I just need to find out how to get the "IR Codes" from the conf files...
Im so close... I just need to be able to do an "irsend list "" "" >> /home/pi/list.ist" so I can find the NAME of the remote that is currently active....... I just cant seem to figure out how to make that command run correctly. I think the quotes are messing it up.....
import os
import shutil
import subprocess
import time
# Using readline()
count = 0
#os.remove("list.list")
os.system("touch /home/pi/com.list")
os.system("touch /home/pi/list.list")
os.system("systemctl start lircd")
for filename in os.listdir('confs'):
currconf = "/home/pi/confs/" + filename
print "**********start*******"
print "1. ", filename
#print "2. ", currconf
#os.system("systemctl stop lircd")
#subprocess.call('systemctl stop lircd', shell=True)
shutil.move(currconf, "/etc/lirc/lircd.conf")
subprocess.call('systemctl reset-failed lircd', shell=True)
subprocess.call('systemctl restart lircd', shell=True)
time.sleep(1)
subprocess.call('systemctl status lircd | tail -3', shell=True)
# os.system("systemctl start lircd")
# irlist = ""
#print "3. ", irlist
os.remove("/home/pi/list.list")
os.remove("/home/pi/com.list")
os.system('irsend list \"\" \"\" >> /home/pi/list.list')
qbfile = open("/home/pi/list.list", "r")
for aline in qbfile:
values = aline.split()
print(values[0])
rname = values[0].strip('\n')
print "2. rname", rname
comlist = 'irsend list ' + rname + ' \"\" >> /home/pi/com.list'
print "3. comlist", comlist
os.system(comlist)
comfile = open("/home/pi/com.list", "r")
for coms in comfile:
comvalues = coms.split()
comand = comvalues[1]#.strip('\n')
cmd = "irsend SEND_ONCE " + rname + " " + comand
print "4. cmd ", cmd
time.sleep(.001)
os.system(cmd)
print "**********end*******"