SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v9 Customizations

Notices

SageTV v9 Customizations This forums is for discussing and sharing user-created modifications for the SageTV version 9 application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss plugins for SageTV version 9 and newer.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-14-2018, 08:04 PM
EnterNoEscape's Avatar
EnterNoEscape EnterNoEscape is offline
SageTVaholic
 
Join Date: Jun 2010
Location: Harrisburg, PA
Posts: 2,505
How do I get the IP address of an HD extender via the API?

Maybe I missed something obvious, but is there a way through the API to get the IP address of an extender?

I know I could check the ARP table, but it seems very inefficient when the SageTV server already knows.
__________________
SageTV v9 Server: ASRock Z97 Extreme4, Intel i7-4790K @ 4.4Ghz, 32GB RAM, 6x 3TB 7200rpm HD, 2x 5TB 7200rpm HD, 2x 6TB 7200rpm HD, 4x 256GB SSD, 4x 500GB SSD, unRAID Pro 6.7.2 (Dual Parity + SSD Cache).
Capture: 1x Ceton InfiniTV 4 (ClearQAM), 2x Ceton InfiniTV 6, 1x BM1000-HDMI, 1x BM3500-HDMI.

Clients: 1x HD300 (Living Room), 1x HD200 (Master Bedroom).
Software: OpenDCT :: WMC Live TV Tuner :: Schedules Direct EPG
Reply With Quote
  #2  
Old 11-15-2018, 03:33 AM
routerunner's Avatar
routerunner routerunner is offline
Sage Icon
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 1,372
Quote:
Originally Posted by EnterNoEscape View Post
Maybe I missed something obvious, but is there a way through the API to get the IP address of an extender?

I know I could check the ARP table, but it seems very inefficient when the SageTV server already knows.
You need to register and listen for the message sent by STV server any time an extender connects/disconnects with it. I use this mechanism for all my plugins, later I will send you a code snippet if you want.

Cheers
Eddy
__________________

Automatic Power Off | Squeezeslave | DVB-S Importer | DVB Decrypter & Card Client | Tuner Preroll


Every man is a damn fool for at least five minutes every day; wisdom consists in not exceeding the limit. ~ Elbert Hubbard
Reply With Quote
  #3  
Old 11-15-2018, 05:42 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,805
IIRC if you get the UI Context name, it is the IP address.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #4  
Old 11-15-2018, 05:54 AM
jusjoken jusjoken is offline
Sage Icon
 
Join Date: Dec 2005
Location: Minneapolis MN
Posts: 2,169
Quote:
Originally Posted by tmiranda View Post
IIRC if you get the UI Context name, it is the IP address.
Isn't it the MAC address ?
Reply With Quote
  #5  
Old 11-15-2018, 06:56 AM
routerunner's Avatar
routerunner routerunner is offline
Sage Icon
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 1,372
Smile

Quote:
Originally Posted by EnterNoEscape View Post
Maybe I missed something obvious, but is there a way through the API to get the IP address of an extender?

I know I could check the ARP table, but it seems very inefficient when the SageTV server already knows.
Code:
	@SuppressWarnings("rawtypes")
	public synchronized void start()
	{
	  registry.eventSubscribe(this, CLIENT_CONNECTED);
        }

	public synchronized void sageEvent(String eventName, Map eventVars)
	{
          if (CLIENT_CONNECTED.equals(eventName))
	  {
	     String MAC = (String)eventVars.get("MACAddress");
	     String IP = (String)eventVars.get("IPAddress");
          }
        }
Cheers
Eddy
__________________

Automatic Power Off | Squeezeslave | DVB-S Importer | DVB Decrypter & Card Client | Tuner Preroll


Every man is a damn fool for at least five minutes every day; wisdom consists in not exceeding the limit. ~ Elbert Hubbard
Reply With Quote
  #6  
Old 11-15-2018, 02:20 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,805
Quote:
Originally Posted by jusjoken View Post
Isn't it the MAC address ?
Yes, my bad.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #7  
Old 11-15-2018, 07:50 PM
EnterNoEscape's Avatar
EnterNoEscape EnterNoEscape is offline
SageTVaholic
 
