Automatic HDMI Device Detection
Automatic HDMI Device Detection
Hi there,
I want to use eventghost for the following situation:
My HTPC is connected to my AV-Receiver, which is connected to the LCD-TV. All over HDMI.
The AV-Receiver has the "HDMI Passthrough" feature, which allows to passthrough the HDMI Signal to the TV, even if the AV-Receiver is turned off.
At the moment i need to switch between "Dolby Digital Passthrough" (if AV-Receiver is turned ON) and "Decode to Stereo" (if AV is turned OFF) in ffdshow Audio manually.
Is it possible for eventghost to detect the connected Display Device and switch the settings automatically? The Display Device shows the Name of the TV if AV is turned off, and the name of the AV if its turned ON. So all i need is a plugin which triggers an event if a certain Display device is found.
If theres no plugin, is there some documentation or do u have any tips how i could write one by myself?
I want to use eventghost for the following situation:
My HTPC is connected to my AV-Receiver, which is connected to the LCD-TV. All over HDMI.
The AV-Receiver has the "HDMI Passthrough" feature, which allows to passthrough the HDMI Signal to the TV, even if the AV-Receiver is turned off.
At the moment i need to switch between "Dolby Digital Passthrough" (if AV-Receiver is turned ON) and "Decode to Stereo" (if AV is turned OFF) in ffdshow Audio manually.
Is it possible for eventghost to detect the connected Display Device and switch the settings automatically? The Display Device shows the Name of the TV if AV is turned off, and the name of the AV if its turned ON. So all i need is a plugin which triggers an event if a certain Display device is found.
If theres no plugin, is there some documentation or do u have any tips how i could write one by myself?
Re: Automatic HDMI Device Detection
You can do whatever you want but you need additional hardware.brand10 wrote:Is it possible for eventghost to detect the connected Display Device and switch the settings automatically? The Display Device shows the Name of the TV if AV is turned off, and the name of the AV if its turned ON. So all i need is a plugin which triggers an event if a certain Display device is found.
I'm using for a long time now the RCAware HDMI-CEC to USB bridge, with its plugin, and is extremely powerful.
It handles all events in the HDMI chain, allowing EG to interpret and interact with them.
This is an example of how the RCAware plugin reads a common HDMI chain:

Each of the elements of the chain generates events on the bus HDMI, you can use these events to handle any action in EG.
Regards,
xavier.
Re: Automatic HDMI Device Detection
Well, this would be a solution, but i don't want to spend some money for it.
All i need is a "pc local" detection which detects, which display device is connected currently.
All i need is a "pc local" detection which detects, which display device is connected currently.
Re: Automatic HDMI Device Detection
The HDMI output of your PC does not normally have the ability to read data in transit on the CEC bus.brand10 wrote:Well, this would be a solution, but i don't want to spend some money for it.
All i need is a "pc local" detection which detects, which display device is connected currently.
That's why I told you to buy additional hardware.
I could solve by connecting your PC to your TV via the VGA cable, but obviously you would have lower quality video image.
Regards,
xavier.
Re: Automatic HDMI Device Detection
You are in luck. The CEC physical address of the computer is provided in the EDID data and is probably the only piece of data needed for CEC which is available without additional hardware. Here is a piece of code taken from my RCAware plugin. You can turn use this in a Python script and call it once per second (or whatever) with a timer. Your code would compare the previous physical address with the newly detected one and when it changes raise an event, or directly continue to process whatever it is you want to do in Python. It requires you import wmi.py (attached). You could turn this into a plugin pretty easily...
Code: Select all
class DetPhysAddr(eg.ActionBase):
name = 'Determine Physical Address'
description = """\
Find the current physical address; returns physical address of the active monitor."""
def __call__(self):
pAddr=None
def parse_edid(pEdid):
p1=None
p2=None
addr=None
for i in range(252):
try:
if [pEdid[i]+pEdid[i+1]+pEdid[i+2]] == ['\x03\x0c\x00']:
try:
p1=hex(ord(pEdid[i+3]))+'00'
except:
p1=[pEdid[i+3]]+'00'
try:
p2=hex(ord(pEdid[i+4]))+'00'
except:
p2=pEdid[i+4]+'00'
addr=p1[2]+'.'+p1[3]+'.'+p2[2]+'.'+p2[3]
break
except:
pass
return addr
if sys.platform == "win32":
if sys.getwindowsversion() >= (6, ):
# Use WMI for Vista/Win7
import wmi
wmi_connection = wmi.WMI(namespace="WMI")
else:
# Use registry as fallback for Win2k/XP/2003
import _winreg
wmi_connection = None
import win32api
edid = None
if sys.platform == "win32":
try:
if wmi_connection:
for monitor in wmi_connection.WmiMonitorDescriptorMethods():
try:
edid = monitor.WmiGetMonitorRawEEdidV1Block(1)
except:
pass
else:
edid = "".join(chr(i) for i in edid[0])
pAddr=parse_edid(edid)
if pAddr <> None:
break
else:
for monitor in win32api.EnumDisplayMonitors(None, None):
moninfo = win32api.GetMonitorInfo(monitor[0])
device = win32api.EnumDisplayDevices(moninfo["Device"])
id = device.DeviceID.split("\\")[1]
driver = "\\".join(device.DeviceID.split("\\")[-2:])
subkey = "\\".join(["SYSTEM", "CurrentControlSet", "Enum", "DISPLAY", id])
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey)
numsubkeys, numvalues, mtime = _winreg.QueryInfoKey(key)
for i in range(numsubkeys):
hkname = _winreg.EnumKey(key, i)
hk = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "\\".join([subkey, hkname]))
if _winreg.QueryValueEx(hk, "Driver")[0] == driver:
devparms = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "\\".join([subkey, hkname, "Device Parameters"]))
try:
edid = _winreg.QueryValueEx(devparms, "EDID")[0]
pAddr=parse_edid(edid)
break
except:
pass
if pAddr <> None:
break
except:
pass
return pAddr
- Attachments
-
- wmi.py
- (46.56 KiB) Downloaded 265 times
Re: Automatic HDMI Device Detection
Thanks for your script, i will take a look at it.
I found a primitive, but working solution too. Advantage is, that it's very simple:
Together with the two standard Eventghost actions: "if successful jump" and "if not successful jump" its possible to trigger some actions, depending on the current display device. I trigger this small python script with a timer or from MediaPortal actions (by a MediaPortal Plugin).
P.S.: In which directory i have to place the wmi.py?
I found a primitive, but working solution too. Advantage is, that it's very simple:
Code: Select all
from win32api import EnumDisplayDevices
mon = EnumDisplayDevices('\\\\.\\DISPLAY1', 0, 0)
if mon.DeviceID.find('Toshiba') > -1:
eg.result = "Toshiba LCD-TV found"
else:
eg.result = None
P.S.: In which directory i have to place the wmi.py?
Re: Automatic HDMI Device Detection
nice... I'll have to try that this weekend.
your python code should be placed in a Python 'Action'... not an actual file
your python code should be placed in a Python 'Action'... not an actual file
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Automatic HDMI Device Detection
You could put that into a python script action or into a .py file and put build a plugin around it.
Re: Automatic HDMI Device Detection
Sorry, me again: Where i have to place the wmi.py ?
Re: Automatic HDMI Device Detection
unless you want to build a complete plugin (lots more work) you will not use a .py file. Place your code in a SCRIPT ACTION
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Automatic HDMI Device Detection
Yes, i know. But wmi.py looks like a library, which should be placed somewhere, so i can "import" it from a script action.
Re: Automatic HDMI Device Detection
gotcha.. I was missing your pointbrand10 wrote:Yes, i know. But wmi.py looks like a library, which should be placed somewhere, so i can "import" it from a script action.

Post a new thread with the question... how to use a library - or something like that.
setup... XBMC, W7MC for DVR & Live OTA TV, JRMC for multi-zone audio, EG, MiCasaVerde Vera3, USB-UIRT IR receiver, Harmony remote, 5.2 home theater system
Re: Automatic HDMI Device Detection
Any .py files you wish to import for use in an EventGhost Python Script action can just be placed into the Program files\EventGhost directory.
Re: Automatic HDMI Device Detection
I am not having with problems with my hdmi detecting hardware, fortunately. Though there could be an issue with some components running an ample amount slower because of a lot of ports waiting to detect which hardware is plugged in. That way, it makes for a lot tougher time in detecting the hardware the remote will listen to.
I think it would be better if I could write some external plug-in to oversee the whole selection process.
I think it would be better if I could write some external plug-in to oversee the whole selection process.