Gardena Smart System Integration v2
A complete reimplementation of the Home Assistant integration for the Gardena Smart System, based on Gardena's v2 API.
If this integration keeps your garden happy, consider buying me a coffee to keep the developer happy too!
π‘ Compatibility
This integration only works with WiFi-enabled Gardena Smart System devices that connect through a Gardena Smart Gateway. It communicates with the Gardena cloud API, which requires the gateway as a bridge.
Not compatible with:
- Bluetooth-only Gardena devices (e.g. older mowers, Gardena Bluetooth sensors)
- Devices that connect directly via Bluetooth to a phone without a gateway
If your device does not require a Gardena Smart Gateway for operation, it is not supported by this integration.
β οΈ Important: Complete Reimplementation
This is a complete rewrite of the Gardena Smart System integration. It is strongly recommended to:
- Remove the existing integration from Home Assistant
- Restart Home Assistant
- Re-add the integration with this new version
This ensures a clean installation and prevents any conflicts between the old and new implementations.
Why a Complete Reimplementation?
- New API v2: Uses Gardena's completely new API architecture
- Modern Framework: Built using the latest Home Assistant integration patterns
- Improved Architecture: Better state management and error handling
- Enhanced Features: More reliable device detection and control
π v2 New Features
- Modern Architecture : Uses Home Assistant recommended patterns
- Standardized Framework : Based on the official integration framework
- Python 3.11+ : Support for recent Python versions
- API v2 : Uses the new Gardena Smart System API
- Centralized State Management : Coordinator for data synchronization
- Automated Tests : Unit tests with mocks
π§ͺ Testing Status
β Tested and Working
- Lawn Mower (
lawn_mower) : β Fully tested and functional- Start/pause/dock controls working
- Real-time status updates via WebSocket
- Custom service buttons operational
- Smart Irrigation Control (
valve) : β Fully tested and functional- Multiple valve control (6 valves detected)
- Open/close operations working
- Real-time status updates
- Power Socket (
switch) : β Fully tested and functional- On/off control working
- Real-time status updates
- Smart Water Control (
valve) : β Tested and functional- Single valve control working (confirmed on Gardena 19031-20)
- Open/close operations and real-time status updates
β οΈ Not Yet Tested
- Sensors (
sensor) : β οΈ Implementation complete but not tested- Temperature, humidity, light sensors
- Soil sensors implementation ready
- Needs real device testing
π Features
Supported Entities
- Lawn Mowers (
lawn_mower) : Control of automatic lawn mowers - Sensors (
sensor) : Temperature, humidity sensors, etc. - Binary Sensors (
binary_sensor) : Online/offline status - Switches (
switch) : Smart power sockets - Valves (
valve) : Irrigation valves
Lawn Mower Features
- Start mowing
- Pause
- Return to charging station
- State and activity monitoring
Mower error sensor
The mower_error sensor exposes the last_error_code field from the Gardena API. To avoid false positives in error-notification automations, informational operational states are filtered and reported as no_message instead:
| Code filtered | Meaning |
|---|---|
parked_daily_limit_reached |
Daily mowing limit reached β normal operation |
outside_working_area |
Mower returned outside its zone β normal |
off_disabled |
Disabled manually by user |
off_hatch_open |
Hatch opened for maintenance |
off_hatch_closed |
Hatch closed β normal state |
wait_updating |
Firmware update in progress |
wait_power_up |
Booting up |
wait_stop_pressed |
Stop button held β user maintenance |
wait_for_safety_pin |
Waiting for safety pin β user maintenance |
guide_calibration_accomplished |
Calibration completed successfully |
connection_changed |
Network state change β informational |
connection_not_changed |
Network state change β informational |
uninitialised |
Normal boot state |
This means a simple automation like state != 'no_message' reliably catches only real errors that require attention.
π§ Available Services
The integration provides several services that can be called from automations, scripts, or the Developer Tools. All services require a device_id parameter.
π Lawn Mower Services
gardena_smart_system.mower_start
Start automatic mowing (follows the device's schedule).
Parameters:
device_id(required): The device ID of the lawn mower
Example:
service: gardena_smart_system.mower_start
data:
device_id: "your_mower_device_id"
gardena_smart_system.mower_start_manual
Start manual mowing for a specified duration.
Parameters:
device_id(required): The device ID of the lawn mowerduration(optional): Duration in seconds (60-14400, default: 1800)
Example:
service: gardena_smart_system.mower_start_manual
data:
device_id: "your_mower_device_id"
duration: 3600 # 1 hour
gardena_smart_system.mower_park
Park the mower until the next scheduled task.
Parameters:
device_id(required): The device ID of the lawn mower
Example:
service: gardena_smart_system.mower_park
data:
device_id: "your_mower_device_id"
gardena_smart_system.mower_park_until_notice
Park the mower until further notice (ignores schedule).
Parameters:
device_id(required): The device ID of the lawn mower
Example:
service: gardena_smart_system.mower_park_until_notice
data:
device_id: "your_mower_device_id"
π Power Socket Services
gardena_smart_system.power_socket_on
Turn on the power socket for a specified duration.
Parameters:
device_id(required): The device ID of the power socketduration(optional): Duration in seconds (60-86400, default: 3600)
Example:
service: gardena_smart_system.power_socket_on
data:
device_id: "your_power_socket_device_id"
duration: 7200 # 2 hours
gardena_smart_system.power_socket_on_indefinite
Turn on the power socket indefinitely.
Parameters:
device_id(required): The device ID of the power socket
Example:
service: gardena_smart_system.power_socket_on_indefinite
data:
device_id: "your_power_socket_device_id"
gardena_smart_system.power_socket_off
Turn off the power socket immediately.
Parameters:
device_id(required): The device ID of the power socket
Example:
service: gardena_smart_system.power_socket_off
data:
device_id: "your_power_socket_device_id"
gardena_smart_system.power_socket_pause
Pause automatic operation of the power socket.
Parameters:
device_id(required): The device ID of the power socket
Example:
service: gardena_smart_system.power_socket_pause
data:
device_id: "your_power_socket_device_id"
gardena_smart_system.power_socket_unpause
Resume automatic operation of the power socket.
Parameters:
device_id(required): The device ID of the power socket
Example:
service: gardena_smart_system.power_socket_unpause
data:
device_id: "your_power_socket_device_id"
π° Valve Services
gardena_smart_system.valve_open
Open the valve for a specified duration.
Parameters:
device_id(required): The device ID of the valveduration(optional): Duration in seconds (60-14400, default: 3600)
Example:
service: gardena_smart_system.valve_open
data:
device_id: "your_valve_device_id"
duration: 1800 # 30 minutes
gardena_smart_system.valve_close
Close the valve immediately.
Parameters:
device_id(required): The device ID of the valve
Example:
service: gardena_smart_system.valve_close
data:
device_id: "your_valve_device_id"
gardena_smart_system.valve_pause
Pause automatic operation of the valve.
Parameters:
device_id(required): The device ID of the valve
Example:
service: gardena_smart_system.valve_pause
data:
device_id: "your_valve_device_id"
gardena_smart_system.valve_unpause
Resume automatic operation of the valve.
Parameters:
device_id(required): The device ID of the valve
Example:
service: gardena_smart_system.valve_unpause
data:
device_id: "your_valve_device_id"
π WebSocket Services
gardena_smart_system.reconnect_websocket
Force reconnection of the WebSocket connection.
Parameters: None
Example:
service: gardena_smart_system.reconnect_websocket
π System Services
gardena_smart_system.reload
Reload the Gardena Smart System integration.
Parameters: None
Example:
service: gardena_smart_system.reload
gardena_smart_system.websocket_diagnostics
Get WebSocket connection diagnostics and status information.
Parameters:
detailed(optional): Include detailed connection information (default: false)
Example:
service: gardena_smart_system.websocket_diagnostics
data:
detailed: true
π Finding Device IDs
To find the device ID for a specific device:
- Go to Developer Tools > States
- Search for your device (e.g., "mower", "valve", "switch")
- Look for the
device_idattribute in the entity state - Or check the entity's unique ID (usually contains the device ID)
Example entity state:
device_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
π οΈ Installation
β οΈ Important: Clean Installation Required
Before installing this new version, you must remove the existing Gardena Smart System integration:
- Go to Configuration > Integrations
- Find Gardena Smart System in the list
- Click on it and select Delete
- Confirm the deletion
- Restart Home Assistant
Manual Installation
- Copy the
custom_components/gardena_smart_systemfolder to yourconfig/custom_components/folder - Restart Home Assistant
- Go to Configuration > Integrations
- Click + Add Integration
- Search for Gardena Smart System
- Enter your API credentials
Configuration
You will need:
- Client ID : Your Gardena application key
- Client Secret : Your Gardena application secret
These credentials can be obtained through the Gardena Developer Portal.
π§ Technical Architecture
File Structure
custom_components/gardena_smart_system/
βββ __init__.py # Main entry point
βββ config_flow.py # UI configuration flow
βββ const.py # Integration constants
βββ coordinator.py # Data coordinator
βββ gardena_client.py # Gardena API client
βββ lawn_mower.py # Lawn mower entities
βββ sensor.py # Sensor entities
βββ binary_sensor.py # Binary sensor entities
βββ switch.py # Switch entities
βββ valve.py # Valve entities
βββ manifest.json # Integration metadata
βββ strings.json # Translation strings
βββ services.yaml # Custom services
βββ translations/ # Translations
Main Components
Coordinator (coordinator.py)
- Manages data synchronization with the API
- Automatically updates entities
- Handles errors and reconnection
API Client (gardena_client.py)
- Communication with Gardena v2 API
- OAuth2 authentication
- HTTP request management
Entities
- Each device type has its own entity
- Uses modern Home Assistant patterns
- Supports specific features
π§ͺ Tests
Running Tests
# Install test dependencies
pip install pytest pytest-asyncio
# Run tests
pytest custom_components/gardena_smart_system/test_init.py -v
Available Tests
- Configuration : Configuration flow test
- Authentication : Invalid credentials test
- Installation : Integration installation test
- Uninstallation : Integration uninstallation test
π Migration from Previous Versions
β οΈ Migration Required
This is a complete reimplementation and requires a full migration:
- Remove the existing integration from Home Assistant
- Restart Home Assistant
- Install this new version
- Re-add the integration with your API credentials
What Changes?
- New entity IDs: All entities will have new unique IDs
- New device structure: Devices are now organized differently
- Enhanced features: Better device detection and control
- Improved reliability: More stable connection and state management
Migration Checklist
- [ ] Remove existing Gardena Smart System integration
- [ ] Restart Home Assistant
- [ ] Install new integration files
- [ ] Re-add integration with API credentials
- [ ] Verify all devices are detected
- [ ] Update any automations or scripts that reference old entity IDs
π Troubleshooting
Common Issues
Authentication Error
- Check your API credentials
- Make sure your account has access to the v2 API
No Devices Detected
- Check that your devices are connected to the Smart System
- Make sure they are visible in the Gardena app
- Ensure you've removed the old integration first
Entities Not Available
- Check internet connection
- Check Home Assistant logs for more details
- Verify you've restarted Home Assistant after removing the old integration
Duplicate Entities or Conflicts
- This usually happens when the old integration wasn't properly removed
- Remove the integration completely and restart Home Assistant
- Re-add the integration fresh
Logs
Enable detailed logs in configuration.yaml:
logger:
default: info
logs:
custom_components.gardena_smart_system: debug
π€ Contribution
Contributions are welcome! To contribute:
- Fork the project
- Create a branch for your feature
- Add tests for your code
- Submit a pull request
π License
This project is under MIT license. See the LICENSE file for more details.
π Changelog
See CHANGELOG.md for a full list of changes, fixes, and breaking changes per version.
