Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions custom_components/pymc_repeater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions custom_components/pymc_repeater/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pymc_repeater/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
9 changes: 9 additions & 0 deletions custom_components/pymc_repeater/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down