Landroid automower integration

Worx Landroid

Worx - a company to manufacture garden and homeworking tools - is also offering a range of ‘Landroid’ robot lawn mowers.
Some of the older models (M1000i a.k.a. WG796E.1 and M1500i a.k.a. WG797E) introduced end of 2014 feature onboard WiFi and app control. As the app is essentially just using HTTP and JavaScript, we can reuse this interface to integrate with openHAB.
NOTE: there is no official API. This solution is based on reverse engineering the app’s access to a WG796E.1 running software versions 1.98 (“Hypericum 3.1”). Latest version it was verified to work with currently is 2.61, but keep in mind it may change without notice in future mower OS versions.

Note that Worx has substantially changed remote control for the 2017 “S” models. They’re meant to be controlled via Worx cloud now. 2017+ M and L models I believe the interface remained so they should still work with this but I don’t know for sure. Drop me a note if you have one of these models and can test it.
EDIT: There’s work underway to create a bridge for these models.

HTTP binding based control

Use the openHAB HTTP binding to directly query and control Landroids.

(replace IP and use your Landroid PIN instead of “1234”)

String Landroid_status "Landroid Status [%s]" <garden> (Rasenmaeher) { http="<[http://admin:1234@*\"state\":\"(.*?)\",.*)]" }
String Landroid_Command "Landroid action" <garden> (Rasenmaeher)

If you call the URL, output shows a number of parameters, state being just one of them.
Feel free to pick those of interest and use a copy of the Landroid_status item with an appropriately modifed regex.

in sitemap:

Text item=Landroid_status label="Landroid status [%s]"
Switch item=Landroid_Command mappings=[11="Start", 12="Stop"]

put up a rule:

rule "Landroid command"
    Item Landroid_Command received command
    // Commands
    // 11 = start
    // 12 = stop (& return to base)
    // 13 = charging complete
    // 14 = manual stop
    // 15 = going home

    // NOTE: insert your PIN and IP here
    val String URL = "http://admin:1234@"

    var String jsondata = 'data=[[\"settaggi\",' + Landroid_Command.state.toString + ',1]]'

    logInfo("rules", "Sending command " + Landroid_Command.state + " to Landroid.")

    sendHttpPostRequest(URL, "application/x-www-form-urlencoded", jsondata)

Just asking (I really don’t know the product), but being JSON GET/POST, isn’t it easier to define the item with a jsonpath transformation? I mean, that would make the rule you wrote obsolete!
LATER EDIT: sorry didn’t read thoroughly, but still for the item definition Landroid_status if it’s json, you could use that!
Just my 2 cents!


Possibly, but you need a specific HTTP header to be set. At least by the time I wrote this it I couldn’t get this to work with just transformations.

Can you get a GET request through the browser on the status and post it here? The JSONPATH transformation is great! I know you will use that! :wink:

Well one would ideally want to retrieve multiple fields with just one HTTP request, if you know how to get that to work I’d be happy to use that. Other than that I think it’s no big difference to use JSONPATH or REGEX transformations.

[08:40:14] openhabian@openhabianpi:/etc/openhab2/items$ wget http://admin:*password*@landroid/jsondata.cgi
--2018-07-03 08:40:17--  http://admin:*password*@landroid/jsondata.cgi
Auflösen des Hostnamens »landroid (landroid)« …
Verbindungsaufbau zu landroid (landroid)||:80 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 401 Unauthorized
Authentifizierung ausgewählt: Basic realm= "Landroid"
Verbindungsaufbau zu landroid (landroid)||:80 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: nicht spezifiziert [text/html]
Wird in »»jsondata.cgi«« gespeichert.
jsondata.cgi                                        [ <=>                                                                                                  ]     755  --.-KB/s    in 0,04s
2018-07-03 08:40:17 (19,7 KB/s) - »jsondata.cgi« gespeichert [755]
[08:39:33] openhabian@openhabianpi:/etc/openhab2/items$ cat jsondata.cgi
{"versione_fw":2.61,"lingua":1,"ore_funz":[10,0,55,0,0,0,0],"ora_on":[8,0,8,0,0,0,0],"min_on":[30,0,30,0,0,0,0],"allarmi":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"settaggi":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"mac":[0,35,167,82,254,171],"time_format":1,"date_format":0,"rit_pioggia":60,"area":0,"enab_bordo":1,"percent_programmatore":10,"indice_area":9,"tempo_frenatura":20,"perc_rallenta_max":70,"canale":0,"num_ricariche_batt":466191,"num_aree_lavoro":1,"dist_area":[1,1,1,1],"perc_per_area":[1,1,1,1],"area_in_lavoro":0,"email":"john.doe@some.where","perc_batt":"89","ver_proto":1,"state":"home","workReq":"landroid req manual homing","message":"none","batteryChargerState":"charging","distance":-9}