onfoot / homebridge-valetudo-xiaomi-vacuum

A Homebridge plugin for Xiaomi/Roborock vacuum cleaners running Valetudo
MIT License
31 stars 9 forks source link

Multiple parsing errors Unexpected token < in JSON at position 0 with plugin v0.1.5 and Valetudo re v.0.10.5 #16

Open xorguy opened 3 years ago

xorguy commented 3 years ago

Hi.

Installed just released v0.1.5 with legacy mode set to true with Valetudo RE 0.10.5 and same errors appears.

`[3/4/2021, 5:10:31 PM] [ValetudoXiaomiVacuum] Error parsing firmware info: SyntaxError: Unexpected token < in JSON at position 0

[3/4/2021, 5:10:31 PM] [ValetudoXiaomiVacuum] Error parsing firmware info: SyntaxError: Unexpected token < in JSON at position 0

[3/4/2021, 5:10:36 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

[3/4/2021, 5:10:36 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

[3/4/2021, 5:10:36 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

[3/4/2021, 5:10:36 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Status Low Battery' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

[3/4/2021, 5:10:36 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Battery Level' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

[3/4/2021, 5:10:36 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Charging State' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

[3/4/2021, 5:10:42 PM] [ValetudoXiaomiVacuum] Error parsing firmware info: SyntaxError: Unexpected token < in JSON at position 0

[3/4/2021, 5:10:42 PM] [ValetudoXiaomiVacuum] Failed to get volume: SyntaxError: Unexpected token < in JSON at position 0

[3/4/2021, 5:10:42 PM] [ValetudoXiaomiVacuum] Failed to get volume for Mute: SyntaxError: Unexpected token < in JSON at position 0`

T-Bone90 commented 3 years ago

The same... :-(

onfoot commented 3 years ago

All right, that was a disaster, sorry. I underestimated the api changes in RE, which I'm currently running. Let's see how it goes with 0.1.6. Seems to work fine with almost all characteristics, that is speeds, battery status (percentage and charging state). Haven't yet checked the cleaning, because I shouldn't make much noise at the moment. ;)

T-Bone90 commented 3 years ago

Works better but I get [4.3.2021, 22:06:51] [homebridge-valetudo-xiaomi-vacuum] This plugin generated a warning from the characteristic 'Battery Level': characteristic value expected number and received undefined. See https://git.io/JtMGR for more info. in Homebridge.

xorguy commented 3 years ago

With 0.1.6 no more unexpected tokens, only the same warning as @T-Bone90 mentioned. [3/4/2021, 11:49:22 PM] [homebridge-valetudo-xiaomi-vacuum] This plugin generated a warning from the characteristic 'Battery Level': characteristic value expected number and received undefined. See https://git.io/JtMGR for more info. Thanks!

onfoot commented 3 years ago

What version of node and homebridge are you guys running? I fixed the battery level issue in 0.1.7, but the thing is, I'm not getting those errors at all when running. And homebridge is running in debug mode.

xorguy commented 3 years ago

I'm running Homebridge in Docker, no debug mode, and node version is v14.16.0 Updating to plugin version 0.1.7 and the same warning for Battery Level is shown.

T-Bone90 commented 3 years ago

Bildschirmfoto 2021-03-05 um 09 20 17 Same Error in 0.1.7, every few seconds

T-Bone90 commented 3 years ago

It doesn't work that well either. I started the vacuum cleaner with a button on the vacuum cleaner, but I didn't flip a switch in homekit. Only at some point did it start when the cleaning was almost over. (Sorry fort the bad English ;) )

onfoot commented 3 years ago

Sure, I have to do more testing with the vacuum actually running - we'll get there eventually. ;)

T-Bone90 commented 3 years ago

0.1.8 at the moment no errors! Except the above little problem with Homekit.

xorguy commented 3 years ago

Updated to 0.1.8 and no warnings so far. Thanks! Hope Homekit integration gets better over time.

onfoot commented 3 years ago

The issue with the vacuum's state not being up-to-date may be due to the time interval it uses between status checks when the device is idle. If the time is not yet up, it uses the locally cached status instead of reading it from the device. I'll fix that so that regular checks will happen as usual, but when the phone wants the current status when one's entering the Home app, it will hopefully get a more up-to-date one.

T-Bone90 commented 3 years ago

With 0.1.8 [7.3.2021, 03:35:16] [ValetudoXiaomiVacuum] Error parsing current status info: Error: connect ECONNREFUSED 192.168.255.20:80

onfoot commented 3 years ago

That's not something I can fix unfortunately - the connection was refused, so either valetudo died on your vacuum or maybe you have some kind of an IP conflict so another device sits on 192.168.255.20.

T-Bone90 commented 3 years ago

Ah ok sorry. No I have no ip conflict. who knows... :-)

onfoot commented 3 years ago

Try visiting http://192.168.255.20/api/current_status maybe

heikobischoff commented 3 years ago

I'm experiencing a similar issue. I just set up my S50 with Valetudo 2021.02.0, added the latest version of the plugin v0.1.8 to my Homebridge running v1.3.2 and get multiple

Error parsing current status info: SyntaxError: Unexpected token < in JSON at position

Any idea? BTW: Does the plugin work when HTTP authentication is enabled? I do want to protect the web interface, but for the initial tests I did not enabled this.

Edit: http://ip/api/current_status responds with "Cannot GET /api/current_status". Seems like this is not an issue with the plugin, but with my Valetudo. Do you know how to enable the API? It seems like the DEVs don't want us to use the API, instead they are supporting MQTT which is very annoying. Edit2: The API is not part of Valetudo anymore. They released a new API version as described here: https://github.com/Hypfer/Valetudo/pull/635#issuecomment-751809065 Are you planning to update the Homebridge API to be compatible with the new API v2? Sorry for misusing this thread, should I open a new issue?

onfoot commented 3 years ago

Crap, my fault for not tracking these things - I focused on getting the plugin working with RE as I've been having some spare time recently - but in the mean time it seems official Valetudo's API has been updated, but from how the url scheme looks like there's a bigger chance of it becoming an official and, to an extent, supported one. I'll get right on adding support for it, since the RE part is mostly working.

The previous official Valetudo's internal API status endpoint was a little different, /api/state I think, but since that changed, it's /api/v2/robot/state/attributes it seems. Time to roll up the sleeves!

Oh, and I have been thinking about adding support for valetudo vacuums through MQTT, but it would be YET ANOTHER route of talking to the things, and it's not something I have time for. Unless I get an extra vacuum to play with and additional 3 hours in a day. 🤣

And it's probably doable with an existing generic MQTT plugin to create a set of switches that would roughly emulate what this plugin does.

T-Bone90 commented 3 years ago

With the newest home bridge Update I get Errors like: " [14.3.2021, 12:33:54] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Charging State' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:15] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:15] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:15] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' was slow to respond! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:15] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Status Low Battery' was slow to respond! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:15] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Battery Level' was slow to respond! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:15] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'Charging State' was slow to respond! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:21] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info. [14.3.2021, 14:25:21] [homebridge-valetudo-xiaomi-vacuum] This plugin slows down Homebridge. The read handler for the characteristic 'On' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info. "

onfoot commented 3 years ago

Sorry, I'm a little swamped and I my vacuum is currently flashed with the latest official Valetudo, since I've updated the plugin to work with it properly. I have quite a dilemma here, since there are now three slightly different APIs I need to work with. I'd probably drop the previous official Valetudo one and just keep the latest one and the one exposed by RE.

Anyways, I'll try to switch to RE and test it again. I have no idea what would cause it to suddenly stop working with RE, since I didn't see any major changes to the API there.

MoienBowen commented 3 years ago

Sorry, I'm a little swamped and I my vacuum is currently flashed with the latest official Valetudo, since I've updated the plugin to work with it properly. I have quite a dilemma here, since there are now three slightly different APIs I need to work with. I'd probably drop the previous official Valetudo one and just keep the latest one and the one exposed by RE.

Anyways, I'll try to switch to RE and test it again. I have no idea what would cause it to suddenly stop working with RE, since I didn't see any major changes to the API there.

I may have the answer, because I had exactly the same issue... Who has the issue, please first verify if you are using the RE version. If yes, please read carefully the readme file of this project, and ask yourself: did you add the option "legacy-mode": true?

T-Bone90 commented 2 years ago

Any News here? With beta 2 I get [ValetudoXiaomiVacuum] Error parsing current status info: SyntaxError: Unexpected token U in JSON at position 0 once a day.

miguelpruivo commented 2 years ago

I'm also experiencing this.

miguelpruivo commented 2 years ago

Any fixes?

onfoot commented 2 years ago

I finally installed RE on my robot and I'm not getting the unexpected token errors, for now. But I did fix some minor issues with Going Home and Spot cleaning.

I'll be testing the RE version more thoroughly in the coming days, however, so stay tuned.

KayGundhardt commented 2 years ago

So this problem persists for original valetudo as you say "I finally installed RE"??

Actually I'm having this very same issue every second and so it's not reachable via HomeBridge nore HomeKit (Valetudo Release 2022.01.0) with an S5 Roborock.

KayGundhardt commented 2 years ago

so SORRY! I habe missed out your beta-2: problem solved so far ;)