jwillemsen / daikin_onecta

Home Assistant Integration for devices supported by the Daikin Onecta App
https://github.com/jwillemsen/daikin_onecta
GNU General Public License v3.0
237 stars 9 forks source link

[Issue]: service call fails with "unauthorized" #238

Closed sod75 closed 2 months ago

sod75 commented 2 months ago

yesterday everything was working, today I get unauthorized; official app is still working

Version: 4.1.10


2024-06-28 08:52:33.383 INFO (MainThread) [custom_components.daikin_onecta.device] Path: /v1/gateway-devices/96755fe6-5e90-4bd7-b02d-1743bccb55d7/management-points/climateControl/characteristics/onOffMode , options: {"value": "off"}
2024-06-28 08:52:33.550 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140623404503184] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 977, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1049, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/climate.py", line 389, in async_set_hvac_mode
    result &= await self._device.patch(self._device.id, self._embedded_id, "onOffMode", "", on_off_mode)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/device.py", line 91, in patch
    res = await self.api.doBearerRequest("PATCH", setPath, setOptions)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/daikin_api.py", line 145, in doBearerRequest
    raise Exception("Communication failed! Status: " + str(res.status_code) + " " + res.text)
Exception: Communication failed! Status: 401 {
  "message":"Unauthorized",
  "request_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
2024-06-28 09:08:11.017 ERROR (MainThread) [custom_components.daikin_onecta.coordinator] Unexpected error fetching daikin_onecta data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/coordinator.py", line 52, in _async_update_data
    daikin_api.json_data = await daikin_api.getCloudDeviceDetails()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/daikin_api.py", line 149, in getCloudDeviceDetails
    return await self.doBearerRequest("GET", "/v1/gateway-devices")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/daikin_api.py", line 145, in doBearerRequest
    raise Exception("Communication failed! Status: " + str(res.status_code) + " " + res.text)
Exception: Communication failed! Status: 401 {
  "message":"Unauthorized",
  "request_id":"cxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

I changed logging to debug and restarted which gave this:

onecta error

relevant log entry

2024-06-28 11:01:42.123 DEBUG (MainThread) [custom_components.daikin_onecta.daikin_api] Initialing Daikin Onecta API...
2024-06-28 11:01:42.123 INFO (MainThread) [custom_components.daikin_onecta.daikin_api] Daikin Onecta API initialized.
2024-06-28 11:01:42.124 INFO (MainThread) [custom_components.daikin_onecta.coordinator] Daikin coordinator initialized with 0:10:00 interval.
2024-06-28 11:01:42.124 DEBUG (MainThread) [custom_components.daikin_onecta.coordinator] Daikin coordinator start _async_update_data.
2024-06-28 11:01:42.124 DEBUG (MainThread) [custom_components.daikin_onecta.daikin_api] BEARER REQUEST URL: https://api.onecta.daikineurope.com/v1/gateway-devices
2024-06-28 11:01:42.124 DEBUG (MainThread) [custom_components.daikin_onecta.daikin_api] BEARER TYPE GET JSON: None
2024-06-28 11:01:42.301 DEBUG (MainThread) [custom_components.daikin_onecta.daikin_api] BEARER RESPONSE CODE: 401 LIMIT: {'minute': 0, 'day': 0, 'remaining_minutes': 0, 'remaining_day': 0, 'retry_after': 0, 'ratelimit_reset': 0}
2024-06-28 11:01:42.301 ERROR (MainThread) [custom_components.daikin_onecta.coordinator] Unexpected error fetching daikin_onecta data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/coordinator.py", line 52, in _async_update_data
    daikin_api.json_data = await daikin_api.getCloudDeviceDetails()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/daikin_api.py", line 149, in getCloudDeviceDetails
    return await self.doBearerRequest("GET", "/v1/gateway-devices")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/daikin_onecta/daikin_api.py", line 145, in doBearerRequest
    raise Exception("Communication failed! Status: " + str(res.status_code) + " " + res.text)
Exception: Communication failed! Status: 401 {
  "message":"Unauthorized",
  "request_id":"cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
2024-06-28 11:01:42.302 DEBUG (MainThread) [custom_components.daikin_onecta.coordinator] Finished fetching daikin_onecta data in 0.179 seconds (success: False)

config_entry-daikin_onecta-7972c59fedd7838144f36664e0df24d5.json

jwillemsen commented 2 months ago

Duplicate of #236, was a problem at the Daikin side which has been fixed

Boppie1976 commented 2 months ago

Weird... I had the same problem, but it just started working again a few minutes ago...

Greetings, Bob.

sod75 commented 2 months ago

Can confirm it started working again. Apologies for the duplicate ( I did check for open issues but took too long submitting this)