8000 ohme.list_charge_slots action failing whenever charge slots exist · Issue #138842 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

ohme.list_charge_slots action failing whenever charge slots exist #138842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wralb opened this issue Feb 19, 2025 · 3 comments · Fixed by #139013
Closed

ohme.list_charge_slots action failing whenever charge slots exist #138842

wralb opened this issue Feb 19, 2025 · 3 comments · Fixed by #139013

Comments

@wralb
Copy link
wralb commented Feb 19, 2025

The problem

Using Ohme Home Pro Firmware: v2.65
Trying to migrate from latest production HACS version to core version of Ohme integration

If charge slots exist, using the Action ohme.list_charge_slots to retrieve charge slot information never works in my setup and generates an error. Note, if there are no charge slots (car not plugged in, or charge not approved, or charging finished) then the action does not trigger an error and correctly returns an empty collection. A full error listing is below, however in summary this is always returned:

    energy = (slot["estimatedSoc"]["wh"] - wh_tally) / 1000
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

What version of Home Assistant Core has the issue?

core-2025.2.4

What was the last working version of Home Assistant Core?

New Functionality

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Ohme

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

action: ohme.list_charge_slots
data:
  config_entry: 01JKY819AABAA3B0H1ZA79TC0Z

Anything in the logs that might be useful for us?

2025-02-19 08:36:47.019 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: unsupported operand type(s) for -: 'int' and 'NoneType'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 762, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/core.py", line 2794, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/core.py", line 2837, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/components/ohme/services.py", line 67, in list_charge_slots
    return {"slots": client.slots}
                     ^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/ohme/ohme.py", line 267, in slots
    return slot_list(self._charge_session)
  File "/srv/homeassistant/lib/python3.13/site-packages/ohme/utils.py", line 51, in slot_list
    energy = (slot["estimatedSoc"]["wh"] - wh_tally) / 1000
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
2025-02-19 08:36:47.023 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [134777617936976] Error handling message: Unknown error (unknown_error) User from 10.27.125.4 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0)
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        msg.get("variables"), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 1808, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 528, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 558, in _handle_exception
    raise exception
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 762, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/core.py", line 2794, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/core.py", line 2837, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/homeassistant/components/ohme/services.py", line 67, in list_charge_slots
    return {"slots": client.slots}
                     ^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.13/site-packages/ohme/ohme.py", line 267, in slots
    return slot_list(self._charge_session)
  File "/srv/homeassistant/lib/python3.13/site-packages/ohme/utils.py", line 51, in slot_list
    energy = (slot["estimatedSoc"]["wh"] - wh_tally) / 1000
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

Additional information

Installation type | Home Assistant Core
Development | false
Supervisor | false
Docker | false
User | homeassistant
Virtual environment | true
Python version | 3.13.1
Operating system family | Linux
Operating system version | 6.8.0-52-generic
CPU architecture | x86_64
@home-assistant
Copy link

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

Code owner commands

Code owners of ohme 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 ohme 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)


ohme documentation
ohme source
(message by IssueLinks)

@dan-r
Copy link
Contributor
dan-r commented Feb 21, 2025

Another case of Ohme returning null values and me not accounting for it. I'll update ohmepy and bump the version in a PR later today.

@dan-r dan-r mentioned this issue Feb 21, 2025
19 tasks
@dan-r
Copy link
Contributor
dan-r commented Feb 21, 2025

PR drafted for this, will test it out over the weekend and put it out for review in the next couple of days.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0