Renault Integration : Add stop charge and stop hvac

Hi,

Is it possible to add to the Renault integration a service / entity to :

  • Stop charging : in core/button.py something like
async def _stop_charge(entity: RenaultButtonEntity) -> None:
    """Stop charge on the vehicle."""
    await entity.vehicle.vehicle.set_charge_stop()
  • Stop Hvac : in core/button.py something like
async def _stop_air_conditioner(entity: RenaultButtonEntity) -> None:
    """Stop air conditioner on the vehicle."""
    await entity.vehicle.vehicle.set_ac_stop()

Note: I don’t know if these lines of code are all what’s required to make a stop charge and stop climate feature to work correctly.

Regards

Looking for that too. Would like to stop charging at 70%

I have no idea about home assistant integration development but I have managed to copy core integration into custom_components and add service pause_charge. It works - I’m able to pause charging by calling service directly from lovelace or by automation.
I did try to add button as you mentioned above but it’s not working - don’t know why.
If you want I can give you some hint how to do that. I don’t feel competent to make pull-request.

great. can you explain how you did that?

As I have HA running in docker I had connected to bash:
sudo docker exec -it homeassistant bash

Then had to find core integration component:
find / -iname "renault"

Now copy whole directory to custom components folder:
cp -R /usr/src/homeassistant/homeassistant/components/renault /config/custom_components/

And now out of docker just with normal sesion connected to HA machine inside HA config directory /custom_components/renault you need to modify few files:

  • manifest.json - need to add version line like:
    "version": "0.1",
  • services.yaml - add new service definition
charge_pause:
  description: Pause charge on vehicle.
  fields:
    vehicle:
      name: Vehicle
      description: The vehicle to send the command to.
      required: true
      selector:
        device:
          integration: renault
  • services.py
    Add service after
    SERVICE_CHARGE_START = “charge_start”
    and insert one into list of SERVICES:
SERVICE_CHARGE_PAUSE = "charge_pause"
SERVICES = [
    SERVICE_AC_CANCEL,
    SERVICE_AC_START,
    SERVICE_CHARGE_SET_SCHEDULES,
    SERVICE_CHARGE_START,
    SERVICE_CHARGE_PAUSE,
]

somewhere near charge_start method:

    async def charge_pause(service_call: ServiceCall) -> None:
        """Pause charge."""
        # The Renault pause charge service has been replaced by a
        # dedicated button entity and marked as deprecated
        LOGGER.warning(
            "The 'renault.charge_pause' service is deprecated and "
            "replaced by a dedicated start charge button entity; please "
            "use that entity to start the charge instead"
        )

        proxy = get_vehicle_proxy(service_call.data)

        LOGGER.debug("Charge pause attempt")
        result = await proxy.vehicle.set_charge_stop()
        LOGGER.debug("Charge pause result: %s", result)

and after:
hass.services.async_register(
DOMAIN,
SERVICE_CHARGE_START,
charge_start,
schema=SERVICE_VEHICLE_SCHEMA,
)

new registration:

    hass.services.async_register(
        DOMAIN,
        SERVICE_CHARGE_PAUSE,
        charge_pause,
        schema=SERVICE_VEHICLE_SCHEMA,
    )

After reloading of integration (maybe HA restart) service started working for me.

1 Like

thanks a bunch i will try it over the next couples of days

Thanks again. It works greeat. your instruktions were easy to follow, even for a noob like me:-)
I am realy greatful to you for sharing.

1 Like

Thanks for providing a work around. I’m sure this is helpful for the developers. I really would love to see this in the standard integration. Thanks.

Thank you so much i managed to get your changes into my Home-Assistant and now im Able to stop charging at 80% what i wanted to do from the First day of my BEV-Life. (Dacia Spring)

If somebody could push these Changes to the Main Thread of the Integrations or could give me a short hint how to do so it would be a blast.

Some time ago i added start and stop charging to Renault integration locally.
I did not yet manage to push this to HA core repo.
Here are my changes:

diff --git a/homeassistant/components/renault/services.py b/homeassistant/components/renault/services.py
index d2c7d45184..ba98c28b62 100644
--- a/homeassistant/components/renault/services.py
+++ b/homeassistant/components/renault/services.py
@@ -64,8 +64,10 @@ SERVICE_CHARGE_SET_SCHEDULES_SCHEMA = SERVICE_VEHICLE_SCHEMA.extend(
 
 SERVICE_AC_CANCEL = "ac_cancel"
 SERVICE_AC_START = "ac_start"
+SERVICE_CHARGE_START = "charge_start"
+SERVICE_CHARGE_STOP = "charge_stop"
 SERVICE_CHARGE_SET_SCHEDULES = "charge_set_schedules"
-SERVICES = [SERVICE_AC_CANCEL, SERVICE_AC_START, SERVICE_CHARGE_SET_SCHEDULES]
+SERVICES = [SERVICE_AC_CANCEL, SERVICE_AC_START, SERVICE_CHARGE_START, SERVICE_CHARGE_STOP, SERVICE_CHARGE_SET_SCHEDULES]
 
 
 def setup_services(hass: HomeAssistant) -> None:
@@ -89,6 +91,22 @@ def setup_services(hass: HomeAssistant) -> None:
         result = await proxy.set_ac_start(temperature, when)
         LOGGER.debug("A/C start result: %s", result.raw_data)
 
+    async def charge_start(service_call: ServiceCall) -> None:
+        """Start charging."""
+        proxy = get_vehicle_proxy(service_call.data)
+
+        LOGGER.debug("Charge start attempt");
+        result = await proxy.set_charge_start()
+        LOGGER.debug("Charge start result: %s", result.raw_data)
+
+    async def charge_stop(service_call: ServiceCall) -> None:
+        """Stop charging."""
+        proxy = get_vehicle_proxy(service_call.data)
+
+        LOGGER.debug("Charge stop attempt");
+        result = await proxy.set_charge_stop()
+        LOGGER.debug("Charge stop result: %s", result.raw_data)
+
     async def charge_set_schedules(service_call: ServiceCall) -> None:
         """Set charge schedules."""
         schedules: list[dict[str, Any]] = service_call.data[ATTR_SCHEDULES]
@@ -134,6 +152,18 @@ def setup_services(hass: HomeAssistant) -> None:
         ac_start,
         schema=SERVICE_AC_START_SCHEMA,
     )
+    hass.services.async_register(
+        DOMAIN,
+        SERVICE_CHARGE_START,
+        charge_start,
+        schema=SERVICE_VEHICLE_SCHEMA,
+    )
+    hass.services.async_register(
+        DOMAIN,
+        SERVICE_CHARGE_STOP,
+        charge_stop,
+        schema=SERVICE_VEHICLE_SCHEMA,
+    )
     hass.services.async_register(
         DOMAIN,
         SERVICE_CHARGE_SET_SCHEDULES,
diff --git a/homeassistant/components/renault/services.yaml b/homeassistant/components/renault/services.yaml
index 2dc99833d5..66c36ca171 100644
--- a/homeassistant/components/renault/services.yaml
+++ b/homeassistant/components/renault/services.yaml
@@ -27,6 +27,22 @@ ac_cancel:
         device:
           integration: renault
 
+charge_start:
+  fields:
+    vehicle:
+      required: true
+      selector:
+        device:
+          integration: renault
+
+charge_stop:
+  fields:
+    vehicle:
+      required: true
+      selector:
+        device:
+          integration: renault
+
 charge_set_schedules:
   fields:
     vehicle:
diff --git a/homeassistant/components/renault/strings.json b/homeassistant/components/renault/strings.json
index 0b0c3d8782..008d657fff 100644
--- a/homeassistant/components/renault/strings.json
+++ b/homeassistant/components/renault/strings.json
@@ -181,6 +181,26 @@
         }
       }
     },
+    "charge_start": {
+      "name": "Start charge",
+      "description": "Starts charging process on vehicle.",
+      "fields": {
+        "vehicle": {
+          "name": "Vehicle",
+          "description": "[%key:component::renault::services::charge_start::fields::vehicle::description%]"
+        }
+      }
+    },
+    "charge_stop": {
+      "name": "Stop charge",
+      "description": "Stops charging process on vehicle.",
+      "fields": {
+        "vehicle": {
+          "name": "Vehicle",
+          "description": "[%key:component::renault::services::charge_stop::fields::vehicle::description%]"
+        }
+      }
+    },
     "charge_set_schedules": {
       "name": "Update charge schedule",
       "description": "Updates charge schedule on vehicle.",
1 Like

Is there a easy way to use the renault.ac_cancel and renault.ac_start service? I like to set a temperature according to the weather.