Join Date: Jun 2010
Location: Harrisburg, PA
Posts: 2,505
Quote:
Originally Posted by routerunner View Post
Code:
	@SuppressWarnings("rawtypes")
	public synchronized void start()
	{
	  registry.eventSubscribe(this, CLIENT_CONNECTED);
        }

	public synchronized void sageEvent(String eventName, Map eventVars)
	{
          if (CLIENT_CONNECTED.equals(eventName))
	  {
	     String MAC = (String)eventVars.get("MACAddress");
	     String IP = (String)eventVars.get("IPAddress");
          }
        }
Cheers
Eddy
Thanks for this snippet. I'm coding for Node.js because that's the native language of the driver API for my Neeo remote. I'm using sagex for API related queries so as to not re-invent the wheel, but I believe that precludes subscribing to events.

Maybe I'm going about this the wrong way since it looks like I'm limiting what I can access by not writing a SageTV plugin. I don't know if I want to spend time converting their API to Java, however I've seen a few Node.js adaptations for Java. Before I get too deep in that rabbit hole, does anyone have any recommendations for one they liked or reasons this would be a bad idea?
__________________
SageTV v9 Server: ASRock Z97 Extreme4, Intel i7-4790K @ 4.4Ghz, 32GB RAM, 6x 3TB 7200rpm HD, 2x 5TB 7200rpm HD, 2x 6TB 7200rpm HD, 4x 256GB SSD, 4x 500GB SSD, unRAID Pro 6.7.2 (Dual Parity + SSD Cache).
Capture: 1x Ceton InfiniTV 4 (ClearQAM), 2x Ceton InfiniTV 6, 1x BM1000-HDMI, 1x BM3500-HDMI.

Clients: 1x HD300 (Living Room), 1x HD200 (Master Bedroom).
Software: OpenDCT :: WMC Live TV Tuner :: Schedules Direct EPG
Reply With Quote
  #8  
Old 11-16-2018, 05:56 PM
EnterNoEscape's Avatar
EnterNoEscape EnterNoEscape is offline
SageTVaholic
 
Join Date: Jun 2010
Location: Harrisburg, PA
Posts: 2,505
I took a deeper look at things and I think I'm going to just port the API to Java. At it's heart, it's just a lot of REST and JSON.
__________________
SageTV v9 Server: ASRock Z97 Extreme4, Intel i7-4790K @ 4.4Ghz, 32GB RAM, 6x 3TB 7200rpm HD, 2x 5TB 7200rpm HD, 2x 6TB 7200rpm HD, 4x 256GB SSD, 4x 500GB SSD, unRAID Pro 6.7.2 (Dual Parity + SSD Cache).
Capture: 1x Ceton InfiniTV 4 (ClearQAM), 2x Ceton InfiniTV 6, 1x BM1000-HDMI, 1x BM3500-HDMI.

Clients: 1x HD300 (Living Room), 1x HD200 (Master Bedroom).
Software: OpenDCT :: WMC Live TV Tuner :: Schedules Direct EPG
Reply With Quote
  #9  
Old 11-17-2018, 04:16 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
Quote:
Originally Posted by EnterNoEscape View Post
I took a deeper look at things and I think I'm going to just port the API to Java. At it's heart, it's just a lot of REST and JSON.
You might want to take a look at this library. It's a handy library for mapping json to java apis.

https://square.github.io/retrofit/
Reply With Quote
  #10  
Old 11-17-2018, 08:52 AM
graywolf's Avatar
graywolf graywolf is offline
Sage Icon
 
Join Date: Oct 2009
Location: NC
Posts: 1,176
Been too long and fuzzy memory but didn't Slugger have a GlobalsHelper API that might have what you want?

I remember can power on/off extenders and other stuff.
Reply With Quote
  #11  
Old 11-17-2018, 05:48 PM
EnterNoEscape's Avatar
EnterNoEscape EnterNoEscape is offline
SageTVaholic
 
