plmilord / Hass.io-custom-component-ikamand

Home Assistant integration - iKamand
16 stars 1 forks source link

Losing connection #8

Closed palmedia closed 6 months ago

palmedia commented 7 months ago

I'm testing the iKamand in Home Assistant. Every time after +- one hour the connection is lost. When I reload the intergration it is working again.

System log:

2024-01-29 12:32:14.559 WARNING (SyncWorker_3) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 487, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/response.py", line 91, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'

The iKamand is still accessible direct on IP. It looks like the session is expired (?)

palmedia commented 7 months ago
afbeelding

And again after 3 hours and 10 minutes the connection with the iKamand is lost.

plmilord commented 7 months ago

The error you displayed ("HTTP/1.1 200 OK\r\n\n") is normal... The iKamand module contains a header error which causes difficulties with the http library.

Concerning the loss of connection, when testing your iKamand, can you also run a "ping -t....." to validate the connection from elsewhere...

Let me know the development.

palmedia commented 7 months ago

The iKamand is still accessible (and pingable), while Home Assistant not registering any temperature updates anymore.

For example:

Probe1 and iKamand temp are both 19:

image

But if I request the data directly from the iKamand via http://::ip::/cgi-bin/data the temperature is 18:

time=11075&rm=0&acs=0&csid=&cm=0&ag=0&as=0&pt=18&t1=19&t2=400&t3=400&dc=0&tpt=0

So it looks like Home Assistant is not getting any new data.

palmedia commented 7 months ago
2024-01-29 19:38:48.903 WARNING (SyncWorker_16) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:38:54.991 WARNING (SyncWorker_0) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:39:01.054 WARNING (SyncWorker_0) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:39:07.165 WARNING (SyncWorker_0) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:39:13.233 WARNING (SyncWorker_2) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:39:19.294 WARNING (SyncWorker_3) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:39:25.406 WARNING (SyncWorker_13) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-29 19:39:31.487 WARNING (SyncWorker_15) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-31 07:22:06.025 WARNING (SyncWorker_3) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/info): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-31 07:22:07.056 WARNING (SyncWorker_10) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-31 07:22:13.167 WARNING (SyncWorker_12) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-01-31 07:22:19.245 WARNING (SyncWorker_2) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'

Looks like the integration just stops requesting data. If I re-init the intgration it requests /info and after that it is requesting /data again.

Maybe it's because self._online is set to False after 1 bad response? Maybe it's better to try for like 10 minutes to see if the iKamand is back online after a bad respone / failure?

plmilord commented 7 months ago

I'm going to test over a long period with my iKamand... maybe I could set up a keep alive call at x frequency to bring on track the iKamand.

palmedia commented 7 months ago
2024-02-08 06:15:01.323 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py: get_data loop
2024-02-08 06:15:01.379 WARNING (SyncWorker_3) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 487, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/response.py", line 91, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-02-08 06:15:02.404 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py self._data = {'time': ['23537'], 'rm': ['0'], 'acs': ['0'], 'cm': ['0'], 'ag': ['0'], 'as': ['0'], 'pt': ['19'], 't1': ['19'], 't2': ['400'], 't3': ['400'], 'dc': ['0'], 'tpt': ['0']}
2024-02-08 06:15:07.405 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py: get_data loop
2024-02-08 06:15:07.429 WARNING (SyncWorker_1) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 487, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/response.py", line 91, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-02-08 06:15:08.493 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py self._data = {'time': ['23543'], 'rm': ['0'], 'acs': ['0'], 'cm': ['0'], 'ag': ['0'], 'as': ['0'], 'pt': ['19'], 't1': ['19'], 't2': ['400'], 't3': ['400'], 'dc': ['0'], 'tpt': ['0']}
2024-02-08 06:15:13.499 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py: get_data loop
2024-02-08 06:15:13.524 WARNING (SyncWorker_13) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 487, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/response.py", line 91, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-02-08 06:37:01.554 WARNING (MainThread) [homeassistant.components.sensor] Updating ikamand sensor took longer than the scheduled update interval 0:00:01

I did some debugging myself. After the last WARNING noting happens. It's strange that the time between the last call and the exception is more than 15 minutes. As far as I can see is the connection to the iKamand succesfull. The exception says it can't update the sensor.

Changes I made for this debug data:

    async def get_data(self):
        """Get grill data."""
        url = f"{self.base_url}data"

        while True:
            loop = asyncio.get_running_loop()

            _LOGGER.debug("ikamand.py: get_data loop")
            try:
                response = await loop.run_in_executor(None, lambda: requests.get(url))

                if response.status_code in GOOD_HTTP_CODES:
                    result = parse_qs(response.text)
                    self._data = result
                    self._online = True
                else:
                    self._online = False
                _LOGGER.debug("ikamand.py self._data = %s", self._data)

            except requests.RequestException as ex:
                self._online = False
                raise HomeAssistantError(ex.error_description if ex.error_description else ex.msg) from ex

            except Exception as ex:
                self._online = False
                raise HomeAssistantError(ex.error_description if ex.error_description else ex.msg) from ex

            await asyncio.sleep(5)
plmilord commented 7 months ago

We can add a timeout in the get request... then we will need to catch the Timeout exception... But when this happens, what do you do to resolve the situation?

The code might look like this:

async def get_data(self):
    """Get grill data."""
    url = f"{self.base_url}data"

    while True:
        loop = asyncio.get_running_loop()

        try:
            response = await loop.run_in_executor(None, lambda: requests.get(url, timeout=10))

            if response.status_code in GOOD_HTTP_CODES:
                result = parse_qs(response.text)
                self._data = result
                self._online = True
            else:
                self._online = False

        except requests.Timeout as e:
            self._online = False

        except requests.RequestException as e:
            self._online = False

        except Exception as e:
            self._online = False

        await asyncio.sleep(5)

If you can try that on your side, that would give some ideas... You can add the LOGGER elements that you proposed to better see what is happening.

If this works for you, I'll see about adding this timeout processing to all post and get calls.

veetek22 commented 7 months ago

I would like to test it as well - do I replace the code in ikamand.py between lines 76 and 99 ? sorry im not too savvy when it comes to that

palmedia commented 7 months ago

We can add a timeout in the get request... then we will need to catch the Timeout exception... But when this happens, what do you do to resolve the situation? .... If you can try that on your side, that would give some ideas... You can add the LOGGER elements that you proposed to better see what is happening.

If this works for you, I'll see about adding this timeout processing to all post and get calls.

Thanks, I will give it a try. I've added some debugging and now testing it.

palmedia commented 7 months ago

I would like to test it as well - do I replace the code in ikamand.py between lines 76 and 99 ? sorry im not too savvy when it comes to that

Yes, replace these lines and restart HA. If you past the function in ikamand.py, pay attention to the indentation of the lines.

veetek22 commented 7 months ago

Thank you trying now

plmilord commented 7 months ago

Tests are underway here too... Report your findings.

palmedia commented 7 months ago
2024-02-10 23:31:31.555 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1419, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 707, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1419, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 707, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/ikamand/ikamand.py", line 84, in get_data
    response = await loop.run_in_executor(None, lambda: requests.get(url, timeout=10))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ikamand/ikamand.py", line 84, in <lambda>
    response = await loop.run_in_executor(None, lambda: requests.get(url, timeout=10))
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

This is what I get....

plmilord commented 7 months ago

During a 17-hour run, I had 5 small glitches (delay of 21s) and 2 long glitches (3m45s). Each time, the component resumed communication on its own... Still in control of the iKamand this morning!

On your end, has the component resumed or completely stopped responding after those glitches?

palmedia commented 7 months ago

During a 17-hour run, I had 5 small glitches (delay of 21s) and 2 long glitches (3m45s). Each time, the component resumed communication on its own... Still in control of the iKamand this morning!

On your end, has the component resumed or completely stopped responding after those glitches?

The integration stopped working.

palmedia commented 7 months ago

I did another duratingtest. Looks like the connection was lost but after a couple of minutes it restored itself and was recieving data again.

But after the hiccup the climate integration was nog "heating" anymore. So if I use this on my BBQ the iKamand stops keeping the BBQ at the right temperature.

afbeelding

Also time value resets:

2024-02-12 12:17:35.108 WARNING (SyncWorker_34) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 487, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/response.py", line 91, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-02-12 12:17:36.101 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py self._data = {'time': ['1707736642'], 'rm': ['1'], 'acs': ['1'], 'cm': ['0'], 'ag': ['0'], 'as': ['0'], 'pt': ['20'], 't1': ['20'], 't2': ['400'], 't3': ['400'], 'dc': ['0'], 'tpt': ['10']}
2024-02-12 12:17:41.102 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:17:51.122 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:17:56.122 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:18:06.139 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:18:11.140 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:18:21.148 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:18:26.150 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:18:36.176 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:18:41.177 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:18:51.194 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:18:56.194 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:19:06.218 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:19:11.220 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:19:21.254 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:19:26.255 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:19:36.288 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Read timed out. (read timeout=10)
2024-02-12 12:19:41.289 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:19:51.301 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff463a1bb0>, 'Connection to 192.168.178.162 timed out. (connect timeout=10)'))
2024-02-12 12:19:56.303 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:20:06.317 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff42258470>, 'Connection to 192.168.178.162 timed out. (connect timeout=10)'))
2024-02-12 12:20:11.318 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:20:21.323 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff56217620>, 'Connection to 192.168.178.162 timed out. (connect timeout=10)'))
2024-02-12 12:20:26.324 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:20:36.338 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff53e59e80>, 'Connection to 192.168.178.162 timed out. (connect timeout=10)'))
2024-02-12 12:20:41.339 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:20:51.357 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0xffff4f44b7a0>, 'Connection to 192.168.178.162 timed out. (connect timeout=10)'))
2024-02-12 12:20:56.358 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:21:00.315 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff6269fe00>: Failed to establish a new connection: [Errno 111] Connection refused'))
2024-02-12 12:21:05.316 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:21:05.331 ERROR (MainThread) [custom_components.ikamand.const] HTTPConnectionPool(host='192.168.178.162', port=80): Max retries exceeded with url: /cgi-bin/data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff6bca0980>: Failed to establish a new connection: [Errno 111] Connection refused'))
2024-02-12 12:21:10.333 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py loop = <_UnixSelectorEventLoop running=True closed=False debug=False>
2024-02-12 12:21:10.358 WARNING (SyncWorker_40) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.178.162:80/cgi-bin/data): [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 487, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/response.py", line 91, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [MissingHeaderBodySeparatorDefect()], unparsed data: 'HTTP/1.1 200 OK\r\n\n'
2024-02-12 12:21:11.526 DEBUG (MainThread) [custom_components.ikamand.const] ikamand.py self._data = {'time': ['17'], 'rm': ['0'], 'acs': ['0'], 'cm': ['0'], 'ag': ['0'], 'as': ['0'], 'pt': ['72'], 't1': ['72'], 't2': ['400'], 't3': ['400'], 'dc': ['0'], 'tpt': ['0']}
plmilord commented 7 months ago

@palmedia , have a look to the new release v1.5. It improves the stability of the component... but perhaps not up to your expectations! For my part, after returning from a loss of network connection, the display resumes where it was. Obviously, if the device resumes after a loss of electrical power, it resumes in neutral.

palmedia commented 7 months ago

Thanks for the update. I'm going to do another duration test. I also wrote an automation for changing the state to heat after a loss of network connection.

I also discovered that sometimes the iKamand loses its network and doesn't come back. For this I will connect a wall plug to give the iKamand a complete reset.

plmilord commented 6 months ago

I have not experienced this state which does not return to heat...

The only time my iKamand didn't recover on its own was when I unplugged and reconnected the power (this only happened once, and I wasn't patient! I have already observed the iKamand absent for 3-4 minutes).

