hacf-fr / renault-api

https://readthedocs.org/projects/renault-api/
MIT License
109 stars 38 forks source link

[ERROR] when calling hvac = await vehicle.get_hvac_status() #1202

Closed eltoro0815 closed 5 months ago

eltoro0815 commented 5 months ago

The car called is a DACIA SPRING.

The following Error is displayed:

marshmallow.exceptions.ValidationError: {'hvacStatus': ['Not a valid string.']}

Doing the request with Postman the following Json is returned by the server:

{
    "data": {
        "id": "UU1XXXXXXXXXXXXXX",
        "attributes": {
            "hvacStatus": 1,
            "lastUpdateTime": "2024-05-28T12:46:19Z"
        }
    }
}

The attribute "hvacStatus" has changed it's type.

Has been of type String and the possible Return Values where "on" and "off"

Looks like now you get an integer instead.

neilgall commented 5 months ago

Seeing the same with my Renault Megane E-Tech

epenet commented 5 months ago

My car doesn't support this endpoint - so I am unable to confirm.

Can someone open a PR?

0sasu0 commented 5 months ago

The same here, lots of error messages since yesterday. My Car is aTwingo electric.

Logger: homeassistant.components.renault.renault_vehicle
Quelle: helpers/update_coordinator.py:315
Integration: Renault (Dokumentation, Probleme)
Erstmals aufgetreten: 14:34:02 (15 Vorkommnisse)
Zuletzt protokolliert: 16:12:03

Unexpected error fetching VF1AH00********** hvac_status data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/renault/coordinator.py", line 57, in _async_update_data
    data = await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/renault_api/renault_vehicle.py", line 160, in get_hvac_status
    response.get_attributes(schemas.KamereonVehicleHvacStatusDataSchema),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/renault_api/kamereon/models.py", line 353, in get_attributes
    cast(KamereonVehicleDataAttributes, schema.load(self.data.attributes))
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/marshmallow_dataclass/__init__.py", line 910, in load
    all_loaded = super().load(data, many=many, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/marshmallow/schema.py", line 723, in load
    return self._do_load(
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/marshmallow/schema.py", line 910, in _do_load
    raise exc
marshmallow.exceptions.ValidationError: {'hvacStatus': ['Not a valid string.']}
HomeACcessoryKid commented 5 months ago

Same here Captur E-tech 2021

epenet commented 5 months ago

I assume 1 means "off", and 2 means "on"... PR #1211 has been merged Release v0.2.3 is available: https://github.com/hacf-fr/renault-api/releases/tag/v0.2.3 This should be available in Home Assistant 2024.6: https://github.com/home-assistant/core/pull/118718

eltoro0815 commented 5 months ago

Yes, that's correct!

1 = off
2 = on
Konubinix commented 5 months ago

Today, the endpoint for DACIA SPRING return strings again. I get "hvacStatus": "off". To mitigate this, I changed in the code the type of hvacStatus from hvacStatus: Optional[int] to hvacStatus: Optional[int] | Optional[str]