discussion #772: Extend the hdhomerun widget
- maintain the previous behavior if no additional configuration is done - define additional available fields and present the data in order configured - global: "tunerCount" - per-tuner: "channelNumber", "channelNetwork", "signalStrength", "signalQuality", "symbolQuality", "networkRate", "clientIP" - add handling for refreshInterval - update docs
This commit is contained in:
parent
a6e4786fc4
commit
ebb0656127
@ -3,12 +3,18 @@ title: HDHomerun
|
|||||||
description: HDHomerun Widget Configuration
|
description: HDHomerun Widget Configuration
|
||||||
---
|
---
|
||||||
|
|
||||||
Learn more about [HDHomerun](https://www.silicondust.com/support/downloads/).
|
[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. The
|
||||||
|
order that fields are configured is preserved for display.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
tuner: 0 # optional - defaults to 0, used for tuner-specific fields
|
||||||
widget:
|
widget:
|
||||||
type: hdhomerun
|
type: hdhomerun
|
||||||
url: http://hdhomerun.host.or.ip
|
url: http://hdhomerun.host.or.ip
|
||||||
|
refreshInterval: 10000 # optional - minimum of 1 sec, default of 10s
|
||||||
|
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",
|
||||||
|
|||||||
@ -2,16 +2,68 @@ import Container from "components/services/widget/container";
|
|||||||
import Block from "components/services/widget/block";
|
import Block from "components/services/widget/block";
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
function generateDefinitions(channelsData, statusData, tuner) {
|
||||||
|
return {
|
||||||
|
channels: {
|
||||||
|
label: "hdhomerun.channels",
|
||||||
|
value: channelsData?.length,
|
||||||
|
},
|
||||||
|
hd: {
|
||||||
|
label: "hdhomerun.hd",
|
||||||
|
value: channelsData?.filter((channel) => channel.HD === 1)?.length,
|
||||||
|
},
|
||||||
|
tunerCount: {
|
||||||
|
label: "hdhomerun.tunerCount",
|
||||||
|
value: `${statusData?.filter((num) => num.VctNumber != null).length ?? 0} / ${statusData?.length ?? 0}`,
|
||||||
|
},
|
||||||
|
channelNumber: {
|
||||||
|
label: "hdhomerun.channelNumber",
|
||||||
|
value: statusData[tuner]?.VctNumber ?? null,
|
||||||
|
},
|
||||||
|
channelNetwork: {
|
||||||
|
label: "hdhomerun.channelNetwork",
|
||||||
|
value: statusData[tuner]?.VctName ?? null,
|
||||||
|
},
|
||||||
|
signalStrength: {
|
||||||
|
label: "hdhomerun.signalStrength",
|
||||||
|
value: statusData[tuner]?.SignalStrengthPercent ?? null,
|
||||||
|
},
|
||||||
|
signalQuality: {
|
||||||
|
label: "hdhomerun.signalQuality",
|
||||||
|
value: statusData[tuner]?.SignalQualityPercent ?? null,
|
||||||
|
},
|
||||||
|
symbolQuality: {
|
||||||
|
label: "hdhomerun.symbolQuality",
|
||||||
|
value: statusData[tuner]?.SymbolQualityPercent ?? null,
|
||||||
|
},
|
||||||
|
clientIP: {
|
||||||
|
label: "hdhomerun.clientIP",
|
||||||
|
value: statusData[tuner]?.TargetIP ?? null,
|
||||||
|
},
|
||||||
|
networkRate: {
|
||||||
|
label: "hdhomerun.networkRate",
|
||||||
|
value: statusData[tuner]?.NetworkRate ?? null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget, tuner = 0 } = service;
|
||||||
|
const { refreshInterval = 10000, fields = ["channels", "hd"] } = widget;
|
||||||
|
|
||||||
const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "lineup");
|
const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "lineup", {
|
||||||
|
refreshInterval: Math.max(1000, refreshInterval),
|
||||||
|
});
|
||||||
|
const { data: statusData, error: statusError } = useWidgetAPI(widget, "status", {
|
||||||
|
refreshInterval: Math.max(1000, refreshInterval),
|
||||||
|
});
|
||||||
|
|
||||||
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 +72,17 @@ export default function Component({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hdChannels = channelsData?.filter((channel) => channel.HD === 1);
|
const definitions = generateDefinitions(channelsData, statusData, tuner);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="hdhomerun.channels" value={channelsData.length} />
|
{fields.slice(0, 4).map((field) => (
|
||||||
<Block label="hdhomerun.hd" value={hdChannels.length} />
|
<Block
|
||||||
|
key={field}
|
||||||
|
label={definitions[Object.keys(definitions).filter((id) => id === field)].label}
|
||||||
|
value={definitions[Object.keys(definitions).filter((id) => id === field)].value}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,9 @@ const widget = {
|
|||||||
lineup: {
|
lineup: {
|
||||||
endpoint: "lineup.json",
|
endpoint: "lineup.json",
|
||||||
},
|
},
|
||||||
|
status: {
|
||||||
|
endpoint: "status.json",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user