From e87a211295c5b10260ecb1f5ddc63d76359105f2 Mon Sep 17 00:00:00 2001 From: Yellowcooln <12516003+yellowcooln@users.noreply.github.com> Date: Wed, 20 May 2026 11:23:38 -0400 Subject: [PATCH] Add broker presets support for 1.1.3 --- CHANGELOG.md | 5 +++++ custom_components/pymc_repeater/__init__.py | 17 +++++++++++++++++ custom_components/pymc_repeater/api.py | 8 ++++++++ custom_components/pymc_repeater/manifest.json | 2 +- custom_components/pymc_repeater/services.yaml | 9 +++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eff77b..4c5c08a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.1.3 + +- added a Home Assistant action for the new repeater `broker_presets` API endpoint so bundled MC2MQTT broker templates can be queried from HA +- reviewed repeater API changes from `e03174d` to `22adbd1`; the other changes in that range were setup-wizard behavior and update messaging rather than new ongoing telemetry/control surface + ## 1.1.2 - fixed the `Packets received per hour` and `Packets forwarded per hour` sensors to use `/api/packet_stats?hours=1` instead of the repeater status counters backed by the capped `recent_packets` buffer diff --git a/custom_components/pymc_repeater/__init__.py b/custom_components/pymc_repeater/__init__.py index a4fc48f..d4c2514 100644 --- a/custom_components/pymc_repeater/__init__.py +++ b/custom_components/pymc_repeater/__init__.py @@ -46,6 +46,7 @@ SERVICE_COMPANION_SET_ADVERT_NAME = "companion_set_advert_name" SERVICE_COMPANION_SET_ADVERT_LOCATION = "companion_set_advert_location" SERVICE_GET_LOGS = "get_logs" +SERVICE_GET_BROKER_PRESETS = "get_broker_presets" SERVICE_GET_RECENT_PACKETS = "get_recent_packets" SERVICE_GET_FILTERED_PACKETS = "get_filtered_packets" SERVICE_GET_PACKET_BY_HASH = "get_packet_by_hash" @@ -533,6 +534,22 @@ async def _with_api_response( ), ) + hass.services.async_register( + DOMAIN, + SERVICE_GET_BROKER_PRESETS, + lambda call: _with_api_response( + call, + lambda api, _: api.async_get_broker_presets(), + always_return=True, + ), + schema=vol.Schema( + { + vol.Optional(CONF_ENTRY_ID): str, + } + ), + supports_response=SupportsResponse.ONLY, + ) + hass.services.async_register( DOMAIN, SERVICE_GET_LOGS, diff --git a/custom_components/pymc_repeater/api.py b/custom_components/pymc_repeater/api.py index 68a2b51..461acdf 100644 --- a/custom_components/pymc_repeater/api.py +++ b/custom_components/pymc_repeater/api.py @@ -260,6 +260,14 @@ async def async_open_gps_stream(self) -> ClientResponse: """Open the GPS SSE stream.""" return await self._async_open_stream("GET", "/api/gps_stream") + async def async_get_broker_presets(self) -> dict[str, Any]: + """Return bundled MC2MQTT broker presets.""" + presets = await self._async_request_wrapped("GET", "/api/broker_presets") + return { + "presets": presets, + "count": len(presets) if isinstance(presets, list) else 0, + } + async def async_get_logs(self) -> dict[str, Any]: """Return buffered repeater logs.""" payload = await self._async_request_json("GET", "/api/logs", auth="api_token") diff --git a/custom_components/pymc_repeater/manifest.json b/custom_components/pymc_repeater/manifest.json index 558a9a5..fc73ad1 100644 --- a/custom_components/pymc_repeater/manifest.json +++ b/custom_components/pymc_repeater/manifest.json @@ -10,5 +10,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/pyMC-dev/pyMC-HA-Integration/issues", "requirements": [], - "version": "1.1.2" + "version": "1.1.3" } diff --git a/custom_components/pymc_repeater/services.yaml b/custom_components/pymc_repeater/services.yaml index 903f0c9..0c2fa08 100644 --- a/custom_components/pymc_repeater/services.yaml +++ b/custom_components/pymc_repeater/services.yaml @@ -370,6 +370,15 @@ companion_set_advert_location: selector: text: +get_broker_presets: + name: Get broker presets + description: Return bundled MC2MQTT broker presets exposed by the repeater API. + fields: + config_entry_id: + selector: + config_entry: + integration: pymc_repeater + get_logs: name: Get logs description: Return the current pyMC repeater log buffer.