megakid / ha_octopus_intelligent

Apache License 2.0
94 stars 9 forks source link

Timing seems wrong #13

Closed jimmyburnworld closed 1 year ago

jimmyburnworld commented 1 year ago

Hello,

I’ve been monitoring the Intelligent sots and comparing them with my bill and they don’t seem to be reliable enough to use for triggering battery charges. Is this something with my setup? An example would be the 26th Feb, see attached photos.

My bill shows an off peak slot 06:30-07:30 however homeassistant has it at 07:20-08:00

8408A5CD-82E9-4CB6-BEEE-52D332F64424 E4F1ADB8-AD87-417B-91FF-0C68521ADDCC

martindell commented 1 year ago

Same problem here, since the clocks went forward on March 26th, the Octopus smart charging slots have been an hour earlier than reported in the Octopus app. HA has the correct timezone and other apps showing time correctly.

This displays the correct local time: {{ as_timestamp(utcnow()) | timestamp_custom("%I:%M:%S %p %b/%d/%Y") }}

IMG_20230428_212751

Screenshot 2023-04-28 at 21 26 42
nigels0 commented 1 year ago

Looks like the timings are still running on GMT while UK is on BST.

megakid commented 1 year ago

I am not seeing this issue. I have confirmed my time zones (the above template {{ as_timestamp(utcnow()) | timestamp_custom("%I:%M:%S %p %b/%d/%Y") }} outputs correct local time)

@martindell Your one could be explained by wrong timezone handling of the attributes in your custom lovelace view. Please show the raw sensor attributes you're using.

nigels0 commented 1 year ago

You know, I think I made a mistake - I’m looking at the entity in Europe, while the HA server is in the UK. The times were adjusted for European time in HA. Looking at it in the UK, the timings are correct.

My bad. Sorry.

martindell commented 1 year ago

Thanks for looking @megakid I'm not too sure what you mean about 'raw sensor attributes'. Can you point me in the right direction please? I can't double-check the standard integration view at the moment - car is at 100% SOC

megakid commented 1 year ago

Thanks for looking @megakid I'm not too sure what you mean about 'raw sensor attributes'. Can you point me in the right direction please? I can't double-check the standard integration view at the moment - car is at 100% SOC

I can only screenshot my phone at the moment but if you goto the Octopus Intelligent Slot and expand the attributes. You'll see the raw data. I suspect that whatever you copied or setup to display these slots in a nice way (as per your screenshot above) is misinterpreting the time zone and it has only come to light when your local time diverged from UTC.

image

martindell commented 1 year ago

d'oh - of course, sorry - here's my lovelace

{% if (state_attr('binary_sensor.octopus_intelligent_slot', 'plannedDispatches') | length > 0) %} {% for dispatch in state_attr('binary_sensor.octopus_intelligent_slot', 'plannedDispatches') %} ⏰{{': '}} {{ as_datetime(dispatch.startDtUtc).strftime('%H:%M') }} to {{ as_datetime(dispatch.endDtUtc).strftime('%H:%M') }} {% endfor %} {% else %} ⏰ None {% endif %}

I grabbed it from this thread: https://community.home-assistant.io/t/octopus-energy-intelligent-tariff/418680/97 and duncansmart has now amended the time to include 'as_local' to fix this issue

{% if (state_attr('binary_sensor.octopus_intelligent_slot', 'plannedDispatches') | length > 0) %} {% for dispatch in state_attr('binary_sensor.octopus_intelligent_slot', 'plannedDispatches') -%} ⏰ {{ (dispatch.startDtUtc | as_datetime | as_local).strftime('%H:%M') }} to {{ (dispatch.endDtUtc | as_datetime | as_local).strftime('%H:%M') }} {%- endfor %} {%- else -%} ⏰ None {%- endif %}

Sorry for creating noise!