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

[evcc] Charge Plan Time is not converted to correct Timezone #17620

Closed
tmsch13 opened this issue Oct 23, 2024 · 23 comments · Fixed by #17640
Closed

[evcc] Charge Plan Time is not converted to correct Timezone #17620

tmsch13 opened this issue Oct 23, 2024 · 23 comments · Fixed by #17640
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@tmsch13
Copy link

tmsch13 commented Oct 23, 2024

Expected Behavior

If i set the VehiclePlanTime in openhab I expect to see the same time in EVCC.

Current Behavior

If I set the VehiclePlanTime to eg "2024-10-24T05:30:00.636+02:00“ using Blockly
Bildschirmfoto 2024-10-23 um 11 39 45

it converts to 7:30 in EVCC
Bildschirmfoto 2024-10-23 um 11 40 10

The correspondig MQTT Topic (evcc/vehicles/Tesla_Y/plans/1/time) then shows 1729747800
which is
GMT: Thursday, 24. October 2024 05:30:00
My time zone: 24. Oktober 2024 07:30:00 [GMT+02:00]

By the way: If i change the Planed Time in EVCC, the MQTT Topic gets updated, but not the EVCC channel of the EVCC Binding in Openhab...

Steps to Reproduce (for Bugs)

Set the Plan Time via openhab to a not GMT Time and see the result in EVCC

Your Environment

Openhab: 4.2.1
EVCC: 0.130.2

@tmsch13 tmsch13 added the bug An unexpected problem or unintended behavior of an add-on label Oct 23, 2024
@Laith-Budairi
Copy link
Contributor

does it also display the same time in the item linked to the channel? I tried running the same blockly code and I have this result:

image

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

6:30 is strange... Is it converting the Item value to some other local time zone at your system?

The Item shows 5:30:00 for me.
Bildschirmfoto 2024-10-24 um 08 52 21

The log shows:
2024-10-24 08:52:06.322 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'EVCC_TeslaY_Plan_Time' received command 2024-10-25T05:30:00.320+0200

But thats as expected in openHAB, because „copy of now“ uses ZonedDateTime.

Bildschirmfoto 2024-10-24 um 08 55 02

@Laith-Budairi
Copy link
Contributor

my time zone is UTC+2. Just to make sure, the plan should be displayed here right? I am using https://demo.evcc.io/

image

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

Yes, thats where the Plan Time is displayed.

I just checked openhab and evcc system, which are each individual vms:
Seems fine for me:

root@evcc:~# date
Thu Oct 24 09:06:02 CEST 2024

openhabian@openhab3:~$ date
Thu Oct 24 09:06:21 CEST 2024

But strange that you see 6:30 in your openhab although you’re in UTC+2 as well.

@Laith-Budairi
Copy link
Contributor

so the bug is not there anymore?

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

no it is still there.
the system time on both systems (openhab and evcc) is the same, but when I set a time plan i have different times:

Bildschirmfoto 2024-10-24 um 09 23 45 Bildschirmfoto 2024-10-24 um 09 24 10

@Laith-Budairi
Copy link
Contributor

Laith-Budairi commented Oct 24, 2024

yeah, I just tried to reproduce the bug and had this result, it is 3 hours ahead from what I set:

image

in any case, I tried debugging it, and the value for the channel being updated is set as: 2024-10-25T05:30:00.390+02:00

@Laith-Budairi
Copy link
Contributor

actually there is a weird behavior, if I try to set it to tomorrow at 5:30, the value is:
image

but if I try to set it for any day after tomorrow with the same time (5:30), the value displayed on the item is correct:
image

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

on October 27th we will switch to normal aka winter time. I think thats why you see different times.
I bet if you try with 26th october it will be 6:30 as well.

It think there is an additional problem in your setup as well, as it does not show 5:30 correctly in summer time. Have you checked your system time setting and if some differnt time zone is selected in openhab maybe?

in any case, I tried debugging it, and the value for the channel being updated is set as: 2024-10-25T05:30:00.390+02:00

I think it is either a Problem of what the evcc addon is sending to evcc (maybe sending without TimeZone Info) or even an evcc problem.

@Laith-Budairi
Copy link
Contributor

yeah I think you are right with the winter/summer time. So we can assume that the time is displayed correctly from the defined item, the only issue now is the time on EVCC

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

I just tried the evcc api and i think its also not working correct:

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00Z"
{"result":{"soc":90,"time":"2024-10-25T05:30:00Z"}}

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00-01:00"
{"result":{"soc":90,"time":"2024-10-25T05:30:00-01:00"}}

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-25T05:30:00+01:00"
404 page not found

so positiv offsets from Zulu time (aka UTC ) doesn’t work.

But as the openhab Binding is able to send a plan to evcc it is using „Z" time or "-0:00“ offset, which is not a problem, but than the binding has to make sure to convert correctly from local time (5:30:00+02:00 in this case) to UTC.

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

I raised an Issue at EVCC Link
But I think the Problem needs also be addressed in the openhab binding as said:

the binding has to make sure to convert correctly from local time (5:30:00+02:00 in this case) to UTC

