Page 1 of 1

Adding Worx Landroid

Posted: Thursday 15 August 2019 1:41
by daPeda
Hello,

I am trying to integrate my Worx Landroid robotic lawnmower into Domoticz. For this I am following the following instructions:
https://easydomoticz.com/forum/viewtopi ... 300#p72300

However, I get an error here in the first part of the manual:
TOKEN = $ (curl -v -X POST -d '{"client_......
(23) Failed writing body

My research came up with the result that my file system should be broken. So I've reinstalled Domotics on the Raspberry. Unfortunately, no improvement.

I would be very happy if I got a tip.

Thank you in advance!

all the best
Peter

Re: Adding Worx Landroid

Posted: Thursday 23 April 2020 23:02
by timmpo
i tested the information on that site and found it working, i rewrite some code..

This make 2 files with json data with all usefull info aboute your landroid (second file hold the most usefull information).
make sure you give the script rights to create files. (sudo chmod 777 filename.sh)
edit user, pass and your serial number
you need to have JQ installed

Code: Select all

#!/bin/sh
DOMOTICZ="192.168.1.100"
PORT="8080"

TOKEN=$(curl -v -X POST -d '{"client_id": 1, "grant_type": "password", "scope": "*", "client_secret":"nCH3A0WvMYn66vGorjSrnGZ2YtjQWDiCvjg7jNxK", "username":"YOUR_EMAIL", "password":"YOUR_PASSWORD"}' -H 'Content-Type: application/json' https://api.worxlandroid.com/api/v2/oauth/token | jq -r '.access_token')
curl -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" https://api.worxlandroid.com/api/v2/product-items > landroid_indata.json
curl -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" https://api.worxlandroid.com/api/v2/product-items/YOUR_SERIAL_NUMBER/status > landroid_indata2.json
echo "Done..."

#This reads the json file
MOWER_WORKED=`cat landroid_indata.json | jq '.[]|.mower_work_time'/60`
echo $MOWER_WORKED
#Put the value to domoticz
curl http://$DOMOTICZ:$PORT/json.htm?"type=command&param=udevice&idx=IDX&svalue=$MOWER_WORKED"
but this information on that site is not right, on newer firmwares (5.52) you find the mower_work_time in the second json file
at the ['dat'] ['st'] ['wt']
distance is on ['dat'] ['st'] ['d']
battery voltage ['dat'] ['bt'] ['v']
rsi ['dat'] ['rsi']
so perhaps you have to find out what is what with your version

Re: Adding Worx Landroid

Posted: Monday 04 May 2020 14:23
by azertigrou
The following command worked very well yesterday but not today.
Is the problem is on my site or the API does not exist anymore?
Thx

TOKEN=$(curl -v -X POST -d '{"client_id": 1, "grant_type": "password", "scope": "*", "client_secret":"nCH3A0WvMYn66vGorjSrnGZ2YtjQWDiCvjg7jNxK", "username":"YOUR_EMAIL", "password":"YOUR_PASSWORD"}' -H 'Content-Type: application/json' https://api.worxlandroid.com/api/v2/oauth/token | jq -r '.access_token')

Re: Adding Worx Landroid

Posted: Sunday 24 May 2020 16:24
by magicduck
I have an "old" Worx (with the app : Worx Mover).

I have just made some quick dzvents script :

Code: Select all

-- Your Worx Landroid M informations
local worx_ip  = "192.168.x.Z"
local worx_pin = "0000"
-- Update the virtual devices 
local update_devices = 1 -- 0 = no update / 1 = update 
local idxbat   = 1234  -- Virtual Device type Percentage
local idxstate = 1235  -- Virtual Device type Text
local idxmsg   = 1236  -- Virtual Device type Text


-- For http callback
local response = "Worx_response"

return {
	on = {
	    timer         = { "every minute"},
	    httpResponses = { response },
	},
	logging = {
	        level = domoticz.LOG_DEBUG,
	        maker = "Worx M"},
	execute = function(dz, item)
            local function logWrite(str, level)
                dz.log(tostring(str), level or dz.LOG_DEBUG)
            end
            
            if item.isHTTPResponse then
                local worx_state
                local worx_battery
                local worx_charger
                local worx_message
                
                worx_state = item.json.state 
                worx_battery = item.json.perc_batt
                worx_charger = item.json.batteryChargerState
                worx_message = item.json.message
                
                logWrite("Worx State   : " .. worx_state)
                logWrite("Worx Battery : " .. worx_battery .. "%")
                logWrite("Worx Charger : " .. worx_charger)
                logWrite("Worx Message : " .. worx_message)
                
                if update_devices then
                    dz.devices(idxbat).updatePercentage(worx_battery)
                    dz.devices(idxstate).updateText(worx_state)
                    dz.devices(idxmsg).updateText(worx_message)
                end
            else
                local url = "http://admin:"..worx_pin.."@"..worx_ip.."/jsondata.cgi"
                
                dz.openURL({
                    url    = url,
                    method = "GET",
                    callback = response })
            end 
	end
}
Replace all information at the begining, you'll get data directly :p

Re: Adding Worx Landroid

Posted: Wednesday 07 April 2021 12:01
by skorc11
Hello,

is this still working for new models with WIFI ? New API ?

This looks nice for lawn mower...
https://www.npmjs.com/package/iobroker.worx

U