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

Integration stopped working with HA 2022.7.0 #130

Closed
bezibaerchen opened this issue Jul 7, 2022 · 63 comments · Fixed by #134
Closed

Integration stopped working with HA 2022.7.0 #130

bezibaerchen opened this issue Jul 7, 2022 · 63 comments · Fixed by #134

Comments

@bezibaerchen
Copy link

I read about changes in Python.

Status as of now: "Failed to set up: Import error

@bezibaerchen
Copy link
Author

2022-07-07 12:06:39 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration freeathome: Exception importing custom_components.freeathome.config_flow

@bezibaerchen bezibaerchen changed the title Integration stopped working aith HA 2022.7.0 Integration stopped working with HA 2022.7.0 Jul 7, 2022
@Snipes999
Copy link

I do get the same error message, since I have installed 2022.7.

@miguelcastilho
Copy link

miguelcastilho commented Jul 7, 2022

I also see this error in my logs

This error originated from a custom integration.

Logger: homeassistant.loader
Source: custom_components/freeathome/fah/pfreeathome.py:21
Integration: Busch Jaeger/ABB Free@Home (documentation)
First occurred: 13:22:19 (15 occurrences)
Last logged: 14:30:26

Unexpected exception importing platform custom_components.freeathome.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 618, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 635, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/freeathome/config_flow.py", line 12, in <module>
    from .fah.pfreeathome import FreeAtHomeSysApp
  File "/config/custom_components/freeathome/fah/pfreeathome.py", line 21, in <module>
    from slixmpp.plugins.xep_0060.stanza.pubsub_event import Event, EventItems, EventItem
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0060/__init__.py", line 11, in <module>
    from slixmpp.plugins.xep_0060.pubsub import XEP_0060
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0060/pubsub.py", line 15, in <module>
    from slixmpp.plugins.xep_0060 import stanza
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0060/stanza/__init__.py", line 9, in <module>
    from slixmpp.plugins.xep_0060.stanza.pubsub import *
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0060/stanza/pubsub.py", line 11, in <module>
    from slixmpp.plugins import xep_0004
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0004/__init__.py", line 11, in <module>
    from slixmpp.plugins.xep_0004.stanza import Form
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0004/stanza/__init__.py", line 10, in <module>
    from slixmpp.plugins.xep_0004.stanza.form import Form
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0004/stanza/form.py", line 13, in <module>
    from slixmpp.thirdparty import OrderedSet
  File "/usr/local/lib/python3.10/site-packages/slixmpp/thirdparty/__init__.py", line 7, in <module>
    from slixmpp.thirdparty.orderedset import OrderedSet
  File "/usr/local/lib/python3.10/site-packages/slixmpp/thirdparty/orderedset.py", line 25, in <module>
    class OrderedSet(collections.MutableSet):
AttributeError: module 'collections' has no attribute 'MutableSet'

@StevenBoelhouwer
Copy link

StevenBoelhouwer commented Jul 8, 2022

Looks like the error is not in the freeathome part but in a required package. I wonder if updating the "requirements" to a later version (slixmpp==1.8.2) will fix the issue or raise a couple new ones.

@jeroen84
Copy link
Contributor

jeroen84 commented Jul 8, 2022

I have created a PR as a first try to fix this issue. Upgraded slixmpp and made a small code change. Please go to #131 to verify the change.

@theuzzy
Copy link

theuzzy commented Jul 8, 2022

Sadly new errors:

This error originated from a custom integration.

Logger: homeassistant.loader
Source: custom_components/freeathome/fah/crypto.py:2
Integration: Busch Jaeger/ABB Free@Home (documentation)
First occurred: 8:21:33 PM (4 occurrences)
Last logged: 8:21:58 PM

Unexpected exception importing platform custom_components.freeathome.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 618, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 635, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/freeathome/config_flow.py", line 12, in <module>
    from .fah.pfreeathome import FreeAtHomeSysApp
  File "/config/custom_components/freeathome/fah/pfreeathome.py", line 39, in <module>
    from .saslhandler import SaslHandler
  File "/config/custom_components/freeathome/fah/saslhandler.py", line 7, in <module>
    from .crypto import Crypto, loginSaslPayload, buildSaslResponse
  File "/config/custom_components/freeathome/fah/crypto.py", line 2, in <module>
    import libnacl
  File "/usr/local/lib/python3.10/site-packages/libnacl/__init__.py", line 85, in <module>
    nacl = _get_nacl()
  File "/usr/local/lib/python3.10/site-packages/libnacl/__init__.py", line 81, in _get_nacl
    raise OSError(msg)
OSError: Could not locate nacl lib, searched for libsodium.so, libsodium.so.23, libsodium.so.18, libsodium.so.17, libsodium.so.13, libsodium.so.10, libsodium.so.5, libsodium.so.4, 

@AStenzel
Copy link

AStenzel commented Jul 8, 2022

Sadly new errors:

This error originated from a custom integration.

Logger: homeassistant.loader
Source: custom_components/freeathome/fah/crypto.py:2
Integration: Busch Jaeger/ABB Free@Home (documentation)
First occurred: 8:21:33 PM (4 occurrences)
Last logged: 8:21:58 PM

Unexpected exception importing platform custom_components.freeathome.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 618, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 635, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/freeathome/config_flow.py", line 12, in <module>
    from .fah.pfreeathome import FreeAtHomeSysApp
  File "/config/custom_components/freeathome/fah/pfreeathome.py", line 39, in <module>
    from .saslhandler import SaslHandler
  File "/config/custom_components/freeathome/fah/saslhandler.py", line 7, in <module>
    from .crypto import Crypto, loginSaslPayload, buildSaslResponse
  File "/config/custom_components/freeathome/fah/crypto.py", line 2, in <module>
    import libnacl
  File "/usr/local/lib/python3.10/site-packages/libnacl/__init__.py", line 85, in <module>
    nacl = _get_nacl()
  File "/usr/local/lib/python3.10/site-packages/libnacl/__init__.py", line 81, in _get_nacl
    raise OSError(msg)
OSError: Could not locate nacl lib, searched for libsodium.so, libsodium.so.23, libsodium.so.18, libsodium.so.17, libsodium.so.13, libsodium.so.10, libsodium.so.5, libsodium.so.4, 

I also had this error.
It seems as if the APK for "libsodium" was removed in the "Home Assistant Operation System".

If you apply the PullRequest #131 from @jeroen84 in the code and run the integration in the Docker image (latest), then everything is found correctly and free@home integration is working fine.

As a workaround, I can only recommend the following (for "Home Assistant Operation System"-Users):

  • log in via SSH or Terminal
  • log into the docker container "homeassistant" via shell (e.g. docker exec -it homeassistant /bin/bash)
  • add the apk libsodium (apk add libsodium)
  • Restart homeassistant

@theuzzy
Copy link

theuzzy commented Jul 8, 2022

Another error:

This error originated from a custom integration.

Logger: slixmpp.basexmpp
Source: custom_components/freeathome/fah/pfreeathome.py:308 
Integration: Busch Jaeger/ABB Free@Home (documentation) 
First occurred: 22:50:31 (1 occurrences) 
Last logged: 22:50:31

local variable 'node_jid' referenced before assignment
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/slixmpp/xmlstream/xmlstream.py", line 1094, in handler_callback_routine
    await cb(data)
  File "/config/custom_components/freeathome/fah/pfreeathome.py", line 308, in start
    self['xep_0030'].static.add_identity(self.boundjid.full, capsversion, '', identity)
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0030/static.py", line 318, in add_identity
    new_node = self.add_node(jid, node)
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0030/static.py", line 88, in add_node
    if (node_jid, node, node_ifrom) not in self.nodes:
UnboundLocalError: local variable 'node_jid' referenced before assignment

@AStenzel
Copy link

AStenzel commented Jul 8, 2022

Another error:

This error originated from a custom integration.

Logger: slixmpp.basexmpp
Source: custom_components/freeathome/fah/pfreeathome.py:308 
Integration: Busch Jaeger/ABB Free@Home (documentation) 
First occurred: 22:50:31 (1 occurrences) 
Last logged: 22:50:31

local variable 'node_jid' referenced before assignment
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/slixmpp/xmlstream/xmlstream.py", line 1094, in handler_callback_routine
    await cb(data)
  File "/config/custom_components/freeathome/fah/pfreeathome.py", line 308, in start
    self['xep_0030'].static.add_identity(self.boundjid.full, capsversion, '', identity)
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0030/static.py", line 318, in add_identity
    new_node = self.add_node(jid, node)
  File "/usr/local/lib/python3.10/site-packages/slixmpp/plugins/xep_0030/static.py", line 88, in add_node
    if (node_jid, node, node_ifrom) not in self.nodes:
UnboundLocalError: local variable 'node_jid' referenced before assignment

Has the complete PR #131 also been applied?
This error reads like the 2nd fixed error in the PR (file: custom_components/freeathome/fah/pfreeathome.py)!

@rsegers
Copy link
Contributor

rsegers commented Jul 9, 2022

Applied PR #131 but that (alone) didn't work. Installing libsodium as mentioned above by AStenzel solved the issue. So now I have PR #131 and libsodium. Haven't tried it without the PR.

I'm running Home Assistant OS

@theuzzy
Copy link

theuzzy commented Jul 9, 2022

Applied PR #131 but that (alone) didn't work. Installing libsodium as mentioned above by AStenzel solved the issue. So now I have PR #131 and libsodium. Haven't tried it without the PR.

Same here, its working again (Had to reboot the Busch Jaeger / Free@Home).

How do I git clone the fix because when I do a git clone I get the old files without the fix. :(

Anyway, thank you for the fix and help!

@sstadlberger
Copy link

If you just want to get it working quickly again you can do a rollback to HA version 2022.6.7 with

ha core update --version 2022.6.7

@bartdorlandt
Copy link
Contributor

bartdorlandt commented Jul 9, 2022 via email

@AStenzel
Copy link

AStenzel commented Jul 9, 2022

As I'm lazy to repeat those steps each time after an update, I've create a simple script, that can be triggered via automation.
So all I have to do after an update is to initiate a restart of the system (via UI).

For all other lazy people, here are my scripts and settings respectively:

Shell-Script (/config/custom_components/freeathome/scripts/fah_requirements.sh):

#!/bin/bash
LIB_EXISTS=$(apk info | grep 'libsodium')
if [[ -z $LIB_EXISTS ]]; then
  apk add libsodium
fi

EDIT
Ensure that you set the executable bits!
chmod +x /config/custom_components/freeathome/scripts/fah_requirements.sh

Entry in global configuration.yaml:

shell_command:
  fah_requirements: '/config/custom_components/freeathome/scripts/fah_requirements.sh'

Entry in global automations.yaml:

- alias: fah_system_start
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: shell_command.fah_requirements

Short explanation:

When Home Assistant is started/restarted, the automation 'fah_system_start' is triggered, this executes the shell command 'fah_requirements' which triggers our script. The script itself first checks whether the apk is already installed and only installs it if this is not the case.

@bezibaerchen
Copy link
Author

I can also confirm applying the PR and apk adding libsodium brings FAH integration back to life and functionality

@bezibaerchen
Copy link
Author

As I'm lazy to repeat those steps each time after an update, I've create a simple script, that can be triggered via automation. So all I have to do after an update is to initiate a restart of the system (via UI).

For all other lazy people, here are my scripts and settings respectively:

Shell-Script (/config/custom_components/freeathome/scripts/fah_requirements.sh):

#!/bin/bash
LIB_EXISTS=$(apk info | grep 'libsodium')
if [[ -z $LIB_EXISTS ]]; then
  apk add libsodium
fi

Entry in global configuration.yaml:

shell_command:
  fah_requirements: '/config/custom_components/freeathome/scripts/fah_requirements.sh'

Entry in global automations.yaml:

- alias: fah_system_start
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: shell_command.fah_requirements

Short explanation:

When Home Assistant is started/restarted, the automation 'fah_system_start' is triggered, this executes the shell command 'fah_requirements' which triggers our script. The script itself first checks whether the apk is already installed and only installs it if this is not the case.

Thanks for this. As I tend to be a lazy person as well I also added that. Cheers mate.

@mrVoltrix
Copy link

Hi Guys,

I don't know what i'm doing wrong but i can't get it working.
I added the changes from PR #131
and I also integrated the script to adding libsodium again.
I'm running Home Assistant OS.

@jeroen84
Copy link
Contributor

Looks like this change breaks the integration: home-assistant/docker@e926373

This removed libsodium from the build of the Home Assistant base image. Home Assistant OS and Docker images are affected.

Not sure how to make a structural solution for this, other than adding libsodium as explained above.

@mrVoltrix
Copy link

Yes but when I try to do it like above, then I get this response back from the logbook:

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/init.py:115
Integration: Shell Command (documentation, issues)
First occurred: 13:36:07 (1 occurrences)
Last logged: 13:36:07

Error running command: /config/custom_components/freeathome/scripts/fah_requirements.sh, return code: 126
NoneType: None

@jeroen84
Copy link
Contributor

After a brief search a potential solution is switching to https://github.com/pyca/pynacl/ as a replacement for libnacl. This package is a standard dependency in Home Assistant https://github.com/home-assistant/core/blob/3429a75cc5d9be8560dfef5c2619d21273e2bffe/requirements_all.txt#L27

@Tho85
Copy link
Collaborator

Tho85 commented Jul 10, 2022

I also don't see an easy way to solve this. As @jeroen84 mentioned, the library was removed from the docker image, and since no other official component relies on it, chances are low that it will be re-added by the core team.

My workaround is to build a custom Docker image on my machine, however this may not be possible for everyone:

FROM homeassistant/home-assistant:2022.7.2
RUN apk add libsodium

The cleanest solution would be to replace libnacl with pynacl as outlined by @jeroen84, but this is not an easy switch. It would require to completely rewrite fah/crypto.py. Also, some methods would have to be added upstream to pynacl, i.e. the crypto_box_easy stuff added by @jheling in saltstack/libnacl#114

@AStenzel
Copy link

Yes but when I try to do it like above, then I get this response back from the logbook:

Logger: homeassistant.components.shell_command Source: /usr/src/homeassistant/homeassistant/components/shell_command/init.py:115 Integration: Shell Command (documentation, issues) First occurred: 13:36:07 (1 occurrences) Last logged: 13:36:07

Error running command: /config/custom_components/freeathome/scripts/fah_requirements.sh, return code: 126 NoneType: None

Seems that you don't have the correct permissions on "fah_requirements.sh"...
Try to set the executable bits and run again:

chmod +x /config/custom_components/freeathome/scripts/fah_requirements.sh

@AStenzel
Copy link

Looks like this change breaks the integration: home-assistant/docker@e926373

This removed libsodium from the build of the Home Assistant base image. Home Assistant OS and Docker images are affected.

Not sure how to make a structural solution for this, other than adding libsodium as explained above.

In fact, they have removed a number of libs.
Someone could try to add a request to add them back?
The mariadb-connector was also removed and added back 1 hour ago....
Just give it a try! ;-)

@mrVoltrix
Copy link

I give now all permits to fah_requirements.sh
But now I got another failure:

Error running command: `/config/custom_components/freeathome/scripts/fah_requirements.sh`, return code: 127
NoneType: None

I tried to add the libsodium manually:
it looks like its added OK: 95 MiB in 97 packages

But when I restart home assistant I get again faillures;

Deze fout is ontstaan door een aangepaste integratie.

Logger: homeassistant.loader
Source: custom_components/freeathome/fah/crypto.py:2
Integration: Busch Jaeger/ABB Free@Home (documentation)
First occurred: 21:16:03 (6 occurrences)
Last logged: 21:16:27

Unexpected exception importing platform custom_components.freeathome.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 618, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 635, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/freeathome/config_flow.py", line 12, in <module>
    from .fah.pfreeathome import FreeAtHomeSysApp
  File "/config/custom_components/freeathome/fah/pfreeathome.py", line 39, in <module>
    from .saslhandler import SaslHandler
  File "/config/custom_components/freeathome/fah/saslhandler.py", line 7, in <module>
    from .crypto import Crypto, loginSaslPayload, buildSaslResponse
  File "/config/custom_components/freeathome/fah/crypto.py", line 2, in <module>
    import libnacl
  File "/usr/local/lib/python3.10/site-packages/libnacl/__init__.py", line 85, in <module>
    nacl = _get_nacl()
  File "/usr/local/lib/python3.10/site-packages/libnacl/__init__.py", line 81, in _get_nacl
    raise OSError(msg)
OSError: Could not locate nacl lib, searched for libsodium.so, libsodium.so.23, libsodium.so.18, libsodium.so.17, libsodium.so.13, libsodium.so.10, libsodium.so.5, libsodium.so.4, 

@bezibaerchen
Copy link
Author

I had an update for freeathome yesterday, everything still worked afterwards.
libsodium and script still applied and changes from PR.

Now 2022-07.3 came up and it's broken again...

I guess HA guys don't make too many friends this time. I read that Homematic seems to be broken as well...

@bezibaerchen
Copy link
Author

Update: Script stopped working for me as well now. manually apk adding in shell and restarting HA brought integration back to life again

@AStenzel
Copy link

Update: Script stopped working for me as well now. manually apk adding in shell and restarting HA brought integration back to life again

Was broken for me after update to 2022-07.3. I did a restart of HA only and fah is working again.

My script tries to add the apk after every HA restart, but this trigger is handled after integration tries to start, that's why I have to do a 2nd restart after each update!

@AStenzel
Copy link

I give now all permits to fah_requirements.sh But now I got another failure:

Error running command: `/config/custom_components/freeathome/scripts/fah_requirements.sh`, return code: 127
NoneType: None

Check your path and try running the command via terminal or ssh.
If it works, you perhaps misspelled it in shell_command (configuration.yaml)...

@mrVoltrix
Copy link

  • homeassistant

I tried to do that, but when I login via SHH and following the instructions I get:

[core-ssh ~]$ docker exec -it homeassistant /bin/bash -bash: docker: command not found

@derjoerg
Copy link

  • homeassistant

I tried to do that, but when I login via SHH and following the instructions I get:

[core-ssh ~]$ docker exec -it homeassistant /bin/bash -bash: docker: command not found

Have you disabled safe-mode of your ssh-plugin?

@derjoerg
Copy link

  • homeassistant

I tried to do that, but when I login via SHH and following the instructions I get:
[core-ssh ~]$ docker exec -it homeassistant /bin/bash -bash: docker: command not found

Have you disabled safe-mode of your ssh-plugin?

It looks like you use the "ssh" addon from the official repository. Remove it and use the "ssh" addon from the community store. This has docker installed.

@mrVoltrix
Copy link

  • homeassistant

I tried to do that, but when I login via SHH and following the instructions I get:
[core-ssh ~]$ docker exec -it homeassistant /bin/bash -bash: docker: command not found

Have you disabled safe-mode of your ssh-plugin?

It looks like you use the "ssh" addon from the official repository. Remove it and use the "ssh" addon from the community store. This has docker installed.

Thanks, This was the problem. Now everything is working again ;)

@RichardvanGestel
Copy link

Also with the update to 2022.6.7 freeathome does not work...
Will this be resolved?

@NeoBlack
Copy link

I also run into this issue, I have installed a fresh 2022.7.6 and are not able to get free@home running :(
I killed my old home bridge raspberry to start over with Home Assistant, and now I have nothing :D (yes, I know... you better have a backup)

@RichardvanGestel
Copy link

Also with the update to 2022.7.7 freeathome does not work...
Backup is my best friend..;)

@derjoerg
Copy link

Hi,

as I see a lot of "F@H isn't working" messages in this issue I wanted to share my experience with it. Perhaps it helps ...

Main thanks goes to @bezibaerchen and the following comment #130 (comment), which helped me to get F@H working in 2022.7 (from 2022.7.1 to 20.22.7.7).

Pre-Info:

  • I'm running HA on a RPI 4 as HassOS (currently in version 8.4). I can't speek for any other deployment method

Root cause:

  • The F@H addon requires the package "libsodium" to function correctly. This was removed from the docker-image with the following change home-assistant/docker@e926373

Pre-Step (for troubleshooting and so on):

  • Install the ssh-addon from the community-store (NOT from the official store) and disable safe-mode
    • Just as an FYI: If you ssh to a HA-instance running in docker-mode you are connected to the ssh-docker-image and NOT to the docker-image HA is running. So everything you change in the ssh-docker-image doesn't help with HA as it is a complete different environment
    • You can test this step in the following way:
      • SSH to your HA-instance
      • Execute docker exec -ti homeassistant bash
      • If you don't get an error, but see a "bash-xxx" prompt you have correctly set it up

Test-Step:

  1. SSH to your HA-instance
  2. Switch to the homeassistant-docker-instance docker exec -ti homeassistant bash
  3. Execute the following command apk info | grep 'libsodium'
  4. You should see no output, which means that the package libsodium is not installed
  5. Execute the command apk add libsodium
  6. After the command has finished restart HA (Settings - System - Restart [in the upper right corner)
  7. After the restart F@H should work again as expected
    a. If not, sorry, I'm out :(
    b. If yes, read on :)

So if you come to this point your F@H integration should work as expected. You can restart HA and still F@H should work. The drawback of this is, that, because of the nature of a docker-image, each update of HA will override this modification and you have to do the steps above again.

Making it permanent:

  1. SSH to your HA-instance
  2. Switch to the homeassistant-docker-instance docker exec -ti homeassistant bash
    a. You are now in the 'config' directory. I created a sub-directory 'scripts', which contains all my shell-scripts, but this isn't necessary. You just need to remember where you are :)
  3. Create an empty file touch fah_requirements.sh
    a. Make the file executable chmod +x fah_requirements.sh
    b. When doing a ls -l I see that existing files below to an user:group 911 and my newly created file belows to an user:group root
    c. I don't know if it is important, but it doesn't hurt, so I change the user:group to 911 chown 911: fah_requirements.sh
  4. Put the following lines in the file as outlined by @bezibaerchen in the above linked comment
#!/bin/bash
LIB_EXISTS=$(apk info | grep 'libsodium')
if [[ -z $LIB_EXISTS ]]; then
  apk add libsodium
fi
  1. Save and close the file
  2. Test the file by executing it ./fah_requirements.sh
  3. You should see no output and a echo $? should return 0, which means: no error
  4. Display the full path of the file by executing realpath fah_requirements.sh
    a. This display in my environment /config/scripts/fah_requirements.sh but may be different in your environment (see above step 2)
    b. Save this output somewhere
  5. You can now leave the ssh-session and use your prefered method to modify configuration.yaml
  6. Add the following lines to your configuration (and don't forget to save):
shell_command:
  fah_requirements: /config/scripts/fah_requirements.sh

(Replace the directory and filename with your setup you collected in step 8)
11. Restart HA
12. Create a new automation:

Trigger type: Home Assistant (Event: Start)
Action type: Call service (Shell Command: fah_requirements)
- id: fah_requirements
  alias: FAH System Start
  trigger:
  - platform: homeassistant
    event: start
  action:
  - service: shell_command.fah_requirements
    data: {}
  mode: single

Final consideration:

  • There is just one problem left: The shell_command is executed by HA AFTER it loads the integrations. This means:
    • During "normal" restarts everything is working as expected
    • If you do an update of HA and it restarts, the F@H integration will fail on the first run
    • After doing another restart F@H should work again

I hope this write-down helps somebody to get the F@H-integration working again. For sure, this is not a permanent fix (I don't have the technical knowledge to propose a permanent fix), but it is working [at least for me]. I successfully upgraded HA all the way from 2022.7.1 till the current 2022.7.7 with just this one additional restart required.

Regards

@NeoBlack
Copy link

Thanks for the summary, I started from scratch and followed your instructions, and now it works for me too.

@miguelcastilho
Copy link

The guide from @derjoerg also works for me. Thank you so much.
As for a permanent solution, let's hope this integration can be modified to work without the libsodium package.

@NeoBlack
Copy link

As for a permanent solution, let's hope this integration can be modified to work without the libsodium package.
I am not familiar with the programming language behind this integration, but is it not possible to define and deliver the missing dependency directly with the integration?

@jeroen84
Copy link
Contributor

As a permanent solution I think we have two options:

  1. Switch from libnacl to pynacl package.
  2. Make a fork of libnacl and include libsodium in the pypi package build.

For 1, this is complex as outlined by @Tho85 .

For 2, this is a similar approach as how pynacl is build - it is dependent on libsodium as well - and the reason why this package works with HA.

Any other thoughts?

@derjoerg
Copy link

2 sounds for me like the way, which would result in less effort.

I would be happy to test :)

@Gersh1970
Copy link

The guide worked for me too. Thanks a lot!
Just one small thing to pay attention to: be a little patient, it can take up a minute before you see the switches in your dashboard appear again. I was al little too impatient and restored a backup twice thinking I had done something wrong.

@RichardvanGestel
Copy link

Also with version 2022.8 free@home does not work. I'm seriously concerned now.

@bezibaerchen
Copy link
Author

Workaround still working though, just confirmed here

@RichardvanGestel
Copy link

Workaround still working though, just confirmed here

I thought that was a bit complicated.. and wasn't sure it would work for me..
This afternoon I just sat down... and miraculously, it works!
Thanks!

@derjoerg
Copy link

derjoerg commented Aug 5, 2022

Workaround with 2022.8.1 still working

@SuperMaximus1984
Copy link

5. apk add libsodium

Could you please help with the error I get after fully following your guide?
`Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/init.py:115
Integration: Shell Command (documentation, issues)
First occurred: 18:49:42 (1 occurrences)
Last logged: 18:49:42

Error running command: /usr/share/hassio/homeassistant/custom_components/freeathome/scripts/fah_requirements.sh, return code: 127
NoneType: None`

My full path is mentioned above, though I tried only pointing to config path. No matter what it doesn't run within HA startup. Tired of installing libsodium manually via docker everytime after updates.

@jeroen84
Copy link
Contributor

All, I've look at the two options: #130 (comment)

Option 2 is very complex and not sustainable as it requires - next to time to develop and test - significant future maintenance. Option 1 should be considered to make this integration future proof.

I've made a first try, but this is not working yet. It cannot do a successful key exchange, perhaps because pynacl lacks an important libsodium function crypto_onetimeauth. If anybody has time to investigate and would like to contribute: https://github.com/jeroen84/freeathome/tree/move-pynacl

A third option we could consider is moving to the REST API. I notice that this option was considered ~2 years ago in #80

There were limitations of the API back then. Perhaps there are developments in due course that makes this option feasible?

@jeroen84
Copy link
Contributor

I have just pushed a PR for replacing libnacl with pynacl. This should fix the issue structurally. Please test on your setup: #134

@RichardvanGestel
Copy link

I have just pushed a PR for replacing libnacl with pynacl. This should fix the issue structurally. Please test on your setup: #134

It works fine here! Well done!
I'm running HA on intel nuc

@NeoBlack
Copy link

Super that it is fixed, when can we expect a new release? Just ask; no pressure :)

@theuzzy
Copy link

theuzzy commented Aug 17, 2022

Real nice guys! this works like a charm!
Update HA 2022.8.2 -> 2022.8.5

@Tho85
Copy link
Collaborator

Tho85 commented Aug 17, 2022

Super that it is fixed, when can we expect a new release? Just ask; no pressure :)

We do not currently use GitHub releases for this custom component.

Do you use HACS? I'm not an HACS user myself, but you should be able to update the component there somewhere.

@NeoBlack
Copy link

Thx, I will try that. I am very new to HomeAssistant and HACS. I don't know anything about the internal release process.
I will give it a try in the evening.

@fotiDim
Copy link

fotiDim commented Aug 17, 2022

I updated using HACS just fine. It updates to the latest commit.

@AStenzel
Copy link

I have just pushed a PR for replacing libnacl with pynacl. This should fix the issue structurally. Please test on your setup: #134

Works for me too!
Good job and thanks to all contributors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.