@Laith-Budairi
Copy link
Contributor

Laith-Budairi commented Oct 24, 2024

although in the binding after it updates the time using the POST API, it retrieves the whole values using the GET API /api/state, and I can see that the effective plan time is set correctly:
image

so at first it updates the value on the EVCC dashboard, then it sends a GET request and retrieves the whole value and updates all needed channels.

You are saying that it should convert the time to the proper time zone before sending it in the POST request, and naturally it should convert it again after the GET request

@tmsch13
Copy link
Author

tmsch13 commented Oct 24, 2024

Yeah, what you see is the problem.

You set the time in openhab to 5:30+2:00 (which is 3:30Z aka UTC)
and your screenshot shows 5:30Z (which is 7:30+2:00)

that because the binding takes 5:30+2:00 and send it as 5:30Z which means 5:30+0:00, so is a total different time.
The binding should send: 5:30+2:00 (which seems to be impossible due to an api bug in evcc) or 3:30Z which is the same time just in Zulu time zone.

@Laith-Budairi
Copy link
Contributor

Hi @lucaarn,

Can you share your insights on this?

@Laith-Budairi
Copy link
Contributor

@tmsch13 have you tried it after the fix they merged?

@lsiepel
Copy link
Contributor

lsiepel commented Oct 26, 2024

The binding does not make use of the TimeZoneProvider so it does not respect the timezone set in openHAB. It uses the zone information from the running proces/java/systemI might come up with a fix, but i need someone able to test and verify. (mayube in 2 iterations)

@tmsch13
Copy link
Author

tmsch13 commented Oct 26, 2024

@Laith-Budairi Just tried the nighty EVCC Release with the Fix, positive time offset is now working fine. Remember as we will switch to Winter time this night the offset in Europe is now +01:00

curl -X POST "http://192.168.XX.XX:7070/api/vehicles/Tesla_Y/plan/soc/90/2024-10-27T09:30:00+01:00" {"result":{"soc":90,"time":"2024-10-27T09:30:00+01:00"}}

But openhab binding is (as a expected) still not working correct:

Set Item to 5:30h

Log has the correct Time including Timezone:
Item 'EVCC_TeslaY_Plan_Time' received command 2024-10-27T05:30:00.763+0100

But I see 6:30h in EVCC. So openhab Binding is sending 5:30 UTC to EVCC which is 6:30+01:00

@lsiepel Let me know if i can test anything, would be glad to help.
You say, the binding uses the Timezone of the running process, but as my system time is the same as the openhab timezone, I think the problem really is, that the binding is ignoring any timezone and just sends out the time as if it would be utc. Maybe this is working if the System is set to utc...

@Laith-Budairi
Copy link
Contributor

Laith-Budairi commented Oct 27, 2024

@tmsch13 I tried to fix it in the binding and I have a jar file, would you like to test it out and see if it works in your time zone?

jar file: https://files.fm/u/wdfevpaa9g

Laith-Budairi pushed a commit to Laith-Budairi/openhab-addons that referenced this issue Oct 27, 2024
Laith-Budairi pushed a commit to Laith-Budairi/openhab-addons that referenced this issue Oct 27, 2024
Laith-Budairi pushed a commit to Laith-Budairi/openhab-addons that referenced this issue Oct 27, 2024
…#17620)

Signed-off-by: Laith Budairi <laith.budairi@exalt.ps>
@tmsch13
Copy link
Author

tmsch13 commented Oct 28, 2024

Just tested the jar and can confirm, that times are now send correctly to evcc. Thanks very much :)

Nevertheless if i edit chardplan time or target SOC in EVCC, the binding seems not to get the new values... But thats maybe another bug and not as important for me as i just want to send plans from OH to EVCC

@lucaarn
Copy link
Contributor

lucaarn commented Oct 28, 2024

Hi @lucaarn,

Can you share your insights on this?

Sorry for not responding. Recently I have some uni and private stuff to do.
I hope you can fix/fixed this bug🙏

@Laith-Budairi
Copy link
Contributor

Hi @lucaarn,
Can you share your insights on this?

Sorry for not responding. Recently I have some uni and private stuff to do. I hope you can fix/fixed this bug🙏

no worries, thank you

@Laith-Budairi
Copy link
Contributor

Just tested the jar and can confirm, that times are now send correctly to evcc. Thanks very much :)

Nevertheless if i edit chardplan time or target SOC in EVCC, the binding seems not to get the new values... But thats maybe another bug and not as important for me as i just want to send plans from OH to EVCC

good to hear!

lsiepel pushed a commit that referenced this issue Oct 28, 2024
…#17640)

Signed-off-by: Laith Budairi <laith.budairi@exalt.ps>
KaaNee pushed a commit to KaaNee/openhab-addons that referenced this issue Nov 8, 2024
matchews pushed a commit to matchews/openhab-addons that referenced this issue Dec 16, 2024
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this issue Jan 2, 2025
…#17620) (openhab#17640)

Signed-off-by: Laith Budairi <laith.budairi@exalt.ps>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants