home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.82k forks source link

Renault integration: wrong plug_state #124682

Closed tmenguy closed 6 days ago

tmenguy commented 2 weeks ago

The problem

Hi,

Lately I have some inconsistency between the plus sensor and the plug state one (vehicle : Twingo eTech), and the integration having issues (like no refresh of the sensor). Seems there was some changes on the Renault side.

See some logs below but in a nutshell: File "/usr/local/lib/python3.12/site-packages/renault_api/kamereon/models.py", line 384, in get_plug_status raise exceptions.KamereonException( renault_api.kamereon.exceptions.KamereonException: Unable to convert 3 to PlugState.

seems to be in the renault API library. Hope this help

BR Thomas

What version of Home Assistant Core has the issue?

core-2024.8.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Renault

Link to integration documentation on our website

https://www.home-assistant.io/integrations/renault/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 453, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 533, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 542, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/renault/sensor.py", line 91, in native_value
    return self.entity_description.value_lambda(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/renault/sensor.py", line 109, in _get_plug_state_formatted
    plug_status = data.get_plug_status() if data else None
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/renault_api/kamereon/models.py", line 384, in get_plug_status
    raise exceptions.KamereonException(
renault_api.kamereon.exceptions.KamereonException: Unable to convert `3` to PlugState.

Additional information

No response

home-assistant[bot] commented 2 weeks ago

Hey there @epenet, mind taking a look at this issue as it has been labeled with an integration (renault) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `renault` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign renault` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


renault documentation renault source (message by IssueLinks)

epenet commented 2 weeks ago

See https://github.com/hacf-fr/renault-api/issues/1262

epenet commented 2 weeks ago

@tmenguy you can open a PR to bump the dependency to v0.2.6 and adjust the sensor accordingly.

tmenguy commented 2 weeks ago

yes I know, never did a PR on homeassitant core directly ... seems a bit daunting :)

epenet commented 1 week ago

The PR to bump the dependency has been merged. Now all is left is to add the new values to the options and to the string. It should be straightforward... give it a go!

tmenguy commented 1 week ago

Ok I'll try then :) I have an Hass setup ...any special stuff I have to do to send the pull request?

epenet commented 1 week ago

You can look at https://github.com/epenet/home-assistant-core/commit/a2372c05c0d713bf1732f5526959cb3ed2693aff for a sample

tmenguy commented 1 week ago

@epenet I completely missed your example ... would have been quicker :) I do hope what I have done is comparable :)