mirror of
				https://github.com/gethomepage/homepage.git
				synced 2025-11-03 19:17:03 -05:00 
			
		
		
		
	Enhancement: extend hdhomerun widget (#2757)
This commit is contained in:
		
							parent
							
								
									23e697ed4a
								
							
						
					
					
						commit
						05a7c0ff56
					
				@ -5,10 +5,14 @@ description: HDHomerun Widget Configuration
 | 
			
		||||
 | 
			
		||||
Learn more about [HDHomerun](https://www.silicondust.com/support/downloads/).
 | 
			
		||||
 | 
			
		||||
Allowed fields: `["channels", "hd"]`.
 | 
			
		||||
Allowed fields: `["channels", "hd", "tunerCount", "channelNumber", "channelNetwork", "signalStrength", "signalQuality", "symbolQuality", "networkRate", "clientIP" ]`.
 | 
			
		||||
 | 
			
		||||
If more than 4 fields are provided, only the first 4 are displayed.
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
widget:
 | 
			
		||||
  type: hdhomerun
 | 
			
		||||
  url: http://hdhomerun.host.or.ip
 | 
			
		||||
  tuner: 0 # optional - defaults to 0, used for tuner-specific fields
 | 
			
		||||
  fields: ["channels", "hd"] # optional - default fields shown
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@ -535,7 +535,15 @@
 | 
			
		||||
    },
 | 
			
		||||
    "hdhomerun": {
 | 
			
		||||
        "channels": "Channels",
 | 
			
		||||
        "hd": "HD"
 | 
			
		||||
        "hd": "HD",
 | 
			
		||||
        "tunerCount": "Tuners",
 | 
			
		||||
        "channelNumber": "Channel",
 | 
			
		||||
        "channelNetwork": "Network",
 | 
			
		||||
        "signalStrength": "Strength",
 | 
			
		||||
        "signalQuality": "Quality",
 | 
			
		||||
        "symbolQuality": "Quality",
 | 
			
		||||
        "networkRate": "Bitrate",
 | 
			
		||||
        "clientIP": "Client"
 | 
			
		||||
    },
 | 
			
		||||
    "scrutiny": {
 | 
			
		||||
        "passed": "Passed",
 | 
			
		||||
 | 
			
		||||
@ -398,6 +398,9 @@ export function cleanServiceGroups(groups) {
 | 
			
		||||
          // glances, customapi, iframe
 | 
			
		||||
          refreshInterval,
 | 
			
		||||
 | 
			
		||||
          // hdhomerun
 | 
			
		||||
          tuner,
 | 
			
		||||
 | 
			
		||||
          // healthchecks
 | 
			
		||||
          uuid,
 | 
			
		||||
 | 
			
		||||
@ -541,6 +544,9 @@ export function cleanServiceGroups(groups) {
 | 
			
		||||
          if (showTime) cleanedService.widget.showTime = showTime;
 | 
			
		||||
          if (timezone) cleanedService.widget.timezone = timezone;
 | 
			
		||||
        }
 | 
			
		||||
        if (type === "hdhomerun") {
 | 
			
		||||
          if (tuner !== undefined) cleanedService.widget.tuner = tuner;
 | 
			
		||||
        }
 | 
			
		||||
        if (type === "healthchecks") {
 | 
			
		||||
          if (uuid !== undefined) cleanedService.widget.uuid = uuid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -4,14 +4,17 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
 | 
			
		||||
 | 
			
		||||
export default function Component({ service }) {
 | 
			
		||||
  const { widget } = service;
 | 
			
		||||
  const { tuner = 0 } = widget;
 | 
			
		||||
 | 
			
		||||
  const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "lineup");
 | 
			
		||||
  const { data: statusData, error: statusError } = useWidgetAPI(widget, "status");
 | 
			
		||||
 | 
			
		||||
  if (channelsError) {
 | 
			
		||||
    return <Container service={service} error={channelsError} />;
 | 
			
		||||
  if (channelsError || statusError) {
 | 
			
		||||
    const finalError = channelsError ?? statusError;
 | 
			
		||||
    return <Container service={service} error={finalError} />;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!channelsData) {
 | 
			
		||||
  if (!channelsData || !statusData) {
 | 
			
		||||
    return (
 | 
			
		||||
      <Container service={service}>
 | 
			
		||||
        <Block label="hdhomerun.channels" />
 | 
			
		||||
@ -20,12 +23,30 @@ export default function Component({ service }) {
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const hdChannels = channelsData?.filter((channel) => channel.HD === 1);
 | 
			
		||||
  // Provide a default if not set in the config
 | 
			
		||||
  if (!widget.fields) {
 | 
			
		||||
    widget.fields = ["channels", "hd"];
 | 
			
		||||
  }
 | 
			
		||||
  // Limit to a maximum of 4 at a time
 | 
			
		||||
  if (widget.fields.length > 4) {
 | 
			
		||||
    widget.fields = widget.fields.slice(0, 4);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <Container service={service}>
 | 
			
		||||
      <Block label="hdhomerun.channels" value={channelsData.length} />
 | 
			
		||||
      <Block label="hdhomerun.hd" value={hdChannels.length} />
 | 
			
		||||
      <Block label="hdhomerun.channels" value={channelsData?.length} />
 | 
			
		||||
      <Block label="hdhomerun.hd" value={channelsData?.filter((channel) => channel.HD === 1)?.length} />
 | 
			
		||||
      <Block
 | 
			
		||||
        label="hdhomerun.tunerCount"
 | 
			
		||||
        value={`${statusData?.filter((num) => num.VctNumber != null).length ?? 0} / ${statusData?.length ?? 0}`}
 | 
			
		||||
      />
 | 
			
		||||
      <Block label="hdhomerun.channelNumber" value={statusData[tuner]?.VctNumber ?? null} />
 | 
			
		||||
      <Block label="hdhomerun.channelNetwork" value={statusData[tuner]?.VctName ?? null} />
 | 
			
		||||
      <Block label="hdhomerun.signalStrength" value={statusData[tuner]?.SignalStrengthPercent ?? null} />
 | 
			
		||||
      <Block label="hdhomerun.signalQuality" value={statusData[tuner]?.SignalQualityPercent ?? null} />
 | 
			
		||||
      <Block label="hdhomerun.symbolQuality" value={statusData[tuner]?.SymbolQualityPercent ?? null} />
 | 
			
		||||
      <Block label="hdhomerun.clientIP" value={statusData[tuner]?.TargetIP ?? null} />
 | 
			
		||||
      <Block label="hdhomerun.networkRate" value={statusData[tuner]?.NetworkRate ?? null} />
 | 
			
		||||
    </Container>
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,9 @@ const widget = {
 | 
			
		||||
    lineup: {
 | 
			
		||||
      endpoint: "lineup.json",
 | 
			
		||||
    },
 | 
			
		||||
    status: {
 | 
			
		||||
      endpoint: "status.json",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user