From 05a7c0ff567cf28c19dd010f4a08317d6bfa130e Mon Sep 17 00:00:00 2001 From: JeffRandall Date: Fri, 26 Jan 2024 12:57:08 -0600 Subject: [PATCH] Enhancement: extend hdhomerun widget (#2757) --- docs/widgets/services/hdhomerun.md | 6 +++++- public/locales/en/common.json | 10 ++++++++- src/utils/config/service-helpers.js | 6 ++++++ src/widgets/hdhomerun/component.jsx | 33 +++++++++++++++++++++++------ src/widgets/hdhomerun/widget.js | 3 +++ 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/docs/widgets/services/hdhomerun.md b/docs/widgets/services/hdhomerun.md index a7351156c..261ab046e 100644 --- a/docs/widgets/services/hdhomerun.md +++ b/docs/widgets/services/hdhomerun.md @@ -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 ``` diff --git a/public/locales/en/common.json b/public/locales/en/common.json index b0f60a6d4..716f9270e 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -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", diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 84be1666d..8d56e2a53 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -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; } diff --git a/src/widgets/hdhomerun/component.jsx b/src/widgets/hdhomerun/component.jsx index 2b2cb24a4..a118eafed 100644 --- a/src/widgets/hdhomerun/component.jsx +++ b/src/widgets/hdhomerun/component.jsx @@ -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 ; + if (channelsError || statusError) { + const finalError = channelsError ?? statusError; + return ; } - if (!channelsData) { + if (!channelsData || !statusData) { return ( @@ -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 ( - - + + channel.HD === 1)?.length} /> + num.VctNumber != null).length ?? 0} / ${statusData?.length ?? 0}`} + /> + + + + + + + ); } diff --git a/src/widgets/hdhomerun/widget.js b/src/widgets/hdhomerun/widget.js index 689fbf0bc..e708b4d4d 100644 --- a/src/widgets/hdhomerun/widget.js +++ b/src/widgets/hdhomerun/widget.js @@ -8,6 +8,9 @@ const widget = { lineup: { endpoint: "lineup.json", }, + status: { + endpoint: "status.json", + }, }, };