Step 1: Create the Husqvarna API application
- Sign in to the Husqvarna Developer Portal with the same account you use in the Automower Connect app, and authorise the portal when asked.
- Go to "My applications" and create a new application. Name it anything (for example "My Home Assistant"). For the redirect URL use https://my.home-assistant.io/redirect/oauth, with no extra spaces on the end. If you have My Home Assistant disabled, the HA docs say to use your Home Assistant URL followed by /auth/external/callback, exactly as used during setup.
- Click Create. You get an Application Key and Application Secret. The HA docs say to protect them like a username and password.
- Connect two APIs to the application: the Authentication API and the Automower Connect API. Leave the tab open.
Go to Settings > Devices & services > Add integration > Husqvarna Automower. Enter a name for the credentials, paste the Application Key as the OAuth Client ID and the Application Secret as the OAuth Client Secret, then follow the prompts to log in with your Husqvarna account. If you get a credentials error, delete the credentials on the Application credentials page and try again.
You should get a lawn_mower entity, battery and status sensors, a calendar, and (depending on the model) buttons such as Confirm Error, Sync clock and Reset cutting blade usage time, and switches for stay-out zones and work areas. The HA docs mention a Sync clock button, which is handy after daylight saving changes.
Step 3: Notify when mowing is finished
The Lawn mower docs include this example (adapt the entity IDs, which will probably be lawn_mower.your_mower_name):
Code: Select all
alias: "Notify when the mower is done"
triggers:
- trigger: lawn_mower.returned_to_dock
target:
entity_id: lawn_mower.backyard
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: "The backyard mower is back at the dock."
Step 4: Send it home when it rains
Most mowers have their own rain sensor. This is an extra for cases where you have a better local rain sensor or a weather station. Also from the Lawn mower docs:
Code: Select all
alias: "Dock the mower when it starts raining"
triggers:
- trigger: state
entity_id: binary_sensor.rain_detected
to: "on"
conditions:
- condition: lawn_mower.is_mowing
target:
entity_id: lawn_mower.backyard
actions:
- action: lawn_mower.dock
target:
entity_id: lawn_mower.backyard
Step 5: Override the schedule when you want an extra cut
Per the HA docs, lawn_mower.start_mowing only works during the schedules defined in the Automower Connect app, and the battery must be fully charged. To mow outside the schedule, use husqvarna_automower.override_schedule, which lets the mower either mow or park for a given duration, overriding all schedules. Use the Developer tools > Actions page to try the action and see the fields for your version before putting it in an automation.
Ideas: mow only when the "garden is empty" (nobody home, pets inside), or skip the schedule on days when there is a party or a sprinkler schedule runs.
Safety and security
- Never rely on an automation to make a garden safe. A mower blade can cause serious injury. Do not start the mower remotely if people or pets might be on the lawn.
- Keep the Application Key and Secret private. If they leak, delete the application on the developer portal and create a new one.
- Rate limits: the openHAB Automower binding docs state Husqvarna's application key limits as 10,000 requests per month and 1 request per second. Do not write automations that poll the API in a loop.
- Leave the mower PIN set and enable its alarm so a stolen mower is useless.
Question for the group: what automations do you run with your mower (rain, schedule overrides, "only when we are out")? Has anyone found a good way to avoid it mowing during a pool party?