Join Date: Jun 2010
Location: Harrisburg, PA
Posts: 2,505
Quote:
Originally Posted by stuckless View Post
You might want to take a look at this library. It's a handy library for mapping json to java apis.

https://square.github.io/retrofit/
Interesting. It looks like it would work fairly well with how this API is structured. I'll definitely give it a try.

Quote:
Originally Posted by graywolf View Post
Been too long and fuzzy memory but didn't Slugger have a GlobalsHelper API that might have what you want?

I remember can power on/off extenders and other stuff.
I'll keep this in mind if things start to go south with the porting.
__________________
SageTV v9 Server: ASRock Z97 Extreme4, Intel i7-4790K @ 4.4Ghz, 32GB RAM, 6x 3TB 7200rpm HD, 2x 5TB 7200rpm HD, 2x 6TB 7200rpm HD, 4x 256GB SSD, 4x 500GB SSD, unRAID Pro 6.7.2 (Dual Parity + SSD Cache).
Capture: 1x Ceton InfiniTV 4 (ClearQAM), 2x Ceton InfiniTV 6, 1x BM1000-HDMI, 1x BM3500-HDMI.

Clients: 1x HD300 (Living Room), 1x HD200 (Master Bedroom).
Software: OpenDCT :: WMC Live TV Tuner :: Schedules Direct EPG
Reply With Quote
  #12  
Old 11-18-2018, 10:23 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,578
I could be wrong but doesn't something like

Configuration.GetServerProperty("sagex/uicontexts/001d6a5dbc47/ip", "")

return the IP address of that ui context?
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #13  
Old 11-18-2018, 06:23 PM
EnterNoEscape's Avatar
EnterNoEscape EnterNoEscape is offline
SageTVaholic
 
Join Date: Jun 2010
Location: Harrisburg, PA
Posts: 2,505
Quote:
Originally Posted by wayner View Post
I could be wrong but doesn't something like

Configuration.GetServerProperty("sagex/uicontexts/001d6a5dbc47/ip", "")

return the IP address of that ui context?
I haven't seen any properties like that in Sage.properties.
__________________
SageTV v9 Server: ASRock Z97 Extreme4, Intel i7-4790K @ 4.4Ghz, 32GB RAM, 6x 3TB 7200rpm HD, 2x 5TB 7200rpm HD, 2x 6TB 7200rpm HD, 4x 256GB SSD, 4x 500GB SSD, unRAID Pro 6.7.2 (Dual Parity + SSD Cache).
Capture: 1x Ceton InfiniTV 4 (ClearQAM), 2x Ceton InfiniTV 6, 1x BM1000-HDMI, 1x BM3500-HDMI.

Clients: 1x HD300 (Living Room), 1x HD200 (Master Bedroom).
Software: OpenDCT :: WMC Live TV Tuner :: Schedules Direct EPG
Reply With Quote
  #14  
Old 11-19-2018, 08:03 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,578
I will have to check my files again. Maybe I added that myself (I doubt it) or some other plugin added that.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #15  
Old 11-19-2018, 01:30 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
It's an agreed up key that plugins can use. Phoenix may populate it, as do some other plugins. the "sagex" prefix in the key, means that it's not a sagetv "core" property.
Reply With Quote
  #16  
Old 11-19-2018, 02:41 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,578
By the way, Slugger wrote both Utility Helpers and Global Helpers which help with some of these functions and to get other info regarding extenders, clients, etc. I have been campaigning to get these incorporated into the core API.

Utility Helpers has a function getIpAddrForMacAddr(String mac). This has a dependency on getArpMap which is also in Utility Helpers.

Here is the code:
Code:
/**
	 * <p>Look up the IP address for a given MAC address</p>
	 * <p>
	 *   This method will only succeed if the host is actively connected to the SageTV server.  If
	 *   the host is not connected to the SageTV server then this method will <i>likely</i> return
	 *   null, though there is a slight chance, depending on the timing, that the ARP cache may still
	 *   contain the details for the hostname and will then return the desired result.
	 * </p>
	 * @param mac The MAC address to get the IP address for; lowercase letters and numbers only
	 * @return The IP address for the given MAC or null if it cannot be determined
	 * @throws UnsupportedOperationException If called on an unsupported OS; currently only Windows and Linux are supported
	 * @since 1.0.3
	 */
	static String getIpAddrForMacAddr(String mac) throws UnsupportedOperationException {
		def data
		if(Global.IsWindowsOS())
			data = getArpMapOnWindows(false)
		else if(Global.IsLinuxOS())
			data = getArpMapOnLinux(false)
		else
			throw new UnsupportedOperationException("Unable to get ARP map on this OS! [${Global.GetOS()}]")
		return data[mac]
	}
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #17  
Old 11-21-2018, 09:29 PM
EnterNoEscape's Avatar
EnterNoEscape EnterNoEscape is offline
SageTVaholic
 
Join Date: Jun 2010
Location: Harrisburg, PA
Posts: 2,505
Quote:
Originally Posted by wayner View Post
By the way, Slugger wrote both Utility Helpers and Global Helpers which help with some of these functions and to get other info regarding extenders, clients, etc. I have been campaigning to get these incorporated into the core API.

Utility Helpers has a function getIpAddrForMacAddr(String mac). This has a dependency on getArpMap which is also in Utility Helpers.

Here is the code:
Code:
/**
	 * <p>Look up the IP address for a given MAC address</p>
	 * <p>
	 *   This method will only succeed if the host is actively connected to the SageTV server.  If
	 *   the host is not connected to the SageTV server then this method will <i>likely</i> return
	 *   null, though there is a slight chance, depending on the timing, that the ARP cache may still
	 *   contain the details for the hostname and will then return the desired result.
	 * </p>
	 * @param mac The MAC address to get the IP address for; lowercase letters and numbers only
	 * @return The IP address for the given MAC or null if it cannot be determined
	 * @throws UnsupportedOperationException If called on an unsupported OS; currently only Windows and Linux are supported
	 * @since 1.0.3
	 */
	static String getIpAddrForMacAddr(String mac) throws UnsupportedOperationException {
		def data
		if(Global.IsWindowsOS())
			data = getArpMapOnWindows(false)
		else if(Global.IsLinuxOS())
			data = getArpMapOnLinux(false)
		else
			throw new UnsupportedOperationException("Unable to get ARP map on this OS! [${Global.GetOS()}]")
		return data[mac]
	}
This approach is what I was hinting at doing as a work around, but it's really not the best way to do this since the server actually knows the IP address.

So far the API porting is going well. I'll put it up on GitHub as a library for anyone interested in using Java to work with the Neeo brain when I'm done.

It's nice to have a few days off work to tackle this.
__________________
SageTV v9 Server: ASRock Z97 Extreme4, Intel i7-4790K @ 4.4Ghz, 32GB RAM, 6x 3TB 7200rpm HD, 2x 5TB 7200rpm HD, 2x 6TB 7200rpm HD, 4x 256GB SSD, 4x 500GB SSD, unRAID Pro 6.7.2 (Dual Parity + SSD Cache).
Capture: 1x Ceton InfiniTV 4 (ClearQAM), 2x Ceton InfiniTV 6, 1x BM1000-HDMI, 1x BM3500-HDMI.

Clients: 1x HD300 (Living Room), 1x HD200 (Master Bedroom).
Software: OpenDCT :: WMC Live TV Tuner :: Schedules Direct EPG
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I find the mac address of HD-200 extender rajeevc SageTV Media Extender 3 03-07-2009 07:09 PM
IP Address is Banned skoka123 General Discussion 7 01-27-2009 10:48 AM
IP address ? steingra SageTV Software 2 11-01-2008 06:48 PM
Can't get an IP Address?? mlammens SageTV Media Extender 10 02-26-2008 08:51 AM
Wireless Media extender, No IP address. XSiVE SageTV Media Extender 7 11-22-2006 04:49 PM


All times are GMT -6. The time now is 09:30 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.