Skip to content
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

Number/time controls don't work #78

Closed
nyordanov opened this issue Apr 22, 2024 · 11 comments
Closed

Number/time controls don't work #78

nyordanov opened this issue Apr 22, 2024 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@nyordanov
Copy link

What happened?

Changing the Target Percentage, Target Time, or Preconditioning results in this TypeError

To Reproduce

Drag the Target Percentage range input:

Error message:

Log Output

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 112, in async_set_value
    await entity.async_set_native_value(native_value)
  File "/config/custom_components/ohme/number.py", line 76, in async_set_native_value
    await self._client.async_apply_session_rule(target_percent=int(value))
  File "/config/custom_components/ohme/api_client.py", line 203, in async_apply_session_rule
    max_price = self._last_rule['settings'][0]['enabled'] if 'settings' in self._last_rule and len(
                                                                                               ^^^^
TypeError: object of type 'NoneType' has no len()

Home Assistant Version

Core 2024.4.3
Supervisor 2024.04.0
Operating System 12.2
Frontend 20240404.2

Integration Version

0.8.2

@nyordanov nyordanov added the bug Something isn't working label Apr 22, 2024
@dan-r
Copy link
Owner

dan-r commented Apr 23, 2024

Interesting - was there a car plugged in when you saw this?

@nyordanov
Copy link
Author

Yes

@dan-r
Copy link
Owner

dan-r commented May 2, 2024

I haven't been able to replicate this, do you have any more details you can share? Any errors in the logs beforehand? Any general network issues?

@nyordanov
Copy link
Author

I have this other TypeError in the logs, no idea if it's related to the above and I can't reproduce it on demand like the other error:

[homeassistant.components.switch] ohme: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 707, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1293, in async_device_update
await self.async_update()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 530, in async_update
await self.coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 117, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 291, in async_refresh
await self._async_refresh(log_failures=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, 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 "/config/custom_components/ohme/number.py", line 255, in _handle_coordinator_update
self._state = self.coordinator.data["userSettings"]["chargeSettings"][0]["value"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

Other than that, all I can say is that the error on api_client.py line 203 happens every time the car is plugged in and I try to change a number or time control. But, weirdly, all these controls work just fine if the car isn't plugged in.

For example, I can change the target time from 7:00 to 7:30 with the car unplugged, and it will have stored this value next time I plug the car in. I can also change the target percentage, etc. But I get a TypeError and the value doesn't change if the car is plugged in.

I tried disabling the VW API integration since it mostly doesn't work - didn't make any difference.

I also don't have a tariff selected in the Ohme app as my tariff isn't listed.

@dan-r
Copy link
Owner

dan-r commented May 9, 2024

@nyordanov think I've figured it out. Would you mind trying out v0.8.3-beta.3? (beta instructions)

@nyordanov
Copy link
Author

Works for me now.

Weirdly, the approve charge button didn't work when I tried it (was able to approve it in the Ohme app), but looking at the code I can't see how that could be related. I'll try again next time.

Thanks a lot. With this change I can now have two automations:

  1. Auto approvals based on car location (if the button works, that is)
  2. Automatically set target percentage based on car SoC and avoid Ohme's flaky integration with VW's API (e.g., add 25% instead of relying on charge from 55% to 80%)

@Begie1605
Copy link

Had the same problem, and with beta release it works now....

@simonjharris
Copy link

Beta release working for me too 🙌

One minor issue is that it's disabling the price cap, but I can't see anything in the logs so might just be something on Ohme's end.

@dmsims
Copy link

dmsims commented Jun 13, 2024

Cam here because I could not set the time - get this error with b3

Logger: custom_components.ohme.api_client
Source: custom_components/ohme/api_client.py:109
integration: Ohme (documentation, issues)
First occurred: 18:13:44 (2 occurrences)
Last logged: 18:14:02

Ohme API response error: /v1/chargeSessions/ohmeapp9oj6a/rule?enableMaxPrice=false&targetTs=1718306640000&enablePreconditioning=false&toPercent=100.0&preconditionLengthMins=None, 400; {"timestamp":1718298824487,"status":400,"error":"Bad Request","message":"Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "None"","path":"/v1/chargeSessions/ohmeapp9oj6a/rule"}

@dan-r
Copy link
Owner

dan-r commented Jun 13, 2024

Thanks all for testing that, I'll release it as stable - apologies for not getting round to it sooner!

@dan-r
Copy link
Owner

dan-r commented Jun 13, 2024

Resolved by #81

@dan-r dan-r closed this as completed Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants