Skip to content

Add Gardena mower protocol features#148

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

Add Gardena mower protocol features#148
AlirezaT wants to merge 5 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
@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?

@AlirezaT
AlirezaT force-pushed the upstream-library-changes branch from c46ba8f to 9eca09c Compare June 18, 2026 19:58
@AlirezaT

Copy link
Copy Markdown
Author

Thanks! I rebased the branch on current main and fixed the ruff issues.

Locally I now have:

  • python -m ruff check .: passing
  • python -m ruff format --check .: passing
  • python -m pytest: 24 passed

About the command response helpers: these are mainly to let callers distinguish protocol-level mower response results such as OK, NOT_AVAILABLE, NOT_ALLOWED, OUT_OF_RANGE, DEVICE_BUSY, etc. The existing command helper is convenient when a command succeeds, but integrations also need to know when a mower model explicitly does not support a command or temporarily rejects it. That allows unsupported features to be disabled or skipped cleanly instead of repeatedly polling them and only seeing None/log noise.

About the locked command flow: the mower replies through one shared BLE notification queue. If two commands are allowed to overlap, one caller can consume the response intended for another command. The lock keeps command/request/response ordering serialized.

The locked helper is for higher-level multi-step flows that already hold the command lock and need to send several commands without another command interleaving between them. This is useful for transaction-style operations such as schedule updates, where the sequence needs to remain ordered.

@alistair23

Copy link
Copy Markdown
Owner

Still a ruff format issue

@AlirezaT
AlirezaT force-pushed the upstream-library-changes branch from 0695cf8 to a9d2baf Compare July 7, 2026 12:01
@AlirezaT

AlirezaT commented Jul 7, 2026

Copy link
Copy Markdown
Author

Thanks for pointing this out. I rebased the PR branch on the current upstream main and resolved the conflict in automower_ble/protocol.py by keeping the newer upstream disconnect behavior.

Current status from GitHub is now:

  • mergeable: MERGEABLE
  • reviewDecision: APPROVED
  • the remaining workflow runs are action_required, so they just need maintainer approval to run again

I also reran the checks locally after the rebase:

  • ruff 0.12.4 format --check --no-cache .: passed
  • ruff 0.12.4 check --no-cache .: passed
  • python -m mypy .: passed
  • python -m pytest: 24 passed

Could you please trigger/approve the workflows again when you have a moment?

@gruijter

Copy link
Copy Markdown

@alistair23 hope this is merged soon so I can finalize my Homey app this weekend 🙏.

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.

3 participants