jonasbkarlsson / ev_smart_charging

Electric vehicle smart charging for Home Assistant.
MIT License
171 stars 25 forks source link

Time offset by timezone? #146

Closed tobixx closed 1 year ago

tobixx commented 1 year ago

Hi,

the graph indicates that the charging should have been started already:

time_offset

but not yet started as seen in the state.

Data indicates a one hour offset in opposite to the graph:

current_price: 0.131
EV SOC: 70
EV target SOC: 100
Charging status: Waiting for charging to begin
Charging is planned: true
Charging start time: 2023-03-03T11:00:00+01:00
Charging stop time: 2023-03-03T16:00:00+01:00
Charging number of hours: 5
raw_two_days: 
- start: '2023-03-03T00:00:00+01:00'
  end: '2023-03-03T01:00:00+01:00'
  value: 0.14
- start: '2023-03-03T01:00:00+01:00'
  end: '2023-03-03T02:00:00+01:00'
  value: 0.13
- start: '2023-03-03T02:00:00+01:00'
  end: '2023-03-03T03:00:00+01:00'
  value: 0.131
- start: '2023-03-03T03:00:00+01:00'
  end: '2023-03-03T04:00:00+01:00'
  value: 0.128
- start: '2023-03-03T04:00:00+01:00'
  end: '2023-03-03T05:00:00+01:00'
  value: 0.128
- start: '2023-03-03T05:00:00+01:00'
  end: '2023-03-03T06:00:00+01:00'
  value: 0.135
- start: '2023-03-03T06:00:00+01:00'
  end: '2023-03-03T07:00:00+01:00'
  value: 0.162
- start: '2023-03-03T07:00:00+01:00'
  end: '2023-03-03T08:00:00+01:00'
  value: 0.187
- start: '2023-03-03T08:00:00+01:00'
  end: '2023-03-03T09:00:00+01:00'
  value: 0.195
- start: '2023-03-03T09:00:00+01:00'
  end: '2023-03-03T10:00:00+01:00'
  value: 0.166
- start: '2023-03-03T10:00:00+01:00'
  end: '2023-03-03T11:00:00+01:00'
  value: 0.131
- start: '2023-03-03T11:00:00+01:00'
  end: '2023-03-03T12:00:00+01:00'
  value: 0.123
- start: '2023-03-03T12:00:00+01:00'
  end: '2023-03-03T13:00:00+01:00'
  value: 0.115
- start: '2023-03-03T13:00:00+01:00'
  end: '2023-03-03T14:00:00+01:00'
  value: 0.112
- start: '2023-03-03T14:00:00+01:00'
  end: '2023-03-03T15:00:00+01:00'
  value: 0.111
- start: '2023-03-03T15:00:00+01:00'
  end: '2023-03-03T16:00:00+01:00'
  value: 0.115
- start: '2023-03-03T16:00:00+01:00'
  end: '2023-03-03T17:00:00+01:00'
  value: 0.129
- start: '2023-03-03T17:00:00+01:00'
  end: '2023-03-03T18:00:00+01:00'
  value: 0.156
- start: '2023-03-03T18:00:00+01:00'
  end: '2023-03-03T19:00:00+01:00'
  value: 0.165
- start: '2023-03-03T19:00:00+01:00'
  end: '2023-03-03T20:00:00+01:00'
  value: 0.153
- start: '2023-03-03T20:00:00+01:00'
  end: '2023-03-03T21:00:00+01:00'
  value: 0.133
- start: '2023-03-03T21:00:00+01:00'
  end: '2023-03-03T22:00:00+01:00'
  value: 0.122
- start: '2023-03-03T22:00:00+01:00'
  end: '2023-03-03T23:00:00+01:00'
  value: 0.112
- start: '2023-03-03T23:00:00+01:00'
  end: '2023-03-04T00:00:00+01:00'
  value: 0.102

charging_schedule: 
- start: '2023-03-03T00:00:00+01:00'
  end: '2023-03-03T01:00:00+01:00'
  value: 0
- start: '2023-03-03T01:00:00+01:00'
  end: '2023-03-03T02:00:00+01:00'
  value: 0
- start: '2023-03-03T02:00:00+01:00'
  end: '2023-03-03T03:00:00+01:00'
  value: 0
- start: '2023-03-03T03:00:00+01:00'
  end: '2023-03-03T04:00:00+01:00'
  value: 0
- start: '2023-03-03T04:00:00+01:00'
  end: '2023-03-03T05:00:00+01:00'
  value: 0
- start: '2023-03-03T05:00:00+01:00'
  end: '2023-03-03T06:00:00+01:00'
  value: 0
- start: '2023-03-03T06:00:00+01:00'
  end: '2023-03-03T07:00:00+01:00'
  value: 0
- start: '2023-03-03T07:00:00+01:00'
  end: '2023-03-03T08:00:00+01:00'
  value: 0
- start: '2023-03-03T08:00:00+01:00'
  end: '2023-03-03T09:00:00+01:00'
  value: 0
- start: '2023-03-03T09:00:00+01:00'
  end: '2023-03-03T10:00:00+01:00'
  value: 0
- start: '2023-03-03T10:00:00+01:00'
  end: '2023-03-03T11:00:00+01:00'
  value: 0
- start: '2023-03-03T11:00:00+01:00'
  end: '2023-03-03T12:00:00+01:00'
  value: 0.14625
- start: '2023-03-03T12:00:00+01:00'
  end: '2023-03-03T13:00:00+01:00'
  value: 0.14625
- start: '2023-03-03T13:00:00+01:00'
  end: '2023-03-03T14:00:00+01:00'
  value: 0.14625
- start: '2023-03-03T14:00:00+01:00'
  end: '2023-03-03T15:00:00+01:00'
  value: 0.14625
- start: '2023-03-03T15:00:00+01:00'
  end: '2023-03-03T16:00:00+01:00'
  value: 0.14625
- start: '2023-03-03T16:00:00+01:00'
  end: '2023-03-03T17:00:00+01:00'
  value: 0
- start: '2023-03-03T17:00:00+01:00'
  end: '2023-03-03T18:00:00+01:00'
  value: 0
- start: '2023-03-03T18:00:00+01:00'
  end: '2023-03-03T19:00:00+01:00'
  value: 0
- start: '2023-03-03T19:00:00+01:00'
  end: '2023-03-03T20:00:00+01:00'
  value: 0
- start: '2023-03-03T20:00:00+01:00'
  end: '2023-03-03T21:00:00+01:00'
  value: 0
- start: '2023-03-03T21:00:00+01:00'
  end: '2023-03-03T22:00:00+01:00'
  value: 0
- start: '2023-03-03T22:00:00+01:00'
  end: '2023-03-03T23:00:00+01:00'
  value: 0
- start: '2023-03-03T23:00:00+01:00'
  end: '2023-03-04T00:00:00+01:00'
  value: 0
jonasbkarlsson commented 1 year ago

Hi! Seems like the screenshots are taken about 10:50. Is that correct? The charging is planned to start 11:00, so it seems correct that charging has not started.

I have struggled a bit to make the Apexcharts-card example. How about the following? Note that I added offset: '-30min'.

      - entity: sensor.ev_smart_charging_charging
        name: Charging
        data_generator: >
          return entity.attributes.charging_schedule.map((entry) => { return
          [new Date(entry.start), entry.value]; });
        type: area
        color: black
        offset: '-30min'
        show:
          in_header: false
        extend_to: false

You might want to replace the type: area with type: column to make it clearer.

One problem with this is that when you point at the graph, the pop-up that appears will show starting time incorrectly by 30 minutes.

tobixx commented 1 year ago

Thanks, for the reply!

Ok - if I understand correctly the: the raising flank is due to the area type - so my impression was just wrong that the start time of the flank (10:00) shows also the start of the charging - so basically my fault of misinterpreting it.

And yes: screenshot was taken just in front of of 11:00.

Your suggestion of using type column instead will probably eliminate the confusion. Will try that next week.

Thanks for clarifying!

Have a nice weekend!

AMajland commented 8 months ago

First - the intergration works as expected. I'm just trying to get apexchart to visualize it a bit better.

Current schedule

Charging start time: 2024-01-26T04:00:00+01:00 Charging stop time: 2024-01-26T06:00:00+01:00

Currently i have image Based on type: area curve: stepline

I have tried with different apexchart types but cant get it just right

type: column

image

Anybody got a better visualization ?

AMajland commented 8 months ago

image

Played a bit more

Schedule with type: area curve: stepline stroke_width: 1 annd the price with type: line #column curve: stepline stroke_width: 4

is probably the best i can come up with ....