Skip to content
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

Charge details giving an error #18

Closed
alecwills opened this issue Mar 21, 2021 · 10 comments · Fixed by #19
Closed

Charge details giving an error #18

alecwills opened this issue Mar 21, 2021 · 10 comments · Fixed by #19
Labels
bug Something isn't working

Comments

@alecwills
Copy link

alecwills commented Mar 21, 2021

API is working correctly for all endpoints except /api/v1/cars/:carid/charges/:chargeid
the :carid and :chargeid I am using are both valid.
The web response is ERR_EMPTY_RESPONSE
The logs on the docker instance (Ubuntu server 19.10 64bit on Raspberry Pi 4) is;
sql: Scan error on column index 5, name "not_enough_power_to_heat": sql/driver: couldn't convert <nil> (<nil>) into type bool

I've checked the DB and while this column exists every row has null in this column. Note: I am in Australia and car is Model 3 and I don't believe my battery is ever heated as it's never cold enough here.

@LelandSindt
Copy link
Contributor

I see/can confirm this same behaviour.

@tobiasehlert
Copy link
Owner

Hello @alecwills

Some rows can contain null as data and a SQL query with book does not support null. There is a workaround that I've done at drives endpoint that I can add here, and that is to use NullBoolean instead of Boolean only. I can make a fix and you can test it.
Can you send the full row of data? I think that there is may e some more cell containing null that we can fix at the same time.

My wife is at the computer currently but later in the evening I will add a little code :-)

Regards,
Tobias

@tobiasehlert
Copy link
Owner

google -> https://stackoverflow.com/questions/26976251/how-can-i-fetch-a-null-boolean-from-postgres-in-go -> https://golang.org/pkg/database/sql/#NullBool -> #19

Here is the NullSupport fine containing the fix.. it's using SQL package for this but there could be a better way of implementation maybe.
https://www.github.com/tobiasehlert/teslamateapi/tree/main/src%2FNullSupport.go

@tobiasehlert tobiasehlert added the bug Something isn't working label Mar 21, 2021
@tobiasehlert
Copy link
Owner

Now you can test the fix in docker image with label main instead if latest :-) confirm if it fix by @LelandSindt helped you @alecwills

@LelandSindt
Copy link
Contributor

Ah, I thought that NullBool was made available from github.com/lib/pq I didn't see that you had aliased it from elsewhere.

@LelandSindt
Copy link
Contributor

Not sure if its a better way, but [after some experimenting] I confirmed that you can import database/sql and then reference sql.NullBool directly

but then it looks like you are also pulling in some logic to help with the json marshaling.

..... if it's not already clear, I am here to learn as much as I am here to help.

@tobiasehlert tobiasehlert linked a pull request Mar 21, 2021 that will close this issue
@tobiasehlert
Copy link
Owner

Ah, I thought that NullBool was made available from github.com/lib/pq I didn't see that you had aliased it from elsewhere.

Yeah.. I had issues with errors in the sql statements and that what was I was finding after extensive googling.. 😄

Anyhow.. there is probably a better solution to not link a full library. the database/sql library does include a looot of stuff, so would be pretty nice to only have the part that is needed. But I'm not sure how to structure a new type like that.
Might be something for future enhancements when I'm bored. It works as it is today and that is the important thing 👍

@alecwills
Copy link
Author

Now you can test the fix in docker image with label main instead if latest :-) confirm if it fix by @LelandSindt helped you @alecwills

Thanks @tobiasehlert @LelandSindt I'm not a developer or big github user so can't quite tell who resolved this. I can confirm I have pulled the main label docker image and it is now working as expected. Thanks for your speedy help. I assume I close this, apologies if that's wrong.

@idominiki
Copy link

Hey @tobiasehlert,

I think I have the same problem. Since 4 weeks I can access the charges data. Now I got the error " Empty reply from server
"
Bildschirmfoto 2021-05-31 um 17 34 05

What should I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants