Overkiz integration - Local API [Development / Testers topic]

@imick just got this error/crash, can you stop the python crash and code it so it just slightly reports the connection error, or it a core issue ?

Logger: homeassistant.components.automation.suns_too_bright
Source: custom_components/overkiz/executor.py:91 
Integration: Automation (documentation, issues) 
First occurred: 16:33:57 (3 occurrences) 
Last logged: 16:33:57

Suns Too Bright: Choose at step 1: choice 1: Error executing script. Unexpected error for call_service at pos 1: Cannot connect to host gateway-2024-6137-2105.local:8443 ssl:default [Try again]
Suns Too Bright: Error executing script. Unexpected error for choose at pos 1: Cannot connect to host gateway-2024-6137-2105.local:8443 ssl:default [Try again]
While executing automation automation.suns_too_bright
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1155, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1155, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 874, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/resolver.py", line 33, in resolve
    infos = await self._loop.getaddrinfo(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 867, in getaddrinfo
    return await self.run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/socket.py", line 962, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Try again

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 124, in _async_press_action
    await self.async_press()
  File "/config/custom_components/overkiz/button.py", line 123, in async_press
    await self.executor.async_execute_command(self.entity_description.key)
  File "/config/custom_components/overkiz/executor.py", line 91, in async_execute_command
    exec_id = await self.coordinator.client.execute_command(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 628, in execute_command
    response: str = await self.execute_commands(device_url, [command], label)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 656, in execute_commands
    response: dict = await self.__post("exec/apply", payload)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 852, in __post
    async with self.session.post(
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1169, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host gateway-2024-6137-2105.local:8443 ssl:default [Try again]

plus it is strange as the shade did set the my position crorectly.

Thanks for reporting @andyblac. We don’t retry for this command, which we should do, will fix.

Regarding a better error reporting / trace, that is actually an open issue on core which is not only applicable for the local API. Will be fixed eventually as well.

yeah, these types of error are good for debugging, so. maybe the core need a debug toggle for system logging, like the integrations do. ?

This will already be handled by debug logging of an integration.

Quick question - will this support Tahoma Div Rail v2?

1 Like

Back in town

(mick, I do not know where i can post that on the GIT)

Just reconfigured back my installation with local API in debug mode and compared the two modes

Seems that they are not working the same way.

In Cloud mode there are much more attributes update commands that in local API one
I suppose this is a limitation of event handling in local API mode that is compensated by the Somfy cloud services in some ways.

This might be an issue for devices working in asynchronous IO mode (such as remote devices runing on batteries) that are reporting their updated attributes every 5 to 10 minutes to the box (the switch in my case) but that attributes updates do not seem to be sent back to HA when using local API. But if we reboot HA, we get the right attributes updated.

Regarding climates i have HeatingValveIOComponent in my system
They are prefectly recognised, configured…

BUT

They suffer the issue i just described above (requested temperature when updated on the device are only reported when i reboot HA, but they are reported)

AND

When the current temperature is received, there are some casting issues. I put additional debug message to better understand from where they are coming from in file valve_heating_temperature_interface i added two lines

    def current_temperature(self) -> float | None:
        LOGGER.debug('current temperature')
        LOGGER.debug(self.temperature_device.states[OverkizState.CORE_TEMPERATURE])
        """Return the current temperature."""
        if temperature := self.temperature_device.states[OverkizState.CORE_TEMPERATURE]:
            return temperature.value_as_float

        return None

Result was explaining the error… Integer with value 23.1

2023-09-03 11:33:03.384 DEBUG (MainThread) [custom_components.overkiz] Finished fetching device events data in 0.156 seconds (success: True)

2023-09-03 11:33:03.385 DEBUG (MainThread) [custom_components.overkiz] current temperature

2023-09-03 11:33:03.385 DEBUG (MainThread) [custom_components.overkiz] State(name='core:TemperatureState', type=<DataType.FLOAT: 2>, value=23.1)

2023-09-03 11:33:03.403 DEBUG (MainThread) [custom_components.overkiz] current temperature

2023-09-03 11:33:03.404 DEBUG (MainThread) [custom_components.overkiz] State(name='core:TemperatureState', type=<DataType.FLOAT: 2>, value=23.3)

2023-09-03 11:33:03.417 DEBUG (MainThread) [custom_components.overkiz] current temperature

2023-09-03 11:33:03.417 DEBUG (MainThread) [custom_components.overkiz] State(name='core:TemperatureState', type=<DataType.INTEGER: 1>, value=23.1)

2023-09-03 11:33:03.424 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved

Traceback (most recent call last):

  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 229, in _handle_refresh_interval

    await self._async_refresh(log_failures=True, scheduled=True)

  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 374, in _async_refresh

    self.async_update_listeners()

  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in async_update_listeners

    update_callback()

  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 431, in _handle_coordinator_update

    self.async_write_ha_state()

  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 746, in async_write_ha_state

    self._async_write_ha_state()

  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state

    attr.update(self.state_attributes or {})

                ^^^^^^^^^^^^^^^^^^^^^

  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 301, in state_attributes

    hass, self.current_temperature, temperature_unit, precision

          ^^^^^^^^^^^^^^^^^^^^^^^^

  File "/config/custom_components/overkiz/climate_entities/valve_heating_temperature_interface.py", line 102, in current_temperature

    return temperature.value_as_float

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

Same when updating requested temperature from HA

Is this because the cloud version has a layer cleaning casting issues ? Like it seems they are cleaning event handling and propagation of attribute updates ?

2023-09-03 12:05:30.147 DEBUG (MainThread) [custom_components.overkiz] Finished fetching device events data in 0.037 seconds (success: True)
2023-09-03 12:05:30.148 DEBUG (MainThread) [custom_components.overkiz] current temperature
2023-09-03 12:05:30.148 DEBUG (MainThread) [custom_components.overkiz] State(name='core:TemperatureState', type=<DataType.FLOAT: 2>, value=23.1)
2023-09-03 12:05:30.174 DEBUG (MainThread) [custom_components.overkiz] current temperature
2023-09-03 12:05:30.174 DEBUG (MainThread) [custom_components.overkiz] State(name='core:TemperatureState', type=<DataType.FLOAT: 2>, value=23.3)
2023-09-03 12:05:30.198 DEBUG (MainThread) [custom_components.overkiz] current temperature
2023-09-03 12:05:30.198 DEBUG (MainThread) [custom_components.overkiz] State(name='core:TemperatureState', type=<DataType.INTEGER: 1>, value=23.1)
2023-09-03 12:05:30.200 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140681185243712] core:TemperatureState is not a float
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 617, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/overkiz/climate_entities/valve_heating_temperature_interface.py", line 110, in async_set_temperature
    await self.executor.async_execute_command(
  File "/config/custom_components/overkiz/executor.py", line 103, in async_execute_command
    await self.coordinator.async_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 262, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 374, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 431, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 746, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 301, in state_attributes
    hass, self.current_temperature, temperature_unit, precision
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/overkiz/climate_entities/valve_heating_temperature_interface.py", line 102, in current_temperature
    return temperature.value_as_float
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyoverkiz/models.py", line 334, in value_as_float
    raise TypeError(f"{self.name} is not a float")
TypeError: core:TemperatureState is not a float

Hi @imick , I would like to ask you about the idea of decreasing UPDATE_INTERVAL for local API to a lower value, something like 5s? Or to decrease the interval just in cases when some device is in some movement state, like blinds/covers.
I suppose the state is periodically fetched by the client and the box doesn’t push any events directly to the client.

The latter is already built in (in cloud and local). When you execute a command, it will poll every second for state updates until execution is finished.

In regards to lowering the default polling interval for local API. This could be added later, first focus is to get the local API in HA. The reason we didn’t lower it yet, is because we got feedback on this in an early draft, that 30 seconds is the lowest interval that HA accepts. We will start this discussion later again. :wink:

What is your use-case here?

Hmm, it’s strange, You are right, if the cover is going up the state is updating every second, but if the cover is in the closing state / is going down the state isn’t updating and the state is updated after ~30 seconds. And this behavior is just in local API mode, not in the cloud mode.

My case is observing the closed state and setting the tilt position after that.

I sent logs to the PM.

It already does!
I’ve been using it for a year I think!

Been using the local test version for a while now, and still happy with it.
I did notice that the lights I have on my porch react quite fast when I give a command, but the state is updated only after a while (20 to 30 seconds)

Would be good to collect your log (with debug mode) turned on. If it takes 30 seconds, it means that something went wrong around the event handling.

Will do that!

Hello , I’m very interested by the local API , Thanks a lot for the job

I’m trying to configure the Local API, and I get an error in the log:

2023-09-13 16:16:01.583 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:01.587 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:01.595 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:01.596 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:01.599 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:01.603 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:01.607 WARNING (MainThread) [pyoverkiz.enums.ui] Unsupported value DynamicRollerShutter has been returned for <enum ‘UIWidget’>
2023-09-13 16:16:05.590 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry gateway-2035-7912-3242.local:8443 for overkiz
Traceback (most recent call last):

  • File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 387, in async_setup*
  • result = await component.async_setup_entry(hass, self)*
  •         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
    
  • File “/config/custom_components/overkiz/init.py”, line 113, in async_setup_entry*
  • setup, scenarios = await asyncio.gather(*
  •                   ^^^^^^^^^^^^^^^^^^^^^*
    
  • File “/usr/local/lib/python3.11/site-packages/backoff/_async.py”, line 151, in retry*
  • ret = await target(*args, *kwargs)
  •      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
    
  • File “/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py”, line 667, in get_scenarios*
  • response = await self.__get(“actionGroups”)*
  •           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
    
  • File “/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py”, line 839, in __get*
  • await self.check_response(response)*
  • File “/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py”, line 966, in check_response*
  • raise OverkizException(result)*
    pyoverkiz.exceptions.OverkizException: {‘error’: ‘Bus error’, ‘errorCode’: ‘DBUS_ERROR’}

I use the new motors RS100 solar
Thanks for your help

Which version do you use? Do you face the same issues with the cloud integration?

I will be working on this from October onwards, can you hit me up on Discord (_imick) so we can debug this? Haven’t seen this error yet.

when I use the cloud integration it’s OK
version:
“custom_components”: {
“overkiz”: {
“version”: “2023.8.20-T213739Z”,
“requirements”: [
“pyoverkiz==1.10.1”

Let’s discuss on Discord some day. Seems to go wrong on retrieving the action groups (scenes), which hub do you have?

I’ve a Tahoma switch, firmware : 2023.3.4
OK for Discord
It’s in my secondary residence and I’ve no remote access for the moment…

Hello @imick, is there a release date for the local mode in core ?

No. It is almost finished, but need to address some feedback and make the changes.

I am almost at the end of my holidays now, but when I return I will probably be busy, so I can’t give any ETA now.

4 Likes