rand256 / valetudo

Valetudo RE - experimental vacuum software, cloud free
Apache License 2.0
667 stars 73 forks source link

REST api curl PUT request start_cleaning_zone_by_name #345

Closed markusdahlberg closed 3 years ago

markusdahlberg commented 3 years ago

Hi and thanks for a great software.

I am trying to request zoned cleanup by curl.

I am using this string

curl -X PUT -H "Content-Type: application/json" -d '[{"Zone1"}]' http://192.168.1.118/api/start_cleaning_zone_by_name

This error occurs .

Am I doing this wrong or is it a bug?

`!DOCTYPE html>

Error
SyntaxError: Unexpected token } in JSON at position 9
   at JSON.parse (<anonymous>)
   at parse (/snapshot/valetudo/node_modules/body-parser/lib/types/json.js:89:19)
   at /snapshot/valetudo/node_modules/body-parser/lib/read.js:121:18
   at invokeCallback (/snapshot/valetudo/node_modules/raw-body/index.js:224:16)
   at done (/snapshot/valetudo/node_modules/raw-body/index.js:213:7)
   at IncomingMessage.onEnd (/snapshot/valetudo/node_modules/raw-body/index.js:273:7)
   at IncomingMessage.emit (events.js:327:22)
   at endReadableNT (_stream_readable.js:1221:12)
   at processTicksAndRejections (internal/process/task_queues.js:84:21)

`

rand256 commented 3 years ago

As for me, it tries to say that your json is wrong. You need to put an array of strings, while you're writing an array of invalid objects. Try just '["zone1"]' or '["zone1","zone2"]' etc.

markusdahlberg commented 3 years ago

As for me, it tries to say that your json is wrong. You need to put an array of strings, while you're writing an array of invalid objects. Try just '["zone1"]' or '["zone1","zone2"]' etc.

root@rockrobo:~# curl -X PUT -H "Content-Type: application/json" -d '["Hall"]' http://192.168.1.118/api/start_cleaning_zone_by_name;echo Error: Zones must be array of at most 5 zones.

rand256 commented 3 years ago

And this is really a bug. Probably nobody used this route for years. :(

Just fixed that, please try running this test build. See installation instructions in wiki (if you have a gen1 device, it's still applicable, just replace /etc/init/S11valetudo stop with stop valetudo and, /etc/init/S11valetudo start with start valetudo). Sorry for the inconvenience.

markusdahlberg commented 3 years ago

It works! thanks