jonasbkarlsson / ev_smart_charging

Electric vehicle smart charging for Home Assistant.
MIT License
139 stars 19 forks source link

Charging switch not found on startup with HA 2023.8 #198

Closed ronajon closed 9 months ago

ronajon commented 10 months ago

Version of the custom_component

Version 1.8.0

Configuration

Tesla custom integration 3.16.1

Describe the bug

on restart of homeassistant, the EV Smart Charging integration is unable to find the Charger Control Switch , the EV Charging panel is then disabled The switch is the Tesla charger switch, named _switch.mario_kartcharger

When reloading the integration (after initial startup) the switch is found and the EV Charging panel is active again

Debug log


2023-09-06 22:37:33.868 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ev_smart_charging which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-06 22:37:33.873 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration tesla_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-06 22:37:36.997 DEBUG (MainThread) [custom_components.ev_smart_charging] 
-------------------------------------------------------------------
EV Smart Charging
Version: v1.8.0
This is a custom integration!
If you have any issues with this you need to open an issue here:
https://github.com/jonasbkarlsson/ev_smart_charging/issues
Home Assistant: 2023.8.3
-------------------------------------------------------------------

2023-09-06 22:37:36.998 DEBUG (MainThread) [custom_components.ev_smart_charging] Input sensors not ready.
2023-09-06 22:37:43.348 ERROR (MainThread) [homeassistant.components.tibber.sensor] Unexpected error fetching Tibber ronald jonkman data: 'tibber:energy_consumption_b870bd68c5b74e36868ea587925d3c68'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/tibber/sensor.py", line 583, in _async_update_data
    await self._insert_statistics()
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/components/tibber/sensor.py", line 647, in _insert_statistics
    first_stat = stat[statistic_id][0]
                 ~~~~^^^^^^^^^^^^^^
KeyError: 'tibber:energy_consumption_b870bd68c5b74e36868ea587925d3c68'
2023-09-06 22:37:50.871 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartCharging.switch.py
2023-09-06 22:37:50.871 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitchActive.__init__()
2023-09-06 22:37:50.871 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitch.__init__()
2023-09-06 22:37:50.871 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitchApplyLimit.__init__()
2023-09-06 22:37:50.871 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitch.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitchContinuous.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitch.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitchEVConnected.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitch.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitchKeepOn.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitch.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitchOpportunistic.__init__()
2023-09-06 22:37:50.872 DEBUG (MainThread) [custom_components.ev_smart_charging.switch] EVSmartChargingSwitch.__init__()
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_active_update = True
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_apply_limit_update = False
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.888 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_continuous_update = False
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_ev_connected_update = True
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.889 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.890 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_keep_on_update = False
2023-09-06 22:37:50.890 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.890 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.890 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.890 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] switch_opportunistic_update = False
2023-09-06 22:37:50.890 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.891 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.891 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.917 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform ev_smart_charging
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
    await asyncio.gather(*tasks)
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 1003, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/switch.py", line 66, in async_added_to_hass
    await self.async_turn_on()
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/switch.py", line 87, in async_turn_on
    await self.coordinator.switch_active_update(True)
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/coordinator.py", line 388, in switch_active_update
    await self.update_configuration()
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/coordinator.py", line 513, in update_configuration
    await self.update_sensors(configuration_updated=True)
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/coordinator.py", line 534, in update_sensors
    price_state = self.hass.states.get(self.price_entity_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/core.py", line 1505, in get
    return self._states.get(entity_id.lower())
                            ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'
2023-09-06 22:37:50.958 DEBUG (MainThread) [custom_components.ev_smart_charging.sensor] EVSmartCharging.sensor.py
2023-09-06 22:37:50.958 DEBUG (MainThread) [custom_components.ev_smart_charging.sensor] EVSmartChargingSensor.__init__()
2023-09-06 22:37:50.958 DEBUG (MainThread) [custom_components.ev_smart_charging.sensor] EVSmartChargingSensor.__init__()
2023-09-06 22:37:50.958 DEBUG (MainThread) [custom_components.ev_smart_charging.sensor] EVSmartChargingSensorStatus.__init__()
2023-09-06 22:37:50.958 DEBUG (MainThread) [custom_components.ev_smart_charging.sensor] EVSmartChargingSensor.__init__()
2023-09-06 22:37:50.959 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:50.959 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:50.959 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:50.962 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] charging_hours = 12
2023-09-06 22:37:50.963 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] ready_hour = 2023-09-07 06:00:00+00:00
2023-09-06 22:37:50.966 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] lowest_hours = [22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
2023-09-06 22:37:50.970 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 10
2023-09-06 22:37:50.970 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-09-06 22:37:50.970 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-09-06 22:37:50.985 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.0
2023-09-06 22:37:50.985 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.3019
2023-09-06 22:37:50.985 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-09-06 22:37:50.986 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.30179999999999996
2023-09-06 22:37:50.986 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-09-06 22:37:50.986 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = False
2023-09-06 22:37:50.986 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Turn on charging
2023-09-06 22:37:50.986 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Before service call switch.turn_on: switch.mario_kart_charger
2023-09-06 22:37:50.986 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown
2023-09-06 22:37:51.014 DEBUG (MainThread) [custom_components.ev_smart_charging.button] EVSmartCharging.button.py
2023-09-06 22:37:51.014 DEBUG (MainThread) [custom_components.ev_smart_charging.button] EVSmartChargingButton.__init__()
2023-09-06 22:37:51.014 DEBUG (MainThread) [custom_components.ev_smart_charging.button] self._attr_unique_id = e82aa77835f1f09754e9364045fa72e2.button.manuallystartcharging
2023-09-06 22:37:51.014 DEBUG (MainThread) [custom_components.ev_smart_charging.button] EVSmartChargingButton.__init__()
2023-09-06 22:37:51.014 DEBUG (MainThread) [custom_components.ev_smart_charging.button] self._attr_unique_id = e82aa77835f1f09754e9364045fa72e2.button.manuallystopcharging
2023-09-06 22:37:51.015 ERROR (MainThread) [homeassistant.components.switch] Error while setting up ev_smart_charging platform for switch
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 370, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
    await asyncio.gather(*tasks)
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/helpers/entity.py", line 1003, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/switch.py", line 66, in async_added_to_hass
    await self.async_turn_on()
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/switch.py", line 87, in async_turn_on
    await self.coordinator.switch_active_update(True)
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/coordinator.py", line 388, in switch_active_update
    await self.update_configuration()
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/coordinator.py", line 513, in update_configuration
    await self.update_sensors(configuration_updated=True)
  File "/home/homeassistant/.homeassistant/custom_components/ev_smart_charging/coordinator.py", line 534, in update_sensors
    price_state = self.hass.states.get(self.price_entity_id)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/core.py", line 1505, in get
    return self._states.get(entity_id.lower())
                            ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartCharging.number.py
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumberChargingSpeed.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumberPriceLimit.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumberMinSOC.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumberOpportunistic.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.__init__()
2023-09-06 22:37:51.028 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumberOpportunistic.__init__() 50.0
2023-09-06 22:37:51.063 DEBUG (MainThread) [custom_components.ev_smart_charging.select] EVSmartCharging.select.py
2023-09-06 22:37:51.063 DEBUG (MainThread) [custom_components.ev_smart_charging.select] EVSmartChargingSelectReadyHour.__init__()
2023-09-06 22:37:51.063 DEBUG (MainThread) [custom_components.ev_smart_charging.select] EVSmartChargingSelect.__init__()
2023-09-06 22:37:51.063 DEBUG (MainThread) [custom_components.ev_smart_charging.select] EVSmartChargingSelectReadyHour.__init__()
2023-09-06 22:37:51.063 DEBUG (MainThread) [custom_components.ev_smart_charging.select] EVSmartChargingSelect.__init__()
2023-09-06 22:37:51.073 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.async_added_to_hass()
2023-09-06 22:37:51.073 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:51.073 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:51.073 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:51.079 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 10
2023-09-06 22:37:51.079 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
2023-09-06 22:37:51.079 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Use schedule
2023-09-06 22:37:51.081 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] self._max_price = 0.0
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Current price = 0.3019
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_state()
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] charging_value = 0.30179999999999996
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] turn_on_charging = True
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] current_value = True
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] Charging summary shown
2023-09-06 22:37:51.082 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.async_added_to_hass() 23.0
2023-09-06 22:37:51.083 DEBUG (MainThread) [custom_components.ev_smart_charging.number] EVSmartChargingNumber.async_added_to_hass()
2023-09-06 22:37:51.083 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] EVSmartChargingCoordinator.update_sensors()
2023-09-06 22:37:51.083 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] entity_id = None
2023-09-06 22:37:51.083 DEBUG (MainThread) [custom_components.ev_smart_charging.coordinator] new_state = None
2023-09-06 22:37:51.088 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule).number_of_nonzero() = 10
2023-09-06 22:37:51.088 DEBUG (MainThread) [custom_components.ev_smart_charging.helpers.coordinator] Raw(schedule_min_soc).number_of_nonzero() = 0
jonasbkarlsson commented 10 months ago

Thanks for the report. Actually, this issue is most likely solved by #190 and available in the pre-release v1.9.0-dev2.

I have a few more changes I want to make before publishing the next release, but hopefully within a few days.

ThomasMidgley commented 10 months ago

Hi, `` I have a similar issue. It seems my switch is not being saved after I have set it up.

I'm trying to set up the integration with a polestar and Etrel Inch charger. Using automations I can set the switch "ev_smart_charging_ev_connected" properly. If I activate smart charging, the intervals are being calculated and displayed on the graph, so that's working also.

I configured a switch to control the charger:

switch:
  - platform: template
    switches:
      car_charger_control_switch:
        friendly_name: "Car Charger Control Switch"
        turn_on:
          service: modbus.write_register
          data:
            address: 10         # Connector 1 -  Cancel current setpoint , max value
            slave: 255
            value: 1            # Value ignored, triggered by write
            hub: etrel_inch
        turn_off:
          service: modbus.write_register
          data:
            address: 2          # Connector 1 -  Pause charging
            slave: 255
            value: 0            # Value ignored, triggered by write
            hub: etrel_inch

using this switch I can manually stop and start the charging.

Still the integration does not start or stop the charging when it should. What seems odd to me, is that the switch is not being displayed in the configuration after I set it up. Could it be it's not properly being saved?

image

jonasbkarlsson commented 10 months ago

@ThomasMidgley, what you describe sounds like the issue that #190 should fix. You can try the pre-release, or wait a day or two until I will release v1.9.0.

jonasbkarlsson commented 9 months ago

Fixed in release v1.9.0.

ThomasMidgley commented 9 months ago

@jonasbkarlsson, thanks for the help. I've tested with v1.9.0 and I'm still getting "Charger control switch entity not found" I've deleted the whole integration and downloaded it again, just be sure.

jonasbkarlsson commented 9 months ago

Hi! Sorry, now I see the problem. This is different from #190.

The integration currently only supports native switch entities. It does not support template switches.

The way to make it work is to use two automations, such as https://github.com/jonasbkarlsson/ev_smart_charging#example-of-automation-to-start-charging and https://github.com/jonasbkarlsson/ev_smart_charging#example-of-automation-to-stop-charging. And to replace the actionwith service call to switch.turn_on and switch.turn_off.

Something like the following for the automation that turns on charging.

action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.car_charger_control_switch
ThomasMidgley commented 9 months ago

@jonasbkarlsson, sorry to keep spamming this closed issue. In the beginning I've started with automations, but I can't seem to set it up properly. Hence I tried using a virtual switch.

setting the switch switch.ev_smart_charging_ev_connected works as it should. But I can't seem to trigger the charging.

A penny for your thoughs....

# Doorgeven aan EV Smart Charging dat auto verbonden is
- alias: EV Smart Charging - car connection status
  description: ""
  mode: single
  trigger:
    - platform: state
      entity_id:
        - sensor.Etrel_connection_status
  condition: []
  action:
  - if:
      - condition: state
        entity_id: sensor.Etrel_connection_status
        state: "4"      # Charging

    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.ev_smart_charging_ev_connected
    else:
      - if:
          - condition: state
            entity_id: sensor.Etrel_connection_status
            state: "1"          # socket available
        then:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.ev_smart_charging_ev_connected

# AUG 2023: AAN/AF schakelen laadpaal
- alias: EV Smart Charging - Start
  description: ""
  mode: single
  trigger:
    - platform: state
      entity_id:
        - sensor.ev_smart_charging_charging
      from: "off"
      to: "on"
  condition: []
  action:
  - service: modbus.write_register
    data:
      address: 10         # Connector 1 -  Cancel current setpoint, revert back to maximum
      slave: 255
      value: 1            # Value ignored, triggered by write
      hub: etrel_inch

- alias: EV Smart Charging - Stop
  description: ""
  mode: single
  trigger:
    - platform: state
      entity_id:
        - sensor.ev_smart_charging_charging
      from: "on"
      to: "off"
  condition: []
  action:
  - service: modbus.write_register
    data:
      address: 2          # Connector 1 -  Pause charging
      slave: 255
      value: 0            # Value ignored, triggered by write
      hub: etrel_inch
jonasbkarlsson commented 9 months ago

I would first disable the automation EV Smart Charging - car connection status, and then do the Verifying the configuration.

If that doesn't work, then I would suspect that there are some issues with the modbus parts.

Regarding the automation EV Smart Charging - car connection status, is it so that state: "1" # socket available means that the cable is disconnected? Which is the case when switch.ev_smart_charging_ev_connected should be turned off.

Or do you also get state "1" when the cable is connected, but there is no charging active?

ThomasMidgley commented 9 months ago

Hi @jonasbkarlsson,

I believe I found my issue. There seems to be a different how to write a hex value between lovelance and the automations. Hex values are used in the Modbus command.

I'm now able to do the verification of the configuration. I can control the charging with the press buttons. Will try to charge automatically this night.

Thanks for the help and keep up your nice work!