jonasbkarlsson / ev_smart_charging

Electric vehicle smart charging for Home Assistant.
MIT License
182 stars 27 forks source link

Charging stops at midnight and restarts at 1 a.m. #229

Closed petermnt closed 3 months ago

petermnt commented 11 months ago

Version of the custom_component

Version 1.9.0

Configuration

Apply price limit: on Continuous charging preferred: on Charge start time: None Charge end time: None Limit: 80% Minimum EV Soc: 35%

Describe the bug

When a charging is planned from before midnight, the charging stops at midnight and continues at 1 o'clock. When the charging is supposed to start at midnight, it doesn't start.

Debug log

2023-12-01 20:13:42.435 INFO (MainThread) [homeassistant.components.automation.ev_smart_charging_connected] EV Smart Charging - Connected: Running automation actions
2023-12-01 20:13:42.436 INFO (MainThread) [homeassistant.components.automation.ev_smart_charging_connected] EV Smart Charging - Connected: If at step 1: Running automation actions
2023-12-01 20:13:42.436 INFO (MainThread) [homeassistant.components.automation.ev_smart_charging_connected] EV Smart Charging - Connected: If at step 1: Executing step call service
2023-12-01 20:13:42.437 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_ev_connected_update = True
2023-12-01 20:13:42.437 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 20:13:42.437 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-12-01 20:13:42.437 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-12-01 20:13:42.439 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours = 11
2023-12-01 20:13:42.440 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-12-03 23:00:00+00:00
2023-12-01 20:13:42.440 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours = [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
2023-12-01 20:13:42.440 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours_min_soc = 0
2023-12-01 20:13:42.440 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-12-03 23:00:00+00:00
2023-12-01 20:13:42.440 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours_min_soc = []
2023-12-01 20:13:42.443 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 20:13:42.443 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 20:13:42.443 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 20:13:42.443 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 20:13:42.443 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.14227
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.0
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = False
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Turn off charging
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Before service call switch.turn_off: switch.kermit_charger
2023-12-01 20:13:42.444 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

2023-12-01 21:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_hourly()
2023-12-01 21:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 21:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-12-01 21:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-12-01 21:00:00.090 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours = 11
2023-12-01 21:00:00.090 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-12-03 23:00:00+00:00
2023-12-01 21:00:00.090 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours = [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
2023-12-01 21:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours_min_soc = 0
2023-12-01 21:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-12-03 23:00:00+00:00
2023-12-01 21:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours_min_soc = []
2023-12-01 21:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 21:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 21:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.12507
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.0
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = False
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False
2023-12-01 21:00:00.095 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

2023-12-01 22:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_hourly()
2023-12-01 22:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 22:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-12-01 22:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-12-01 22:00:00.090 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours = 11
2023-12-01 22:00:00.090 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-12-03 23:00:00+00:00
2023-12-01 22:00:00.090 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours = [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
2023-12-01 22:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours_min_soc = 0
2023-12-01 22:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-12-03 23:00:00+00:00
2023-12-01 22:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours_min_soc = []
2023-12-01 22:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 22:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 22:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 22:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 22:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.1182
2023-12-01 22:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 22:00:00.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.0
2023-12-01 22:00:00.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = False
2023-12-01 22:00:00.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False
2023-12-01 22:00:00.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

2023-12-01 23:00:00.087 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_hourly()
2023-12-01 23:00:00.087 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 23:00:00.087 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-12-01 23:00:00.087 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-12-01 23:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 23:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 23:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 23:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 23:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.1081
2023-12-01 23:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 23:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-01 23:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-12-01 23:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False
2023-12-01 23:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Turn on charging
2023-12-01 23:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Before service call switch.turn_on: switch.kermit_charger
2023-12-01 23:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown
2023-12-01 23:00:30.253 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 23:00:30.253 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = sensor.tesla_battery_level
2023-12-01 23:00:30.253 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = <state sensor.tesla_battery_level=48; unit_of_measurement=%, icon=mdi:battery-80, friendly_name=Battery Level @ 2023-12-01T23:00:30.253184+01:00>
2023-12-01 23:00:30.257 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 23:00:30.257 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 23:00:30.257 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 23:00:30.258 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 23:00:30.259 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.1081
2023-12-01 23:00:30.259 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 23:00:30.259 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-01 23:00:30.259 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-12-01 23:00:30.259 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-12-01 23:00:30.259 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

2023-12-01 23:25:14.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 23:25:14.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = sensor.tesla_battery_level
2023-12-01 23:25:14.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = <state sensor.tesla_battery_level=49; unit_of_measurement=%, icon=mdi:battery-80, friendly_name=Battery Level @ 2023-12-01T23:25:14.093209+01:00>
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.1081
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-12-01 23:25:14.097 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

...

2023-12-01 23:53:13.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 23:53:13.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = sensor.tesla_battery_level
2023-12-01 23:53:13.094 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = <state sensor.tesla_battery_level=49; unit_of_measurement=%, icon=mdi:battery-80, friendly_name=Battery Level @ 2023-12-01T23:53:13.091351+01:00>
2023-12-01 23:53:13.097 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 23:53:13.097 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 23:53:13.097 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.1081
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-12-01 23:53:13.098 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown
2023-12-01 23:53:33.279 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-01 23:53:33.279 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = sensor.tesla_battery_level
2023-12-01 23:53:33.279 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = <state sensor.tesla_battery_level=50; unit_of_measurement=%, icon=mdi:battery-80, friendly_name=Battery Level @ 2023-12-01T23:53:33.278215+01:00>
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.1081
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-01 23:53:33.282 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-12-01 23:53:33.283 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-12-01 23:53:33.283 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

2023-12-02 00:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_hourly()
2023-12-02 00:00:00.089 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-02 00:00:00.089 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-12-02 00:00:00.089 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-12-02 00:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-02 00:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-02 00:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = None
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = False
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Turn off charging
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Before service call switch.turn_off: switch.kermit_charger
2023-12-02 00:00:00.093 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown

2023-12-02 01:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_hourly()
2023-12-02 01:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-02 01:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-12-02 01:00:00.088 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = None
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-02 01:00:00.091 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.1724775
2023-12-02 01:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = False
2023-12-02 01:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False
2023-12-02 01:00:00.092 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown
2023-12-02 01:00:00.936 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-12-02 01:00:00.936 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = sensor.average_electricity_price_today
2023-12-02 01:00:00.936 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = <state sensor.average_electricity_price_today=0.13647; state_class=measurement, prices_today=[{'time': '2023-12-02 00:00:00+01:00', 'price': 0.10552}, {'time': '2023-12-02 01:00:00+01:00', 'price': 0.10312}, {'time': '2023-12-02 02:00:00+01:00', 'price': 0.10241}, {'time': '2023-12-02 03:00:00+01:00', 'price': 0.10019}, {'time': '2023-12-02 04:00:00+01:00', 'price': 0.09878}, {'time': '2023-12-02 05:00:00+01:00', 'price': 0.09817}, {'time': '2023-12-02 06:00:00+01:00', 'price': 0.09926}, {'time': '2023-12-02 07:00:00+01:00', 'price': 0.10577}, {'time': '2023-12-02 08:00:00+01:00', 'price': 0.12034}, {'time': '2023-12-02 09:00:00+01:00', 'price': 0.12799}, {'time': '2023-12-02 10:00:00+01:00', 'price': 0.13075}, {'time': '2023-12-02 11:00:00+01:00', 'price': 0.12692}, {'time': '2023-12-02 12:00:00+01:00', 'price': 0.12106}, {'time': '2023-12-02 13:00:00+01:00', 'price': 0.11458}, {'time': '2023-12-02 14:00:00+01:00', 'price': 0.11852}, {'time': '2023-12-02 15:00:00+01:00', 'price': 0.1235}, {'time': '2023-12-02 16:00:00+01:00', 'price': 0.12979}, {'time': '2023-12-02 17:00:00+01:00', 'price': 0.14415}, {'time': '2023-12-02 18:00:00+01:00', 'price': 0.14501}, {'time': '2023-12-02 19:00:00+01:00', 'price': 0.12968}, {'time': '2023-12-02 20:00:00+01:00', 'price': 0.12268}, {'time': '2023-12-02 21:00:00+01:00', 'price': 0.11713}, {'time': '2023-12-02 22:00:00+01:00', 'price': 0.11246}, {'time': '2023-12-02 23:00:00+01:00', 'price': 0.10881}], prices_tomorrow=[], prices=[{'time': '2023-12-01 00:00:00+01:00', 'price': 0.10691}, {'time': '2023-12-01 01:00:00+01:00', 'price': 0.10263}, {'time': '2023-12-01 02:00:00+01:00', 'price': 0.0991}, {'time': '2023-12-01 03:00:00+01:00', 'price': 0.09588}, {'time': '2023-12-01 04:00:00+01:00', 'price': 0.09607}, {'time': '2023-12-01 05:00:00+01:00', 'price': 0.10226}, {'time': '2023-12-01 06:00:00+01:00', 'price': 0.11996}, {'time': '2023-12-01 07:00:00+01:00', 'price': 0.15204}, {'time': '2023-12-01 08:00:00+01:00', 'price': 0.2032}, {'time': '2023-12-01 09:00:00+01:00', 'price': 0.22211}, {'time': '2023-12-01 10:00:00+01:00', 'price': 0.21465}, {'time': '2023-12-01 11:00:00+01:00', 'price': 0.21275}, {'time': '2023-12-01 12:00:00+01:00', 'price': 0.19639}, {'time': '2023-12-01 13:00:00+01:00', 'price': 0.17337}, {'time': '2023-12-01 14:00:00+01:00', 'price': 0.17393}, {'time': '2023-12-01 15:00:00+01:00', 'price': 0.18179}, {'time': '2023-12-01 16:00:00+01:00', 'price': 0.19995}, {'time': '2023-12-01 17:00:00+01:00', 'price': 0.22997}, {'time': '2023-12-01 18:00:00+01:00', 'price': 0.19892}, {'time': '2023-12-01 19:00:00+01:00', 'price': 0.1684}, {'time': '2023-12-01 20:00:00+01:00', 'price': 0.14227}, {'time': '2023-12-01 21:00:00+01:00', 'price': 0.12507}, {'time': '2023-12-01 22:00:00+01:00', 'price': 0.1182}, {'time': '2023-12-01 23:00:00+01:00', 'price': 0.1081}, {'time': '2023-12-02 00:00:00+01:00', 'price': 0.10552}, {'time': '2023-12-02 01:00:00+01:00', 'price': 0.10312}, {'time': '2023-12-02 02:00:00+01:00', 'price': 0.10241}, {'time': '2023-12-02 03:00:00+01:00', 'price': 0.10019}, {'time': '2023-12-02 04:00:00+01:00', 'price': 0.09878}, {'time': '2023-12-02 05:00:00+01:00', 'price': 0.09817}, {'time': '2023-12-02 06:00:00+01:00', 'price': 0.09926}, {'time': '2023-12-02 07:00:00+01:00', 'price': 0.10577}, {'time': '2023-12-02 08:00:00+01:00', 'price': 0.12034}, {'time': '2023-12-02 09:00:00+01:00', 'price': 0.12799}, {'time': '2023-12-02 10:00:00+01:00', 'price': 0.13075}, {'time': '2023-12-02 11:00:00+01:00', 'price': 0.12692}, {'time': '2023-12-02 12:00:00+01:00', 'price': 0.12106}, {'time': '2023-12-02 13:00:00+01:00', 'price': 0.11458}, {'time': '2023-12-02 14:00:00+01:00', 'price': 0.11852}, {'time': '2023-12-02 15:00:00+01:00', 'price': 0.1235}, {'time': '2023-12-02 16:00:00+01:00', 'price': 0.12979}, {'time': '2023-12-02 17:00:00+01:00', 'price': 0.14415}, {'time': '2023-12-02 18:00:00+01:00', 'price': 0.14501}, {'time': '2023-12-02 19:00:00+01:00', 'price': 0.12968}, {'time': '2023-12-02 20:00:00+01:00', 'price': 0.12268}, {'time': '2023-12-02 21:00:00+01:00', 'price': 0.11713}, {'time': '2023-12-02 22:00:00+01:00', 'price': 0.11246}, {'time': '2023-12-02 23:00:00+01:00', 'price': 0.10881}], unit_of_measurement=€/kWh, attribution=Data provided by ENTSO-e Transparency Platform, device_class=monetary, icon=mdi:currency-eur, friendly_name=Average electricity price today @ 2023-12-01T14:00:00.870643+01:00>
2023-12-02 01:00:00.939 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 9
2023-12-02 01:00:00.939 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-12-02 01:00:00.939 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.11
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.10312
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.10875750000000001
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Turn on charging
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Before service call switch.turn_on: switch.kermit_charger
2023-12-02 01:00:00.940 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown
bartashevich commented 9 months ago

This happens to me too. But for me is at 11PM and resumes at midnight. I think this has to do with Timezone and pricing. In ev_smart_charging addon I would see that price is Unknown in that interval.

jonasbkarlsson commented 9 months ago

@petermnt and @bartashevich, In which time zone are in (HA->Settings->System->General->Time zone)? Which price source do you use? Which type of HA installation do you use (HA OS, Container, Core or Supervised)?

petermnt commented 9 months ago

@jonasbkarlsson Time zone: Europe/Brussels Installation type: HA OS as VM (OVA) Price source: This I think is the source of the problem. When using nordpool there seems to be no issue. The issue only exists with Entso-e. I recently went back to Nordpool and the problem seems to have disappeared again.

I think Entso-e has some very short times of being unavailable around the midnight time, when it recalculates the today/tomorrow attributes. And ev_smart_charging tries to update its schedule during this time, which causes charging to stop or not start.

I prefer to use Entso-e though as that one is slightly more reliable for me. But I'm not sure if it's the job of ev_smart_charging to handle the 'bad' behaviour of the Entso-e integration. Although if there's an easy safety check to avoid this, it would be great of course.

zurajm commented 9 months ago

Just confirming that I'm observing exactly the same issue. Charging stops at midnight and resumes at 01:00. I'm using Entso-e.

bartashevich commented 9 months ago

I'm at London timezone and using Entso-e. I've fixed this in the past, I'll try to remember what have I done.

bartashevich commented 9 months ago

@jonasbkarlsson

Solution

Change prices_today (only includes todays prices except 11PM) to prices (include all prices including tomorrow if exist):

# ev_smart_charging/helpers/price_adaptor.py
         if self._price_platform == PLATFORM_ENTSOE:
-            return Raw(state.attributes["prices_today"], self._price_platform)
+            return Raw(state.attributes["prices"], self._price_platform)

         if price_platform == PLATFORM_ENTSOE:
-            if not "prices_today" in price_state.attributes.keys():
+            if not "prices" in price_state.attributes.keys():

Remove extend, since tomorrow prices are already included in raw_today_local from previous statement.

# ev_smart_charging/coordinator.py
             # Change to UTC time
             self.raw_two_days = self.raw_today_local.copy().to_utc()
-            self.raw_two_days.extend(self.raw_tomorrow_local.copy().to_utc())

Problem

state_class: measurement
prices_today: 
- time: '2024-01-15 23:00:00+00:00'
  price: 0.12488
- time: '2024-01-16 00:00:00+00:00'
  price: 0.12113
- time: '2024-01-16 01:00:00+00:00'
  price: 0.11838
- time: '2024-01-16 02:00:00+00:00'
  price: 0.11575
- time: '2024-01-16 03:00:00+00:00'
  price: 0.1154
- time: '2024-01-16 04:00:00+00:00'
  price: 0.11773
- time: '2024-01-16 05:00:00+00:00'
  price: 0.12305
- time: '2024-01-16 06:00:00+00:00'
  price: 0.12305
- time: '2024-01-16 07:00:00+00:00'
  price: 0.1265
- time: '2024-01-16 08:00:00+00:00'
  price: 0.18128
- time: '2024-01-16 09:00:00+00:00'
  price: 0.18047
- time: '2024-01-16 10:00:00+00:00'
  price: 0.17174
- time: '2024-01-16 11:00:00+00:00'
  price: 0.17325
- time: '2024-01-16 12:00:00+00:00'
  price: 0.16913
- time: '2024-01-16 13:00:00+00:00'
  price: 0.1698
- time: '2024-01-16 14:00:00+00:00'
  price: 0.1675
- time: '2024-01-16 15:00:00+00:00'
  price: 0.16391
- time: '2024-01-16 16:00:00+00:00'
  price: 0.1675
- time: '2024-01-16 17:00:00+00:00'
  price: 0.16867
- time: '2024-01-16 18:00:00+00:00'
  price: 0.17534
- time: '2024-01-16 19:00:00+00:00'
  price: 0.18105
- time: '2024-01-16 20:00:00+00:00'
  price: 0.16836
- time: '2024-01-16 21:00:00+00:00'
  price: 0.15369
- time: '2024-01-16 22:00:00+00:00'
  price: 0.0943

prices_tomorrow: 
- time: '2024-01-16 23:00:00+00:00'
  price: 0.0473
- time: '2024-01-17 00:00:00+00:00'
  price: 0.04362
- time: '2024-01-17 01:00:00+00:00'
  price: 0.0322
- time: '2024-01-17 02:00:00+00:00'
  price: 0.03093
- time: '2024-01-17 03:00:00+00:00'
  price: 0.03093
- time: '2024-01-17 04:00:00+00:00'
  price: 0.03105
- time: '2024-01-17 05:00:00+00:00'
  price: 0.0445
- time: '2024-01-17 06:00:00+00:00'
  price: 0.07613
- time: '2024-01-17 07:00:00+00:00'
  price: 0.07762
- time: '2024-01-17 08:00:00+00:00'
  price: 0.11862
- time: '2024-01-17 09:00:00+00:00'
  price: 0.11782
- time: '2024-01-17 10:00:00+00:00'
  price: 0.106
- time: '2024-01-17 11:00:00+00:00'
  price: 0.08618
- time: '2024-01-17 12:00:00+00:00'
  price: 0.08124
- time: '2024-01-17 13:00:00+00:00'
  price: 0.07217
- time: '2024-01-17 14:00:00+00:00'
  price: 0.07205
- time: '2024-01-17 15:00:00+00:00'
  price: 0.08744
- time: '2024-01-17 16:00:00+00:00'
  price: 0.11632
- time: '2024-01-17 17:00:00+00:00'
  price: 0.11851
- time: '2024-01-17 18:00:00+00:00'
  price: 0.12276
- time: '2024-01-17 19:00:00+00:00'
  price: 0.12941
- time: '2024-01-17 20:00:00+00:00'
  price: 0.12012
- time: '2024-01-17 21:00:00+00:00'
  price: 0.11618
- time: '2024-01-17 22:00:00+00:00'
  price: 0.04603

prices: 
- time: '2024-01-15 23:00:00+00:00'
  price: 0.12488
- time: '2024-01-16 00:00:00+00:00'
  price: 0.12113
- time: '2024-01-16 01:00:00+00:00'
  price: 0.11838
- time: '2024-01-16 02:00:00+00:00'
  price: 0.11575
- time: '2024-01-16 03:00:00+00:00'
  price: 0.1154
- time: '2024-01-16 04:00:00+00:00'
  price: 0.11773
- time: '2024-01-16 05:00:00+00:00'
  price: 0.12305
- time: '2024-01-16 06:00:00+00:00'
  price: 0.12305
- time: '2024-01-16 07:00:00+00:00'
  price: 0.1265
- time: '2024-01-16 08:00:00+00:00'
  price: 0.18128
- time: '2024-01-16 09:00:00+00:00'
  price: 0.18047
- time: '2024-01-16 10:00:00+00:00'
  price: 0.17174
- time: '2024-01-16 11:00:00+00:00'
  price: 0.17325
- time: '2024-01-16 12:00:00+00:00'
  price: 0.16913
- time: '2024-01-16 13:00:00+00:00'
  price: 0.1698
- time: '2024-01-16 14:00:00+00:00'
  price: 0.1675
- time: '2024-01-16 15:00:00+00:00'
  price: 0.16391
- time: '2024-01-16 16:00:00+00:00'
  price: 0.1675
- time: '2024-01-16 17:00:00+00:00'
  price: 0.16867
- time: '2024-01-16 18:00:00+00:00'
  price: 0.17534
- time: '2024-01-16 19:00:00+00:00'
  price: 0.18105
- time: '2024-01-16 20:00:00+00:00'
  price: 0.16836
- time: '2024-01-16 21:00:00+00:00'
  price: 0.15369
- time: '2024-01-16 22:00:00+00:00'
  price: 0.0943
- time: '2024-01-16 23:00:00+00:00'
  price: 0.0473
- time: '2024-01-17 00:00:00+00:00'
  price: 0.04362
- time: '2024-01-17 01:00:00+00:00'
  price: 0.0322
- time: '2024-01-17 02:00:00+00:00'
  price: 0.03093
- time: '2024-01-17 03:00:00+00:00'
  price: 0.03093
- time: '2024-01-17 04:00:00+00:00'
  price: 0.03105
- time: '2024-01-17 05:00:00+00:00'
  price: 0.0445
- time: '2024-01-17 06:00:00+00:00'
  price: 0.07613
- time: '2024-01-17 07:00:00+00:00'
  price: 0.07762
- time: '2024-01-17 08:00:00+00:00'
  price: 0.11862
- time: '2024-01-17 09:00:00+00:00'
  price: 0.11782
- time: '2024-01-17 10:00:00+00:00'
  price: 0.106
- time: '2024-01-17 11:00:00+00:00'
  price: 0.08618
- time: '2024-01-17 12:00:00+00:00'
  price: 0.08124
- time: '2024-01-17 13:00:00+00:00'
  price: 0.07217
- time: '2024-01-17 14:00:00+00:00'
  price: 0.07205
- time: '2024-01-17 15:00:00+00:00'
  price: 0.08744
- time: '2024-01-17 16:00:00+00:00'
  price: 0.11632
- time: '2024-01-17 17:00:00+00:00'
  price: 0.11851
- time: '2024-01-17 18:00:00+00:00'
  price: 0.12276
- time: '2024-01-17 19:00:00+00:00'
  price: 0.12941
- time: '2024-01-17 20:00:00+00:00'
  price: 0.12012
- time: '2024-01-17 21:00:00+00:00'
  price: 0.11618
- time: '2024-01-17 22:00:00+00:00'
  price: 0.04603

unit_of_measurement: €/kWh
attribution: Data provided by ENTSO-e Transparency Platform
device_class: monetary
icon: mdi:currency-eur
friendly_name: Average electricity price today
bartashevich commented 9 months ago

@petermnt and @bartashevich, In which time zone are in (HA->Settings->System->General->Time zone)? Which price source do you use? Which type of HA installation do you use (HA OS, Container, Core or Supervised)?

jonasbkarlsson commented 9 months ago

Thanks a lot @bartashevich for the detailed report and suggestion of solution! I think I have an idea now of what is the root cause of the problem. I will check if I can fix that, or if I take your suggested solution instead.

bartashevich commented 9 months ago

@jonasbkarlsson thanks for taking this in consideration. Mine solution isn't great. I don't know exact logic behind prices for tomorrow in your integration, but that also needs a review, since I'm ignoring that.

jonasbkarlsson commented 3 months ago

Hi all! Sorry for not looking into this sooner. I have made a v1.11.0-dev4 that includes a more robust checking of the price information. I think it might fix this problem. Can anyone of you test this version and let me know if this problem is solved?

jonasbkarlsson commented 3 months ago

This might have been fixed in v1.11.0. I will close this issue now, but please let me know if the problem still exists.