sockless-coding / garo_wallbox

Garo wallbox - Home Assistant Component
MIT License
20 stars 35 forks source link

ValueError: 'UNAVAILABLE' is not a valid Status #10

Closed stenrose closed 3 years ago

stenrose commented 3 years ago

I set mode to ALWAYS_OFF (through Home Assistant, using the garo_wallbox.set_mode service) while the connector was still plugged in the vehicle after a completed charge. The charge was thus paused from the vehicle. When I changed mode, some values changed such as to "connector": "UNAVAILABLE", "powerMode": "UNAVAILABLE" and "chargeStatus": 144 (previously "chargeStatus": 48).

Noticed the following exceptions in the logs:

2021-02-18 13:45:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.garo_wallbox fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/config/custom_components/garo_wallbox/sensor.py", line 91, in async_update
    await self._device.async_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 83, in async_update
    await self._do_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 88, in _do_update
    self._status = GaroStatus(response_json)
  File "/config/custom_components/garo_wallbox/garo.py", line 125, in __init__
    self.status = Status(response['connector'])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: 'UNAVAILABLE' is not a valid Status
2021-02-18 13:45:33 ERROR (MainThread) [homeassistant.helpers.script.garo_wallbox_mode] Garo Wallbox Mode: Error executing script. Unexpected error for call_service at pos 1: 'UNAVAILABLE' is not a valid Status
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 254, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 575, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 595, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 632, in _handle_entity_call
    await result
  File "/config/custom_components/garo_wallbox/sensor.py", line 85, in async_set_mode
    await self._device.set_mode(Mode[mode])
  File "/config/custom_components/garo_wallbox/garo.py", line 98, in set_mode
    await self._do_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 88, in _do_update
    self._status = GaroStatus(response_json)
  File "/config/custom_components/garo_wallbox/garo.py", line 125, in __init__
    self.status = Status(response['connector'])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: 'UNAVAILABLE' is not a valid Status
2021-02-18 13:45:33 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [2827465680] 'UNAVAILABLE' is not a valid Status
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 136, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 595, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 632, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/template/switch.py", line 189, in async_turn_on
    await self._on_script.async_run(context=self._context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1033, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 246, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 254, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 575, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 595, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 664, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 632, in _handle_entity_call
    await result
  File "/config/custom_components/garo_wallbox/sensor.py", line 85, in async_set_mode
    await self._device.set_mode(Mode[mode])
  File "/config/custom_components/garo_wallbox/garo.py", line 98, in set_mode
    await self._do_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 88, in _do_update
    self._status = GaroStatus(response_json)
  File "/config/custom_components/garo_wallbox/garo.py", line 125, in __init__
    self.status = Status(response['connector'])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: 'UNAVAILABLE' is not a valid Status
2021-02-18 13:47:46 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.garo_wallbox fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/config/custom_components/garo_wallbox/sensor.py", line 91, in async_update
    await self._device.async_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 83, in async_update
    await self._do_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 88, in _do_update
    self._status = GaroStatus(response_json)
  File "/config/custom_components/garo_wallbox/garo.py", line 125, in __init__
    self.status = Status(response['connector'])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: 'UNAVAILABLE' is not a valid Status
2021-02-18 13:48:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.garo_wallbox_phases fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/config/custom_components/garo_wallbox/sensor.py", line 185, in async_update
    await self._device.async_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 83, in async_update
    await self._do_update()
  File "/config/custom_components/garo_wallbox/garo.py", line 88, in _do_update
    self._status = GaroStatus(response_json)
  File "/config/custom_components/garo_wallbox/garo.py", line 125, in __init__
    self.status = Status(response['connector'])
  File "/usr/local/lib/python3.8/enum.py", line 339, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.8/enum.py", line 662, in __new__
    raise ve_exc
ValueError: 'UNAVAILABLE' is not a valid Status

Here is how the output from /rest/chargebox/status looks before and after changing mode.

$ curl --silent http://192.168.86.117:2222/rest/chargebox/status | jq 
{
  "ocppState": null,
  "connectedToInternet": true,
  "freeCharging": false,
  "ocppConnectionState": null,
  "connector": "CONNECTED",
  "mode": "ALWAYS_ON",
  "currentLimit": 25,
  "factoryCurrentLimit": 32,
  "switchCurrentLimit": 25,
  "powerMode": "ON",
  "currentChargingCurrent": 0,
  "currentChargingPower": 0,
  "accSessionEnergy": 26100,
  "latestReading": 1160400,
  "chargeStatus": 48,
  "updateStatus": {
    "serialsToUpdate": [],
    "serialsUpdated": [],
    "currentlyUpdating": -1,
    "currentProgress": -1,
    "failedUpdate": 0
  },
  "currentTemperature": 9,
  "slaveControlWarning": false,
  "pilotLevel": 25,
  "sessionStartValue": 1134300,
  "nrOfPhases": 1
}
$ curl --silent http://192.168.86.117:2222/rest/chargebox/status | jq 
{
  "ocppState": null,
  "connectedToInternet": true,
  "freeCharging": false,
  "ocppConnectionState": null,
  "connector": "UNAVAILABLE",
  "mode": "ALWAYS_OFF",
  "currentLimit": 25,
  "factoryCurrentLimit": 32,
  "switchCurrentLimit": 25,
  "powerMode": "UNAVAILABLE",
  "currentChargingCurrent": 0,
  "currentChargingPower": 0,
  "accSessionEnergy": 26100,
  "latestReading": 1160400,
  "chargeStatus": 144,
  "updateStatus": {
    "serialsToUpdate": [],
    "serialsUpdated": [],
    "currentlyUpdating": -1,
    "currentProgress": -1,
    "failedUpdate": 0
  },
  "currentTemperature": 9,
  "slaveControlWarning": false,
  "pilotLevel": 25,
  "sessionStartValue": 1134300,
  "nrOfPhases": 1
}
sockless-coding commented 3 years ago

Hi @stenrose Guess the wallbox didn't like when you changed the mode while it was connected... Have you tried doing the same from the web UI? I've fixed the missing UNAVAILABLE status in v1.0.5, so the integration shouldn't fail if the connector becomes unavailable.

stenrose commented 3 years ago

@sockless-coding yes, I tried changing through web UI as well as manually with cURL. The web UI changes to "Charging paused(Master)" from "Vehicle connected".

Here's a diff on the output from the REST API when setting mode to ALWAYS_OFF while connector is connected.

--- -   2021-02-21 20:10:44.401310985 +0100
+++ /dev/fd/63  2021-02-21 20:10:44.343600195 +0100
@@ -3,17 +3,17 @@
   "connectedToInternet": true,
   "freeCharging": false,
   "ocppConnectionState": null,
-  "connector": "CONNECTED",
-  "mode": "ALWAYS_ON",
+  "connector": "UNAVAILABLE",
+  "mode": "ALWAYS_OFF",
   "currentLimit": 25,
   "factoryCurrentLimit": 32,
   "switchCurrentLimit": 25,
-  "powerMode": "ON",
+  "powerMode": "UNAVAILABLE",
   "currentChargingCurrent": 0,
   "currentChargingPower": 0,
   "accSessionEnergy": 0,
   "latestReading": 1161700,
-  "chargeStatus": 48,
+  "chargeStatus": 144,
   "updateStatus": {
     "serialsToUpdate": [],
     "serialsUpdated": [],

Thanks for the quick fix. For future reference, fixed by 11aa19605811a0d7617b1124855025d72eee0728.