Skip to content

Add Gardena mower protocol features#148

Open
AlirezaT wants to merge 2 commits into
alistair23:mainfrom
AlirezaT:upstream-library-changes
Open

Add Gardena mower protocol features#148
AlirezaT wants to merge 2 commits into
alistair23:mainfrom
AlirezaT:upstream-library-changes

Conversation

@AlirezaT

Copy link
Copy Markdown

This ports the generic Automower/Gardena BLE protocol work from the Home Assistant Gardena BLE integration back into the Python library.

Included:

  • safer command response helpers that expose mower response results
  • serialized locked command flow for multi-step commands
  • keep-alive task cleanup on disconnect
  • schedule transaction helpers for reading, replacing, and clearing weekly tasks
  • Gardena-compatible SpotCut flow: prepare SpotCut, start timed override, then trigger start
  • additional protocol definitions for battery diagnostics, SensorControl/frost sensor, drive-past-wire, starting points, reversing distance, SpotCut, realtime sensor data, signal quality, firmware/hardware identity, and production info
  • parser support for signed 16-bit values and variable trailing integer fields, so GetTask works with both existing upstream fixtures and Gardena responses

Notes:

  • The new commands were tested from the Home Assistant integration against a Gardena Sileno mower and cross-checked with Gardena app BLE/HCI observations where available.
  • Some commands are model-dependent and may return NOT_AVAILABLE, INVALID_ID, or NOT_ALLOWED on mowers that do not expose that feature.

Validation:

  • python -m unittest discover
  • python -m compileall automower_ble tests
  • git diff --check

Comment thread automower_ble/mower.py
"""Send a command while the caller already holds the BLE command lock."""
command = Command(self.channel_id, (await self.get_protocol())[command_name])
request = command.generate_request(**kwargs)
response = await self._request_response_locked(request)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a lock here?

@alistair23

alistair23 commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Sorry about the long delay!

Overall this looks good. It does need a rebase and the ruff CI tests need to pass.

It would be great (although not required) if you could split the PR up into some smaller independent PRs. That way if something breaks it's easy to figure out exactly what change causes the breakage.

I'm also not clear on why we need

safer command response helpers that expose mower response results
serialized locked command flow for multi-step commands

Can you provide a few more details?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants