Closed depuytnl closed 7 months ago
Removed the component, the integration, etc and started again. Attached the relevant part of the log file after trying to add my thermostat. errorlog.txt
I removed the component, since than I cannot add it again, I always get "Unknown error occurred" when I give the credentials (serial, access, password)
Until the update it was working fine.
I also have this error since the upgrade, following this topic for a fix. Believe this is the most important part:
AttributeError: module 'ssl' has no attribute 'match_hostname'
2024-02-08 13:44:44.032 ERROR (MainThread) [custom_components.bosch.config_flow] Error connecting Bosch at ######### - module 'ssl' has no attribute 'match_hostname'
2024-02-08 13:44:44.032 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 2202, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 1802, in _raise_ssl_error
self._context._verify_helper.raise_if_problem()
File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 456, in raise_if_problem
raise self._problems.pop(0)
In Python 3.12 function match_hostname()
was removed. You have to downgrade until update is released of aioxmpp library.
There won't be new release any time soon. According to aioxmpp repo:
Notice: As of January 14th, 2024, aioxmpp entered a new mode of operation, which hasn't been fully documented yet elsewhere. There will be no further releases, until there are more contributors who stick around and care for the maintenance and quality of the code. Maintaining it alone at the previous quality level is something I simply cannot deliver anymore.
Too bad, i think that the error that i'm experiencing on #385 can be also related to the aioxmpp library...
There won't be new release any time soon. According to aioxmpp repo:
Notice: As of January 14th, 2024, aioxmpp entered a new mode of operation, which hasn't been fully documented yet elsewhere. There will be no further releases, until there are more contributors who stick around and care for the maintenance and quality of the code. Maintaining it alone at the previous quality level is something I simply cannot deliver anymore.
Same issue. Downgraded back to 2024.1 while waiting for update *fingers crossed
I don't have any knowledge of Python programming, but I'm trying to solve this issue using ChatGPT (3.5)
As pszafer mentioned, the aioxmpp library is not compatible with Python 3.12, so we need to adapt the code of the component to this version.
First of all you need access to your system as root, I use hass os so I follow the steps described in this dev guide
The component runs in homeassistant container in my case. To access it (once connected to SSH as root), I used:
docker exec -it homeassistant bash
Once inside container terminal, locate the route of the package:
pip show aioxmpp
The file that contains the match_hostname function is security_layer.py so edit with vi but make a backup just in case
cd /usr/local/lib/python3.12/site-packages/aioxmpp
cp security_layer.py security_layer.py.bak
vi security_layer.py
This is the code generated by ChatGPT:
import re
def check_x509_hostname(x509, hostname):
"""
Check whether the given :class:`OpenSSL.crypto.X509` certificate `x509`
matches the given `hostname`.
Return :data:`True` if the name matches and :data:`False` otherwise.
"""
cert_structure = extract_python_dict_from_x509(x509)
if 'subjectAltName' not in cert_structure:
return False
for key, value in cert_structure['subjectAltName']:
if key == 'DNS' and _match_hostname(value, hostname):
return True
return False
def _match_hostname(cert_hostname, hostname):
if not cert_hostname:
return False
# Exact match
if cert_hostname == hostname:
return True
# Wildcard match
if cert_hostname.startswith("*."):
cert_hostname = cert_hostname[2:]
return (
hostname.count(".") > cert_hostname.count(".")
and hostname.endswith(cert_hostname)
and hostname.split(".")[0] != cert_hostname.split(".")[0]
)
# IPv4 literal address match
if re.match(r"\d+\.\d+\.\d+\.\d+$", cert_hostname):
return hostname == cert_hostname
# IPv6 literal address match
if ":" in cert_hostname:
# Normalize IPv6 address
cert_hostname = _normalize_ipv6(cert_hostname)
return hostname == cert_hostname
return False
def _normalize_ipv6(address):
"""
Normalize IPv6 address according to RFC 5952.
"""
parts = address.split(":")
if "" in parts:
empty_index = parts.index("")
parts = parts[:empty_index] + ["0"] * (8 - len(parts)) + parts[empty_index + 1:]
else:
parts += ["0"] * (8 - len(parts))
return ":".join(parts)
I don't know if the code is correct with my limited knowledge but its running again. Please, devs , check if this is ok.
I don't have any knowledge of Python programming, but I'm trying to solve this issue using ChatGPT (3.5)
As pszafer mentioned, the aioxmpp library is not compatible with Python 3.12, so we need to adapt the code of the component to this version.
First of all you need access to your system as root, I use hass os so I follow the steps described in this dev guide
The component runs in homeassistant container in my case. To access it (once connected to SSH as root), I used:
docker exec -it homeassistant bash
Once inside container terminal, locate the route of the package:
pip show aioxmpp
The file that contains the match_hostname function is security_layer.py so edit with vi but make a backup just in case
cd /usr/local/lib/python3.12/site-packages/aioxmpp
cp security_layer.py security_layer.py.bak
vi security_layer.py
This is the code generated by ChatGPT:
1. Add the import at the begining of the script
import re
2. Replace the definition of check_x509_hostname
def check_x509_hostname(x509, hostname): """ Check whether the given :class:`OpenSSL.crypto.X509` certificate `x509` matches the given `hostname`. Return :data:`True` if the name matches and :data:`False` otherwise. """ cert_structure = extract_python_dict_from_x509(x509) if 'subjectAltName' not in cert_structure: return False for key, value in cert_structure['subjectAltName']: if key == 'DNS' and _match_hostname(value, hostname): return True return False
3. Add this two functions
def _match_hostname(cert_hostname, hostname): if not cert_hostname: return False # Exact match if cert_hostname == hostname: return True # Wildcard match if cert_hostname.startswith("*."): cert_hostname = cert_hostname[2:] return ( hostname.count(".") > cert_hostname.count(".") and hostname.endswith(cert_hostname) and hostname.split(".")[0] != cert_hostname.split(".")[0] ) # IPv4 literal address match if re.match(r"\d+\.\d+\.\d+\.\d+$", cert_hostname): return hostname == cert_hostname # IPv6 literal address match if ":" in cert_hostname: # Normalize IPv6 address cert_hostname = _normalize_ipv6(cert_hostname) return hostname == cert_hostname return False def _normalize_ipv6(address): """ Normalize IPv6 address according to RFC 5952. """ parts = address.split(":") if "" in parts: empty_index = parts.index("") parts = parts[:empty_index] + ["0"] * (8 - len(parts)) + parts[empty_index + 1:] else: parts += ["0"] * (8 - len(parts)) return ":".join(parts)
I don't know if the code is correct with my limited knowledge but its running again. Please, devs , check if this is ok.
Wow, when I read ChatGPT I had low expectations, but this actually works! Even if the code is buggy (looks good to me though) I guess the only impact is that it's open to a man in the middle attach, which I am not too worried about for this application. Would be nice if someone with actual coding skills considers this fix. For now, I'm happy to be on this version of HomeAssistant, even if I have to 'patch' with every update.
Thanks!
FYI You have to patch after every restart of HA.
FYI You have to patch after every restart of HA.
Is this also the case when running HA locally on a machine instead of in a docker container? I guess these fixes aren't persistent but I'm not sure if this also is the case for local installs.
FYI You have to patch after every restart of HA.
Yeah, after every update of homeassistant (not every restart)
What is the current plan? aioxmpp seems to be dead in the long term. Is slixmpp perhaps a suitable replacement? There is at least current activity in the repo, and the last release was this month.
I actually wanted to try swapping the lib myself in order to create a pr if necessary, but I'm currently failing to get the depedencies with pip without any errors using Python 3.12 -.-
The plan is to rewrite xmpp part of the lib to use Slixmpp, but for now I failed to make it work. It needs to be written in HTTP style, GET -> RESPONSE or PUT -> RESPONSE and make context, together with some sort of queue, so it won't push next message until last one is received or abandoned.
I am very sorry for posting when the thread is closed. I would just like to know if the problem occurs when I don't use xmpp connect, but HTTP. Thanks
This is not closed, right?
it's not closed
Question to the developpers @pszafer and @depuytnl. Would it be an idea to create a version with the workaround of @depuytnl so we are able to upgrade our HA environment to version 2024.2 and above until @pszafer is ready with the "new" compatible version?
@pszafer I'm not pushing you because I know programming and testing takes a lot of time, but any idea when we can expect the updated version is it weeks, months or........?
It's not possible as it is system package. Weeks I guess, I'm injured and unfortunately unable to work for a few weeks... https://github.com/bosch-thermostat/home-assistant-bosch-custom-component/issues/390#issuecomment-1965056042
I am very sorry for posting when the thread is closed. I would just like to know if the problem occurs when I don't use xmpp connect, but HTTP. Thanks
I used xmpp (why I'm not sure) and switched to http and it now workes fine.
So if you guys are using xmpp but have local access to your bosch, switch to local http instead.
I am very sorry for posting when the thread is closed. I would just like to know if the problem occurs when I don't use xmpp connect, but HTTP. Thanks
I used xmpp (why I'm not sure) and switched to http and it now workes fine.
So if you guys are using xmpp but have local access to your bosch, switch to local http instead.
Can you maybe elaborate how to switch from xmpp to http? Does this need to be done in the Nefit Easy app? Also, can we simply update the HA core after this change or do we also need to change something in HA itself?
Because I'm not sure how or where I switch from xmpp to http, but I may be new to this kind of procedures.
Thanks in advance! :)
What thermostat you are using ?
I have the TC100 from Nefit ..
I am very sorry for posting when the thread is closed. I would just like to know if the problem occurs when I don't use xmpp connect, but HTTP. Thanks
I used xmpp (why I'm not sure) and switched to http and it now workes fine.
So if you guys are using xmpp but have local access to your bosch, switch to local http instead.
Can you maybe elaborate how to switch from xmpp to http? Does this need to be done in the Nefit Easy app? Also, can we simply update the HA core after this change or do we also need to change something in HA itself?
Because I'm not sure how or where I switch from xmpp to http, but I may be new to this kind of procedures.
Thanks in advance! :)
I didn't know how to switch either :) So instead I uninstalled the Bosch integration and then reinstalled it again with http settings instead of xmpp. Somewhere in this install process you can choose between xmpp and http. If your heating system is on the same network as your HA you should be able to do this. I think the http option is only available for IVT systems. The HA version can most likely be changed at any time.
What thermostat you are using ?
I have the TC100 from Nefit ..
I use the RC300 also from Netfit.
I am very sorry for posting when the thread is closed. I would just like to know if the problem occurs when I don't use xmpp connect, but HTTP. Thanks
I used xmpp (why I'm not sure) and switched to http and it now workes fine.
So if you guys are using xmpp but have local access to your bosch, switch to local http instead.
Can you maybe elaborate how to switch from xmpp to http? Does this need to be done in the Nefit Easy app? Also, can we simply update the HA core after this change or do we also need to change something in HA itself? Because I'm not sure how or where I switch from xmpp to http, but I may be new to this kind of procedures. Thanks in advance! :)
I didn't know how to switch either :) So instead I uninstalled the Bosch integration and then reinstalled it again with http settings instead of xmpp. Somewhere in this install process you can choose between xmpp and http. If your heating system is on the same network as your HA you should be able to do this. I think the http option is only available for IVT systems. The HA version can most likely be changed at any time.
Thanks for the information. I use the CT100 and when configuring the integration I'm automatically on a page to set up the credentials and it uses XMPP. No option to choose between HTTP or XMPP, so maybe it depends on the thermostat? This was for the case for Easycontrol and Nefit when setting up the configuration.
Only IVT option supports HTTP.
I am very sorry for posting when the thread is closed. I would just like to know if the problem occurs when I don't use xmpp connect, but HTTP. Thanks
I used xmpp (why I'm not sure) and switched to http and it now workes fine.
So if you guys are using xmpp but have local access to your bosch, switch to local http instead.
Can you maybe elaborate how to switch from xmpp to http? Does this need to be done in the Nefit Easy app? Also, can we simply update the HA core after this change or do we also need to change something in HA itself?
Because I'm not sure how or where I switch from xmpp to http, but I may be new to this kind of procedures.
Thanks in advance! :)
I didn't know how to switch either :) So instead I uninstalled the Bosch integration and then reinstalled it again with http settings instead of xmpp. Somewhere in this install process you can choose between xmpp and http. If your heating system is on the same network as your HA you should be able to do this. I think the http option is only available for IVT systems. The HA version can most likely be changed at any time.
Thanks for the information. I use the CT100 and when configuring the integration I'm automatically on a page to set up the credentials and it uses XMPP. No option to choose between HTTP or XMPP, so maybe it depends on the thermostat? This was for the case for Easycontrol and Nefit when setting up the configuration.
Only IVT option supports HTTP.
In the step where you choose device type I choose IVT. Probably the reason why you can't choose http and I can in the next step.
I can confirm that IVT via HTTP is working for the Bosch/Junkers MB LANi module via the local network...
Does not work for the Junkers CT100 :(
FYI, although not fixed, I applied the changes suggested by KarlosHYD (ChatGPT) and it works for me. To ensure it survives updates I have updated the file, which I mount in the container and then execute a copy after having updated the container.
docker exec homeassistant sh fixsecurity.sh && docker restart homeassistant #run nefit easy security fix
where fixsecurity contains:
cp security_layer.py /usr/local/lib/python3.12/site-packages/aioxmpp/security_layer.py
Not a great fix, but though it might be helpful for some
Can anyone tell me how to apply this fix when running HA OS on a pi?
Please, test new release and let me know if it is working https://github.com/bosch-thermostat/home-assistant-bosch-custom-component/releases/tag/v0.25.0-dev.3 I wasn't able to test everything, so I really want your feedback
Works flawless with lastest beta release with HA Core 2024.2.2 using IVT (Rc300)
Have not tested with 2024.3 yet. Thank you so much ❤️🤟
Works for me @2024.3 only getting a "Using slower stringprep, consider compiling the faster cython/libidn one." warning
Warning is normal, HA doesn't ship faster method.
Beta working for me with my Bosch Worcester Wave boiler using NEFIT set up.
Stopped working @2024.3 after approximately 6,5h:
with another bosch related error in another module during this period:
`Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
Logger: homeassistant Quelle: custom_components/bosch/init.py:449 Integration: Bosch thermostat (Dokumentation, Probleme) Erstmals aufgetreten: 05:14:28 (1 Vorkommnisse) Zuletzt protokolliert: 05:14:28
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/bosch/init.py", line 449, in firmware_refresh
await self.gateway.check_firmware_validity()
File "/usr/local/lib/python3.12/site-packages/bosch_thermostat_client/gateway/base.py", line 359, in check_firmware_validity
fw = await self._connector.get(self._db.get(BASE_FIRMWARE_VERSION))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bosch_thermostat_client/connectors/xmpp.py", line 115, in get
raise DeviceException(f"Error requesting data from {path}")
bosch_thermostat_client.exceptions.DeviceException: Error requesting data from /gateway/versionFirmware
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
Logger: bosch_thermostat_client.sensors.sensor Quelle: custom_components/bosch/init.py:412 Integration: Bosch thermostat (Dokumentation, Probleme) Erstmals aufgetreten: 03:32:29 (770 Vorkommnisse) Zuletzt protokolliert: 08:39:52
Can't update data for Outdoor temperature. Trying uri: /system/sensors/temperatures/outdoor_t1. Error message: Error requesting data from /system/sensors/temperatures/outdoor_t1 Can't update data for Actual supply temp. Trying uri: /system/sensors/temperatures/supply_t1. Error message: Error requesting data from /system/sensors/temperatures/supply_t1 Can't update data for Return temp. Trying uri: /system/sensors/temperatures/return. Error message: Error requesting data from /system/sensors/temperatures/return Can't update data for Actual modulation. Trying uri: /heatSources/actualModulation. Error message: Error requesting data from /heatSources/actualModulation Can't update data for Actual supply temperature for HC. Trying uri: /heatingCircuits/hc1/actualSupplyTemperature. Error message: Error requesting data from /heatingCircuits/hc1/actualSupplyTemperature`
Hi Pawel,
The latest beta release is working for me too!
IVT RC300/RC310/Nefit Moduline 3000 HA Core: 2024.3.0 HA Supervisor: 2024.02.1
Sent a small thank you as appreciation for your time and expertice on this project.
Pat
Hi Pawel,
I'm new in HA, how can I upgrade it to 0.25.0-den.3 if I have HA version 2024.3.0. Which tool I may use for it :-) Or is available this version like ease upgrade installation? Regard Jiri
Either you checkout the dev branch in github and copy the code to your custom_components folder or if you use HACS use the beta switch:
https://hacs.xyz/docs/faq/beta/
Don't forget to reboot HA
I did all like you wrote, install it like beta 25.0 dev 3 and reboot HA. But if try add new device via device type=IVT, Bosch IVT Protocol = HTTP, IP adresa from router (i tried use ping to this adres and work well) token and password from IVT AIR-X display menu, after use button "send" is proces finished, but still is there error Unknown model.
Hello Pawel,
I tested and is working like charm!
Device: Buderus CT100 (NEFIT XMPP ) Component: v0.25.0-dev.3 HA Core: 2024.3.0 HA Supervisor: 2024.02.1 OS: 12.0
I send you a small contrib 🙇
Thanks! I'll wait one more day and release stable version.
CT100 via NEFIT XMPP working perfectly again :)
I had to deactivate the plugin completely, no one else had any problems after a few hours? Compress 7001 IVT xmpp
CT100 Belgium seems to work like a charm again, however I do see the following errors in the log:
Exception in async_update when dispatching 'bosch_sensor_update': () Traceback (most recent call last): File "/config/custom_components/bosch/sensor/base.py", line 120, in async_update self._state = None if self._attr_state_class == "measurement" else self._bosch_object.state ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 345, in _getter return getattr(o, private_attr_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'BoschSensor' object has no attribute '__attr_state_class'. Did you mean: '_attr_state_class'?
Update for sensor.notifications fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1262, in async_device_update await self.async_update() File "/config/custom_components/bosch/sensor/base.py", line 120, in async_update self._state = None if self._attr_state_class == "measurement" else self._bosch_object.state ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 345, in _getter return getattr(o, private_attr_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'BoschSensor' object has no attribute '__attr_state_class'. Did you mean: '_attr_state_class'?
Can't update data for Total year usage. Trying uri: /ecus/rrc/recordings/yearTotal. Error message: Error requesting data from /ecus/rrc/recordings/yearTotal
Using slower stringprep, consider compiling the faster cython/libidn one.
I have a Junkers CT100 I installed the beta v0.25.0-dev.3 via HACS HA 2024.3.0 Operating System 12.0
It works! Will check back in a few hours if it still works.
Still going strong!
v0.25.0-dev.3 works for me with Control Connect
You can also try https://github.com/bosch-thermostat/home-assistant-bosch-custom-component/pull/396 against the default branch which works with aioxmpp
You can also try #396 against the default branch which works with aioxmpp
Interesting fix. Does the dev.3 version not work for you? I'd say that replacing an unmaintained outdated component is the better route?
Describe the bug Get the below error on initialization after upgrade to current version of Homeassistant (2024.2.0);
A clear and concise description of what the bug is.
File "/usr/local/lib/python3.12/site-packages/aioxmpp/security_layer.py", line 230, in check_x509_hostname ssl.match_hostname(cert_structure, hostname) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'ssl' has no attribute 'match_hostname' 2024-02-08 13:18:04.170 INFO (MainThread) [custom_components.bosch] Setting up Bosch component version 0.24.6. 2024-02-08 13:18:04.171 DEBUG (MainThread) [custom_components.bosch] Initializing Bosch integration. 2024-02-08 13:18:04.171 DEBUG (MainThread) [custom_components.bosch] Checking connection to Bosch gateway as ########. 2024-02-08 13:18:04.337 ERROR (MainThread) [homeassistant] Error doing job: Fatal error on tls handshake Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aioopenssl/init.py", line 355, in _tls_do_handshake self._tls_conn.do_handshake() File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 2202, in do_handshake self._raise_ssl_error(self._ssl, result) File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 1802, in _raise_ssl_error self._context._verify_helper.raise_if_problem() File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 456, in raise_if_problem raise self._problems.pop(0) File "/usr/local/lib/python3.12/site-packages/OpenSSL/SSL.py", line 481, in wrapper result = callback( ^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aioxmpp/security_layer.py", line 300, in verify_callback if not check_x509_hostname( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aioxmpp/security_layer.py", line 230, in check_x509_hostname ssl.match_hostname(cert_structure, hostname) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'ssl' has no attribute 'match_hostname' 2024-02-08 13:18:04.341 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback None()
To Reproduce Steps to reproduce the behavior:
Expected behavior I expect the integration to initialize like it did before the upgrade
Screenshots NA
Version
Debug SCAN IMPORTANT Go to Developer tools in Home Assistant, choose Service tab and choose
bosch.debug_scan
Download file to your computer and upload it somewhere eg. https://jsonblob.com/ ----> I don't seem to have this serviceAdditional context Add any other context about the problem here.