As the iKamand seems to reset its probes after a power outage or loss of connection, I no longer consider its values in its first 40 seconds of its life. Its values are not relevant and precise during those first 40s of life.

palmedia commented 6 months ago

If the connection is lost, hvac_mode and temperature both resetting to off / 0 degrees. Even if the connection is lost for a couple of seconds / minutes.

I wrote an automation and added some values to restore the settings after connection loss. I've added also a probe target temperature for future notifications.

Variables are in dutch.

input_number:
  # wanted bbq temperature
  ikamand_temperatuur_bbq_gewenst:
    name: "iKamand: temperatuur BBQ gewenst"
    min: 10
    max: 260
    step: 1
    icon: mdi:grill
  #wanted probe1 temperature
  ikamand_temperatuur_probe1_gewenst:
    name: "iKamand: temperatuur probe1 gewenst"
    min: 10
    max: 260
    step: 1
    icon: mdi:food-drumstick
input_boolean:
  #bbq time! iKamand shoud be running
  ikamand_status:
    name: "iKamand status"
    icon: mdi:grill

automation:
  #state changed
  - alias: "BBQ: status gewijzigd"
    id: "bbq_status_gewijzigd"
    trigger:
      - platform: state
        entity_id: input_number.ikamand_temperatuur_bbq_gewenst
      - platform: state
        entity_id:
          - input_boolean.ikamand_status
      - platform: state
        entity_id:
          - climate.ikamand
        from: unavailable
        to: "off"
      - platform: state
        entity_id:
          - climate.ikamand
        to: unavailable
        for:
          minutes: 5
    action:
      - if:
          - condition: state
            entity_id: input_boolean.ikamand_status
            state: "off"
        then:
          - service: climate.set_hvac_mode
            target:
              entity_id: climate.ikamand
            data:
              hvac_mode: "off"
        else:
          - if:
              - condition: state
                entity_id: climate.ikamand
                state: "off"
            then:
              - service: climate.set_hvac_mode
                target:
                  entity_id: climate.ikamand
                data:
                  hvac_mode: "heat"
              - service: climate.set_temperature
                target:
                  entity_id: climate.ikamand
                data:
                  temperature: "{{ states.input_number.ikamand_temperatuur_bbq_gewenst.state }}"
          - if:
              - condition: state
                entity_id: climate.ikamand
                state: unavailable
            then:
              - service: switch.turn_off
                data: {}
                target:
                  entity_id: switch.wallplug_ikamand
              - delay:
                  seconds: 5
              - service: switch.turn_on
                data: {}
                target:
                  entity_id: switch.wallplug_ikamand
              - service: notify.phone
                data:
                  title: "BBQ"
                  message: "iKamand niet beschikbaar voor > 5 minuten."
              - delay:
                  seconds: 30
          - if:
              - condition: state
                entity_id: climate.ikamand
                state: "heat"
            then:
              - service: climate.set_temperature
                target:
                  entity_id: climate.ikamand
                data:
                  temperature: "{{ states.input_number.ikamand_temperatuur_bbq_gewenst.state }}"
plmilord commented 6 months ago

hmmm... experienced that stoppage!!

I'm going to add code to resume where it was before the shutdown which occurs every ~6:30. It makes me think of other things...!! I'll come back to you shortly with another version!

plmilord commented 6 months ago

Have a look at the v2.0 Pre-release.

This should be much better for you. I think you will no longer need your automations.

...Lots of improvements!

Let me know your comments!

palmedia commented 6 months ago

Have a look at the v2.0 Pre-release.

This should be much better for you. I think you will no longer need your automations.

...Lots of improvements!

Let me know your comments!

Thanks for the update! I'm running it for 24 hours now and it's still going strong.

palmedia commented 6 months ago

Still running (60 hours), I think my steak is ready now 😂 If it were up to me, this issue could be closed.

Thanks again!

plmilord commented 6 months ago

I'm going to remember that I shouldn't go eat steak at your place! 😂

...so I'm closing this issue! Thanks for following up on this!