Skip to content

UI: optimizeGridCharge targetTime is not aware of timezones #3146

@iseeberg79

Description

@iseeberg79

Description

Hello,

My operating system is configured to run with UTC and is not set to the local time zone. Everything is working fine and as expected - charging is delayed, and the history diagrams and predictions function correctly.

However, there is a side effect in the UI element that displays the targetTime for the optimizeGridCharge controller. While the graphs correctly show time zone-aware data, the targetTime is printed in UTC. This discrepancy is confusing, as the graphs and targetTime do not use the same time zone.

It appears that the targetTime is two hours earlier than displayed in the UI graphs and controlling behavior. Upon investigation, I realized that the targetTime is displayed in UTC, whereas the graphs are converted to the browser’s local time zone. The graphs show the correct planned behavior, but the displayed targetTime does not adjust accordingly. In any case openEMS controls like displayed by the UI graphs which is correct.

Possible Solution (targetTime is displayed wrong):
It might be an option to gather the targetTime using the epoch time from the edge component:

html (modal.html)

<oe-modal-line *ngIf="targetEpochSeconds && this.delayChargeState !== DelayChargeState.NO_REMAINING_TIME"  
    leftColumnWidth="70" [name]="'Edge.Index.Widgets.GridOptimizedCharge.endTimeLong'| translate"  
    [converter]="CONVERT_EPOCH_TO_LOCAL_TIME" [value]="targetEpochSeconds">  
</oe-modal-line>

Additionally, another converter could be used to process the epoch time correctly:

typescript (modal.ts)

public CONVERT_EPOCH_TO_LOCAL_TIME = (epochSeconds: number): string => {  
  if (!epochSeconds) {  
    return '--';  
  }  
    
  const date = new Date(epochSeconds * 1000);  
  return date.toLocaleTimeString([], {   
    hour: '2-digit',   
    minute: '2-digit',  
    hour12: false   
  });  
};

I am not sure about and experienced enough to fully test and debug these adaptations, but I could provide a draft pull request for review.

Could you please look into this issue?

kind regards,
Ingo

Screenshots

Screenshots:
Image
Image

Operating System

Linux, debian + docker

How to reproduce the Error?

  1. configure optimizeGridchargeController
  2. configure local system (edge/ui) in UTC and the client/browser having local time
  3. let the controller delay charging the ESS storage
  4. setting local time solves the differences

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions