No worries. I very much appreciate your help and there's no hurry.
Our time zone difference makes it a slow process !
Cheers,
Peter
Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
IP controlled relay board
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: IP controlled relay board
i am -6 UTC where abouts are you?
Re: IP controlled relay board
I'm in Sydney - UTC+10
Very pleased to report that this is giving me the board status feedback I'm after -
I tested with relays 1, 2, 3 and 7 ON and the feedback was 'G' which converts to 01000111 exactly as it should.
Now I have to figure out how to convert the byte to binary and broadcast it out to Demopad.
Cheers,
Peter
Very pleased to report that this is giving me the board status feedback I'm after -
Code: Select all
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.0.56', 17494)) # connect to board
f = 'empty' # initialise feedback
try:
s.sendall(b'\x24') # request status
f = s.recv(1024) # get feedback
except:
pass #ignore all exceptions
finally:
s.close() #disconnect from board
print 'feedback = ', repr(f)Now I have to figure out how to convert the byte to binary and broadcast it out to Demopad.
Cheers,
Peter
Re: IP controlled relay board
Final code -
Parsing the feedback in Demopad works fine so that's this little project finished !
Cheers,
Peter
Code: Select all
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.0.56', 17494)) # connect to board
try:
s.sendall(b'\x24') # request status
f = s.recv(1024) # get feedback
except:
pass # ignore all exceptions
finally:
s.close() # disconnect from board
fbin = ' '.join('{0:08b}'.format(ord(x), 'b') for x in f) # convert to binary
eg.plugins.BroadcastListener.Broadcast('Status '+fbin, u'', 33339) # broadcast to demopadCheers,
Peter
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: IP controlled relay board
well I guess i didn't directly solve your problem. I am hoping the code i provided did help you get to the solution..
Always feels good to get something working especially if you have spent a lot of time trying to get it going.. I may not always have the solution but i usually will say or provide something that helps get the job done. It's hard when dealing with devices I have never dealt with hands on. it's a lot of back and forth testing..
let me know if there is anything else I can do or help with.
Always feels good to get something working especially if you have spent a lot of time trying to get it going.. I may not always have the solution but i usually will say or provide something that helps get the job done. It's hard when dealing with devices I have never dealt with hands on. it's a lot of back and forth testing..
let me know if there is anything else I can do or help with.
Re: IP controlled relay board
Yes your code certainly helped. It pointed me to sockets for communication, whereas the help I was getting on the AVS Demopad thread was all about using urllib which doesn't appear to be able to do what I wanted. It's incredible what you can find freely available with a quick Google search. Once I knew about sockets I found a great tutorial on them and then plenty of code examples at Stack Overflow.
Even with my very limited python knowledge I was able to use the code examples with slight modification and it all came together surprisingly easily !
Cheers,
Peter
Even with my very limited python knowledge I was able to use the code examples with slight modification and it all came together surprisingly easily !
Cheers,
Peter
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: IP controlled relay board
you did state you have some programming experience.
Python is unbelievably easy.. You are already familiar with what syntax is and and operators are.. if, elif else, +, -, ==, != those kinds of things.
back in the day most languages had markers to separate code blocks. in C code it's ; and {} in python it's indents. indents can be multiples of the tab key, or they can be multiples of even numbered spaces.
python is a high level language so things have been made in a way so that you do not have to concern yourself with memory management, or garbage collection. freeing the memory.. declaring variables.. all of that stuff is done for you. so all you have to concern yourself with is programming your application. Python is also one of the most used languages on the planet.. there is a plethora of tutorials and examples on the internet..
If you have an android device I would recommend downloading an application called "Learn Python" It is an almost kindergartenish app... But It will teach you a whole lot.. It has lessons and then tests at the end of the lesson It is done in a way that makes you remember.. You should use that somewhat..
I know you are new to EG and if you dive into the python scripting you will then begin to see the power of what EG can do. the true potential of EG is in it's real time scripting.
I have 4 TV's and 1 projector, 5 HTPC's, 5 remotes, 80 zwave devices, 2 fireplace controllers (self made), 3 furnaces, security system including cameras, Whole home audio, sump pump controllers (self made), filter reminders for the furnaces (self made), door locks, geofencing.... and I am sure I am forgetting some things in that list.. But all of it is controlled by a single running copy of EG
Python is unbelievably easy.. You are already familiar with what syntax is and and operators are.. if, elif else, +, -, ==, != those kinds of things.
back in the day most languages had markers to separate code blocks. in C code it's ; and {} in python it's indents. indents can be multiples of the tab key, or they can be multiples of even numbered spaces.
python is a high level language so things have been made in a way so that you do not have to concern yourself with memory management, or garbage collection. freeing the memory.. declaring variables.. all of that stuff is done for you. so all you have to concern yourself with is programming your application. Python is also one of the most used languages on the planet.. there is a plethora of tutorials and examples on the internet..
If you have an android device I would recommend downloading an application called "Learn Python" It is an almost kindergartenish app... But It will teach you a whole lot.. It has lessons and then tests at the end of the lesson It is done in a way that makes you remember.. You should use that somewhat..
I know you are new to EG and if you dive into the python scripting you will then begin to see the power of what EG can do. the true potential of EG is in it's real time scripting.
I have 4 TV's and 1 projector, 5 HTPC's, 5 remotes, 80 zwave devices, 2 fireplace controllers (self made), 3 furnaces, security system including cameras, Whole home audio, sump pump controllers (self made), filter reminders for the furnaces (self made), door locks, geofencing.... and I am sure I am forgetting some things in that list.. But all of it is controlled by a single running copy of EG
