Skip to content

Update CpState to match updated Peblar API docs#430

Open
m-a-r-k-e wants to merge 2 commits into
frenck:mainfrom
m-a-r-k-e:fix/cpstate
Open

Update CpState to match updated Peblar API docs#430
m-a-r-k-e wants to merge 2 commits into
frenck:mainfrom
m-a-r-k-e:fix/cpstate

Conversation

@m-a-r-k-e

Copy link
Copy Markdown

Proposed Changes

The Peblar API documentation related to the EVInterface CpState is updated https://developer.peblar.com/local-rest-api#tag/EVInterface. The values for the INVALID and UNKNOWN state are changed.

This pull request updates the CpState values to match the updated documentation.
Also the CpState descriptions are updated to match the Peblar API documentation.

Background

In the last year the Peblar Home Assistant integration stopped working two times due to an invalid CpState state:

Unexpected error fetching Peblar Peblar meter data
Traceback (most recent call last):
  File "<string>", line 30, in __mashumaro_from_json__
  File "/usr/local/lib/python3.13/enum.py", line 726, in __call__
    return cls.__new__(cls, value)
           ~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/enum.py", line 1199, in __new__
    raise ve_exc
ValueError: 'State Invalid' is not a valid CPState

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/peblar/coordinator.py", line 82, in handler
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/peblar/coordinator.py", line 160, in _async_update_data
    ev=await self.api.ev_interface(),
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/peblar/peblar.py", line 347, in ev_interface
    return PeblarEVInterface.from_json(result)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "<string>", line 32, in __mashumaro_from_json__
mashumaro.exceptions.InvalidFieldValue: Field "cp_state" of type CPState in PeblarEVInterface has invalid value 'State Invalid'

The Peblar EVInterface endpoint reported at that moment:

{
        "ChargeCurrentLimit" : 0,
        "ChargeCurrentLimitActual" : 0,
        "ChargeCurrentLimitSource" : "Local REST API",
        "CpState" : "State Invalid",
        "Force1Phase" : false,
        "LockState" : true
}

At that moment this state was not described in the Peblar API documentation, so I asked Peblar support and got the following response:

Dit is u goed opgevallen. Dit was een fout in onze documentatie en we zullen dit zo spoedig mogelijk gaan aanpassen zodat de documentatie juist is.
De juiste waardes voor CpState zouden zijn “State Invalid” en “unknown state”.

State Invalid feels also more logical related to the other state (and that one is confirmed by my own charger). The unkown state is still an exception (next to the typo in the mail), especially because it also starts with lowercase.

Finally also the documentation on the Peblar website is updated (it matches the state as described in the mail response, only the typo is fixed), so I think this is the right moment to also update this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant