Enhancement: extend hdhomerun widget (#2757)

pull/2772/head v0.8.7
JeffRandall 4 months ago committed by GitHub
parent 23e697ed4a
commit 05a7c0ff56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,10 +5,14 @@ description: HDHomerun Widget Configuration
Learn more about [HDHomerun](https://www.silicondust.com/support/downloads/). 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 ```yaml
widget: widget:
type: hdhomerun type: hdhomerun
url: http://hdhomerun.host.or.ip 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": { "hdhomerun": {
"channels": "Channels", "channels": "Channels",
"hd": "HD" "hd": "HD",
"tunerCount": "Tuners",
"channelNumber": "Channel",
"channelNetwork": "Network",
"signalStrength": "Strength",
"signalQuality": "Quality",
"symbolQuality": "Quality",
"networkRate": "Bitrate",
"clientIP": "Client"
}, },
"scrutiny": { "scrutiny": {
"passed": "Passed", "passed": "Passed",

@ -398,6 +398,9 @@ export function cleanServiceGroups(groups) {
// glances, customapi, iframe // glances, customapi, iframe
refreshInterval, refreshInterval,
// hdhomerun
tuner,
// healthchecks // healthchecks
uuid, uuid,
@ -541,6 +544,9 @@ export function cleanServiceGroups(groups) {
if (showTime) cleanedService.widget.showTime = showTime; if (showTime) cleanedService.widget.showTime = showTime;
if (timezone) cleanedService.widget.timezone = timezone; if (timezone) cleanedService.widget.timezone = timezone;
} }
if (type === "hdhomerun") {
if (tuner !== undefined) cleanedService.widget.tuner = tuner;
}
if (type === "healthchecks") { if (type === "healthchecks") {
if (uuid !== undefined) cleanedService.widget.uuid = uuid; if (uuid !== undefined) cleanedService.widget.uuid = uuid;
} }

@ -4,14 +4,17 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) { export default function Component({ service }) {
const { widget } = service; const { widget } = service;
const { tuner = 0 } = widget;
const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "lineup"); const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "lineup");
const { data: statusData, error: statusError } = useWidgetAPI(widget, "status");
if (channelsError) { if (channelsError || statusError) {
return <Container service={service} error={channelsError} />; const finalError = channelsError ?? statusError;
return <Container service={service} error={finalError} />;
} }
if (!channelsData) { if (!channelsData || !statusData) {
return ( return (
<Container service={service}> <Container service={service}>
<Block label="hdhomerun.channels" /> <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 ( return (
<Container service={service}> <Container service={service}>
<Block label="hdhomerun.channels" value={channelsData.length} /> <Block label="hdhomerun.channels" value={channelsData?.length} />
<Block label="hdhomerun.hd" value={hdChannels.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> </Container>
); );
} }

@ -8,6 +8,9 @@ const widget = {
lineup: { lineup: {
endpoint: "lineup.json", endpoint: "lineup.json",
}, },
status: {
endpoint: "status.json",
},
}, },
}; };

Loading…
Cancel
Save