hass-gardena-smart-system
Home Assistant custom component integration for Gardena Smart System
git clone https://github.com/py-smart-gardena/hass-gardena-smart-system.gitpy-smart-gardena/hass-gardena-smart-systemGardena 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.
🔗 Useful Links
more like this
PowerDisplayESPHome
A small display for ESPHome and Home Assistant to retrieve the current house consumption and energy price via a sensor…
