Automower Binding (G2)

Hi @markus_pfleger,
thanks for your contribution - much appreciated!
I just realized by accident that the JSON with a mower’s data as returned from the Husqvarna API actually contains a list of waypoints (latitude + longitude). I was wondering if you planned to integrate this in your binding? I think it would be very nice to visualize the mower’s position in a map :smiley:
Thanks,
Bernhard

Hello Bernhard,
I have tested the reading of the GPS data. The last 50 positions are always saved. Thereby a new position is added internally in the Automower approx. every 20 seconds and the last one is deleted for this. Unfortunately, there is no time information per position, so that a correct display is not possible. With TrackMap, however, the path traveled can be roughly displayed quite well in e.g. Grafana.
As a further problem, the coordinates or the GPS map of the Automower are probably offset by 15m.

No, I have no plans in that direction as I see no use case for me. It doesn’t help me to automate and in visualizations I am not so much interested :wink: (and if I would be really interested I would just use the automower app).

But happy about any contributions if someone finds that useful…

Hi Sven,
thanks for your reply. I saw that the waypoints don’t have a timestamp, but thought simply updating the position in the map with the latest waypoint would suffice to at least give a good indication where the mower is currently working. But now thinking about it, that would create an issue with too many requests against the very limited quota… otherwise, after say 5 minutes the position will be rather useless.

However, there might still be an intersting usecase: my Automower keeps falling over (over the edge and down a slope, emergency stop because it drove under the trampoline ladder, …). So this way I could at least get a hint where to go to fix the problem :smiley:

Thanks for the heads-up! Maybe at some point I’ll take a look at it and come up with a suggestion :grinning:

Maybe a solution is to retrieve the position if an error occurs. So we should get into any limits and get a hint where to search in case of an error

I think always retrieving the position would automatically let you know the last position when an error occurs, so no additional logic would be required; and we could simply discard the retrieved positions if they are only required for locating the device.

I didn’t look into the logic behind the array of waypoints but assuming they are recorded in certain time intervals would also provide a pretty neat coverage over possibly longer timeframes (as required by the quota of API requests).
Maybe I should simply tape a mobile phone with GPS to the mower at some point and match a separate GPS tracking to the output of a few API requests while the mower is active… this might also provide some practical data to determine the deviation from the actual position.

2 Likes

Actually I did take a stab at it and it seems to work fine so far.
I’ve actually added now 50 channels for all waypoints.

If anyone is interested the changes are available here: GitHub - bern77/openhab-addons at bern77-gps

I’m also happy to share the JAR.

1 Like

Hi,
thanks for doing this enhancements! :grinning:
Can you share how you display the waypoints? My Items are empty.
That’s how I try to implement the Waypoint.

String      AutomowerWayPoint1  "Waypoint 1 [%s]"   <movecontrol>   (Automower, DB) { channel="automower:automower:mybridge2:myAutomower:position01" }

Happy for your suggestions!

br. Christian

Please use Location as the item type, then it should work.

1 Like

And in the channel please use positions#position01

1 Like

Hello bern77,

thanks for your help!!! :smiley: Working great!

Does anyone have a suggestion how to display the way, indicated by the waypoints?

Br. Christian

Hello Christian,
the Grafana PlugIn TrackMap can do this. But for this you need latitude and longitude separately. With openhab an influxdb the location is stored as a comma separated value.
Perhaps there is a suitable query that extracts latitude or longitude from the stored coordinates. Unfortunately, I have not yet been able to do this with the help of the documentation.
A few ideas regarding path visualization can be found here.

Does anyone have an idea or solution for openhab, influxdb and TrackMap?

I get this from the binding now and then.

2021-08-26 15:50:34.394 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://api.authentication.husqvarnagroup.dev/v1/oauth2/token failed with error code invalid_grant, description Failed to find token
2021-08-26 15:50:34.400 [WARN ] [ternal.bridge.AutomowerBridgeHandler] - Unable to fetch automowers: Rest call failed: statusCode=-1, message=Unable to authenticate

Only way to fix it is to delete the thing and recreate it with a new identifier.

What can this be?

Hi Sven,
got it! I use Grafana and InfluxDB. I seperate the values with string manipulation in Latitude und Longitude and set up a Dashboard with the following Select statements:

SELECT mean("value") FROM "MowerWayPoint1Lat" WHERE ("item" = 'MowerWayPoint1Lat') AND $timeFilter GROUP BY time($__interval) fill(null)
SELECT mean("value") FROM "MowerWayPoint1Long" WHERE ("item" = 'MowerWayPoint1Long') AND $timeFilter GROUP BY time($__interval) fill(null)

Then I implement a link to a rendered image in my sitemap which is refreshed every 10 seconds.
br. Christian

Hi All,
just found that the value for the calendar start time (which is in minutes after midnight) is already reflecting the correct time zone. Therefore it always shows a difference of two hours for me (due to timezone handling). On the other side timezone handling is necessary during the day. No clue how to handle this in a correct way. Is there a different state when waiting for the next calendar based start which we can use for the decission to do timezone handling or not?

br. Christian

My modifications work quite well for me, so I’ve now created a PR for them (see https://github.com/openhab/openhab-addons/pull/11323).

@markus_pfleger, I’m curious about your inputs / concerns and more than happy to discuss.

Thanks,
Bernhard

I just got the same problem last week. It has been working fine for several weeks and now it’s not able to connect. Is there a know issue?

I’m running openHAB 3.3.0.M6

I tied to install the Binding and the Bridge but without success.
My bridge is red…
I am using the official 3.2.0 build from openhab.
Is there a hint to get the bridge online?
Or could it be that this is a Husquarna problem???

brgds

Hulli

Hello Frank,

I think it has to do with this issue:

br. Tobi