I have seen a few conversations about how to control the relays and send RS-232 serial data via IP using the Global Cache GC100. I tried the built-in support in hass.io without success. I found a way that works sufficiently for my immediate needs, and thought others might be interested. It uses a couple of simple command_line platform calls to launch python scripts. This is my first post in this forum, so I will do my best to follow the rules and format properly, but please be patient in correcting any deficiencies I have.
In this example, I am turning on a Panasonic PT-AE2000U projector via a serial string command, and simultaneously lowering a motorized screen via a relay contact closure. The combination of these two events is grouped together as “projector on.” Similarly, I have the equivalent commands to turn off the projector and raise the screen grouped as “projector off.”
First, I put the following in configuration.yaml:
switch:
- platform: command_line
switches:
projector:
command_on: "python3 projector_on_via_globalcache.py"
command_off: "python3 projector_off_via_globalcache.py"
friendly_name: Projector
The two python scripts must be placed in the config folder (where configuration.yaml is).
projector_on_via_globalcache.py:
import socket
IPADDR = '192.168.1.251'
SERIALPORT = 4999
CONTROLPORT = 4998
def projectorOn():
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((IPADDR, SERIALPORT))
s.send(b'\x02PON\x03\r\n')
s.close()
def screenDown():
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((IPADDR, CONTROLPORT))
s.send(b'setstate,3:1,1\r\n')
s.close()
projectorOn()
screenDown()
projector_off_via_globalcache.py:
import socket
IPADDR = '192.168.1.251'
SERIALPORT = 4999
CONTROLPORT = 4998
def projectorOff():
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((IPADDR, SERIALPORT))
s.send(b'\x02POF\x03\r\n')
s.close()
def screenUp():
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((IPADDR, CONTROLPORT))
s.send(b'setstate,3:1,0\r\n')
s.close()
projectorOff()
screenUp()
The user will obviously need to consult the Global Cache docs and documentation for the protocols for other relays or whatever serial device they are communicating with.
This is control output only, and does not yet provide any status feedback. As I learn more about HA, I’ll work on more functionality.
I hope this is useful.