-
Notifications
You must be signed in to change notification settings - Fork 9
SyntaxError: Unexpected token N in JSON at position 0 #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The plugin works with both versions, but the appropriate one must be indicated in the config. I guess I need to add an option for more verbose logging so it shows the whole string along with the request URL, so I can pinpoint it more easily. Currently I'm running RE, but want to start testing both, so the plugin is more reliable across the board. |
Hi @onfoot & @greatestview I've the same issue with my Gen1 and Valetudo RE v0.10.7 (latest).
When i check the JSON return of /api/current_status :
When i check the JSON return of /api/get_fw_version :
Any ideas @onfoot ? Thank for your help 🙏 |
@robinfdx Have you set the |
@onfoot : Yes i've, like this :
I've restart homebridge but same thing |
@onfoot : do you ve any idea about this problem ? 😊 |
If you can, please enable debug mode in your homebridge and let me know, what the raw responses are when the error occurs. This is usually accomplished by uncommenting |
@onfoot, I finally figured it out! Thanks to this guy on reddit, I managed to debug your plugin directly on my pi instance: The error occurs inside This line in vacuumvaletudo.js#L370 with call to const response = await sendJSONRequest({ url: VacuumValetudo.statusUrl(this.ip) }); The solution is very simple and only a few lines of code: Just include HTTP Basic Auth into the config and pass it as a parameter to const response = await sendJSONRequest({
url: VacuumValetudo.statusUrl(this.ip),
authentication: config.basicAuth ? config.basicAuth : null,
}); There are multiple calls to Workaround since then: Disable HTTP Basic Auth in Valetudo. |
That's awesome, thanks for doing the research! I have another plugin I had to put basic auth support into, so the simple http request function I made for all my plugins already supports it, so I'll make sure first if both valetudos work the same way and enable the support here. |
Any news? :) |
Coming right up! Hopefully I'll test the change today and push out an update. Will be untested on Valetudo non-RE for now, though. |
v0.3.0 is ready for consumption. 🎉 |
Thanks for the new version and happy new year :)
In the Config I have two entrys for your plugin. The second entry come with v0.3.0.
If I delete the first entry, the Error looks the same. I think I must remove the first entry. Or the plugins write the wrong "accessory" entry in the config. If I change name or ip in your plugin config, the second entry is change. I think the new version use the wrong "accessory" name. |
That's interesting, since your error message says the opposite. 😄 You seem to have one "Valetudo Vacuum" plugin configured instead of "ValetudoXiaomiVacuum". |
OK that's weird. I just installed your plugin. I used another Roborock Plugin in the past but at the moment your plugin is the only. The error message says I must delete the second entry (Valetudo Vacuum) because there is no Plugin "Valetudo Vacuum". |
Same here, was |
Yes that's right. But If I go to Plugins Settings and make entrys, the entry Valetudo Vacuum is automatically recreate in the config file. |
That's wild. The only place the "Valetudo Vacuum" string exists is my local-only config schema file I'm working on to be able to better control the plugin through the Homebridge Web UI in the near future. I'll investigate this issue for sure. You're both using the UI currently? Or is it also happening when configured from command line? |
I only use UI. |
Thanks, I'll check it out! The weird thing is that the plugin registers itself as |
You’re right, the String I can replicate the behavior:
Reboot doesn’t change anything. All my plugins are up to date. Workaround: Delete the entry and keep using an accessory Update: I think I found something. There is a config.schema.json on NPM with |
Yep, that's the crux of the issue! I just published v0.3.1 without the file for now as it's not complete. Thanks for noticing! I didn't realise somehow npm grabs the code for the published module. Seems like they want to control the contents in some way. |
That should’ve solved it, thank you! |
So, this seems to be resolved, finally. Isn't it? ;) |
No sorry the bug already exist :-( [6.1.2023, 03:35:57] [Robi] Error parsing current status info: SyntaxError: Unexpected token M in JSON at position 0 |
A version with better json parsing diagnostic coming soon, unless I come down with the flu. 🤢 |
I'm alive. v0.3.2 is up. Let's try to figure this out. |
No, now I get an other error. 😅 [7.1.2023, 03:35:28] [Robi] Error parsing current status info: Error: connect ECONNREFUSED 192.168.255.20:80 |
That's a connection refused error - something at this address does not accept calls to port 80. Notice your ip is highly sus: 192.168.255.20 . 🤔 |
Yes that's my IP range. 192.168.255.x |
Yeah, I mean the ip is valid, but pretty unusual, so my thought was that maybe there's a typo there somewhere. ;) Oh, perhaps it's restarting due to some watchdog timer firing, and the http server is not available at that moment. |
No there is no typing error ;-) This morning the same: |
That, in turn, is a "Host unreachable" error, meaning the device was not available for connecting. 🤷♂ E.g. its network interface was disconnected at that moment. |
Yes but the problems are only since v0.3.2 ;-) |
So previously you'd only get the |
Actually, I've been thinking about the errors you're getting. Here they are sorted by time of day: That would suggest to me that the vacuum If it were Let's gather some more data. 😄 |
Yes! I take a look at the log one minute ago and see this error messages (all red): [8.1.2023, 03:35:07] [Robi] Error parsing current status info: Error: connect EHOSTUNREACH 192.168.255.20:80 The second is 14:32. But I can't believe that my Roborock is reboot every time. 🤔 Here is an Excerpt from my valeted log. Maybe you find some 2023-01-09T02:35:43.031Z Yes there is a "warning" 02:36 that the Roborock can't reach vacuum. I don't know. But I don' have a warning 14:32... And I'm not the only one who gets the errors. Hmm 🤔 ///Edit: I wanted to use HomeKit to clean with my Roborock. [9.1.2023, 17:36:55] [Robi] Failed to stop cleaning: Error: This callback function has already been called by someone else; it can only be called one time. I haven't named the switches yet. I hope this infos help a little bit. |
See? At least the unreachable/refused scenario is confirmed by the first lines of the log:
This is probably it. The time difference is due to it logging in GMT, and homebridge logging in local time.
About the "Failed to stop cleaning", however - that is an actual bug I need to investigate, because this is something new. 🤔 |
Hmm thats confused. I didn't found an option in valetudo because of the reboots (Maybe wanted...). I can ask and open an issue on valetudo GitHub. But first I'll wait another night and check the log again. But was is with " Error: connect ECONNREFUSED" 14:32? I don't have any entry in my valetudo log on this time. |
This night I didn't get the error in homebridge. I'll keep checking. |
So every night I got this error I don't know what role that plays. I kinda can't believe my robot disconnects every night. Does anybody else have the same problem? |
The plugin simply logs what issue it encountered when connecting to the vacuum at that particular moment. It doesn't control any network interfaces of the device. And because it checks for device's status every once in a while, it may encounter a temporary issue caused by the vacuum rebooting every night at around 3:35. I just checked mine and it rebooted last night at 3:34. |
Ahh ok thanks a lot. So it's a valetudo problem. I'll ask there again, apparently on purpose. |
I did a bit of digging and it doesn't seem to be a problem per se. According to a comment in this file all valetudo-capable vacuums reboot daily. |
My homebridge log is filled with these errors:
The first line appears every 10 seconds, the second infrequently.
First I tought it might be the same issue as described in #16 (and closed #12, #13, #14, #18), but that happens with Valetudo RE while my vacuum runs Valetudo (without RE).
Any ideas? @onfoot, which version combination is working for you?
Versions:
The text was updated successfully, but these errors were encountered: