home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.07k stars 31.09k forks source link

gstreamer integration does not work on Home Assistant Core #72875

Open doughecka opened 2 years ago

doughecka commented 2 years ago

The problem

See this previous issue for more data:

When adding a gstreamer media player to the config the following error occurs: [homeassistant.components.hassio] Platform error media_player.gstreamer - No module named 'gi'

What version of Home Assistant Core has the issue?

2022.6.0

What was the last working version of Home Assistant Core?

unknown

What type of installation are you running?

Home Assistant OS

Integration causing the issue

gstreamer

Link to integration documentation on our website

https://www.home-assistant.io/integrations/gstreamer

Diagnostics information

No response

Example YAML snippet

media_player:
  - platform: gstreamer
    pipeline: "audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/tmp/snapcast_gstreamer"

Anything in the logs that might be useful for us?

ERROR (MainThread) [homeassistant.components.hassio] Platform error media_player.gstreamer - No module named 'gi'

Additional information

Seems that there are some missing components needed for this integration missing from Core, which prevents the integration from working out of the box.

probot-home-assistant[bot] commented 2 years ago

gstreamer documentation gstreamer source (message by IssueLinks)

calisro commented 2 years ago

I wonder if you'd should go in the home assistant OS github instead.

doughecka commented 2 years ago

Well, I thought core was for the container that runs HA, vs the OS that runs the container. The missing components are needed in Core, not OS. Unless I've got my nomenclature wrong. πŸ˜…

calisro commented 2 years ago

lol probably. I'm not sure. :\

tbarbette commented 2 years ago

I can confirm I have the error too :)

And using docker it's even worst, as mounting the gi package and .so libraries I get ImportError: Error relocating /usr/local/lib/python3.9/site-packages/gi/_gi.cpython-39-arm-linux-gnueabihf.so: __memcpy_chk: symbol not found

calisro commented 2 years ago

not stale.

Droow commented 2 years ago

Same here, also I'm unable to install these dependencies manually via ssh :(

linusgke commented 1 year ago

I'm also unable to use gstreamer!

Platform error media_player.gstreamer - No module named 'gi'

using

Home Assistant 2022.12.6
Supervisor 2022.11.2
Operating System 9.4
Frontend 20221213.0 - latest
linusgke commented 1 year ago
  1. Get access to the HA container:
docker exec -it homeassistant bash
  1. Install dependencies:
apk add gstreamer gstreamer-dev gstreamer-tools pkgconfig build-base cairo-dev cairo cairo-tools gobject-introspection-dev gst-plugins-good gst-plugins-bad gst-plugins-ugly  
  1. Install python packages:
pip install PyGObject
pip install pgi

After executing those commands, everything was working fine! I would really appreciate if any dev would implement those dependencies into the project.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

linusgke commented 1 year ago

Hello there,

this problem is still present! Due to the fact that the dependencies listed above are missing from HA Operating System, one is currently forced to manually install them after every core update!

Since I'm not too familiar with the technology behind HA I'd really appreciate someone with a better grasp to check in on this issue!

As for now, this integration is completely broken without manual intervention (see my comment above) and even results in preventing HA from restarting, due to faulty configuration.

Kind regards Linus

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

linusgke commented 1 year ago

Still a problem... not stale!

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

linusgke commented 1 year ago

Sadly still a problem... Still executing above mentioned commands after every core update.

thorbeenwiedemann commented 1 year ago

same problem here!

fraintt commented 1 year ago

I have the same problem. Why is there an integration, which obiously does not work in the official supported Installation HA-OS ???

Tsjoecha commented 11 months ago

This problem still exists on the december release.

Isn't there a way to automate this, through crontab for example?

linusgke commented 11 months ago

I'm honestly a bit helpless here! I'm not that much into HomeAssistant to get any grasp of where to address this issue to...

It might be due to missing dependencies in HA OS, it might be something with the core integration. I have no clue!

However it's sad, that the integration for the awesome tool GStreamer is, is broken for so long now...

yannok commented 11 months ago

same problem here, "No module named 'gi'"

there might be this (ugly) workaround yet : add a new line in the volume section of the docker-compose.yml to link the gi package from the host to the container :

volume:
- /usr/lib/python3/dist-packages/gi:/usr/local/lib/python3.11/site-packages/gi

(after having installed python3-gi on the host : apt install python3-gi)

In my case, the python versions are different on my host and in the docker container so it did not work (Platform error media_player.gstreamer - cannot import name '_gi' from partially initialized module 'gi'). But if I had the courage to compile the exact same python version on my host, that could possibly work...

joostlek commented 11 months ago

https://discord.com/channels/330944238910963714/1184253143979139082/1184253965228060883 I had some contact with @linusgke about gstreamer on Discord, feel free to give it a read on what we are trying to figure out now

linusgke commented 11 months ago

Summarizing our discord conversation: There should be a decision made about whether it's wise to include all the missing dependencies into HomeAssistant or abolish the core integration and make a custom integration out of it. My last test came to the conclusion that the following dependencies are mandatory to use the integration without any errors:

apk add gstreamer gst-plugins-good gst-plugins-bad gst-plugins-ugly gobject-introspection-dev pkgconfig build-base
pip install pgi PyGobject

We don't need gstreamer-tools gstreamer-dev cairo-dev cairo cairo-tools

gdesmott commented 11 months ago

apk add gstreamer gst-plugins-good gst-plugins-bad gst-plugins-ugly gobject-introspection-dev pkgconfig build-base

bad and ugly are, strictly speaking, not mandatory but will provide lots of commonly used plugins (especially bad).

fr34kyn01535 commented 9 months ago

Reminder that this still is an issue, just executed the command on the latest container, again...

fraintt commented 8 months ago

Hello, since updating to 2024.3.x I have again issue with this integration.

When Installing the missing dependencies I still get an error when checking the configuration that there is no module named gi.

Does anybody else also have the same?

Moreover, IΒ΄m curious, on how the Analytics in HASS is "reporting" the usage of this component back to the Analytics page. I on my own have 2 Installations where I use this, and based on this Github-Issue I assume IΒ΄m not alone. (I have Analytics enabled)

So why then it is displaying/saying that the Integration is used by "0" Installations in the Analytics?

https://analytics.home-assistant.io/integrations/ https://www.home-assistant.io/integrations/gstreamer/

Thanks!

linusgke commented 7 months ago

Update: Installing verson 3.44.2 using pip install PyGobject==3.44.2 worked. Since 3.47.0 PyGobject is using meson-python which breaks installation at the moment. Further info: https://gitlab.gnome.org/GNOME/pygobject/-/blob/master/NEWS

After updating to 2024.4.0 I'm no longer able to install PyGobject from the command line. I get the following error:

Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting PyGobject
  Downloading pygobject-3.48.1.tar.gz (714 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 714.5/714.5 kB 19.3 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  Γ— Preparing metadata (pyproject.toml) did not run successfully.
  β”‚ exit code: 1
  ╰─> [34 lines of output]
      Traceback (most recent call last):
        File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-55ul_ah8/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 985, in wrapper
          return func(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-55ul_ah8/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 1038, in build_wheel
          with _project(config_settings) as project:
        File "/usr/local/lib/python3.12/contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-55ul_ah8/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 912, in _project
          yield Project(source_dir, build_dir, meson_args, editable_verbose)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-55ul_ah8/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 635, in __init__
          self._meson = _get_meson_command(pyproject_config.get('meson'))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-55ul_ah8/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 947, in _get_meson_command
          meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.12/subprocess.py", line 548, in run
          with Popen(*popenargs, **kwargs) as process:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.12/subprocess.py", line 1026, in __init__
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "/usr/local/lib/python3.12/subprocess.py", line 1953, in _execute_child
          raise child_exception_type(errno_num, err_msg, err_filename)
      PermissionError: [Errno 13] Permission denied: 'meson'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Trying my best… I'm considering to install gstreamer on a separate machine and use SSH to call it from HA! Not a very good solution though!

fraintt commented 7 months ago

I have the same issue and error code as you @linusgke . I first wanted to check If IΒ΄m alone and post the error afterwards. So thanks for doing that part!

As this is an official integration, I would really appreciate if the devs would take a look on it.. as there are more than 3 Instances running gstreamer for sure and not "0" as reported by the analytics!

linusgke commented 7 months ago

@fraintt Good to know! You've seen the workaround I posted above to get it running again?

There are definitely more than zero instances running. I myself maintain 3 instances with Gstreamer installed.

fraintt commented 7 months ago

I actually used your workaround in the past, I have created myself shell_commands in order to install this automatically as soon as a new Version of HASS is installed.

But as stated above, also when trying your steps (also the "full" and "stripped-down") it still does not work and generates the same error on my side (permission denied - mason)

Funny! :D so we now have confirmed 5 (2 me, 3 you) Instances where gstreamer is used, but hass-analytics reports 0 ! (I repeat: I have analytics enabled on both installations)

linusgke commented 7 months ago

@fraintt Yeah, the instance counter seems to be inaccurate here… In terms of fixing, I was actually referring to my notice on the error message I posted.

Just in case you didn't see it:

Update: Installing verson 3.44.2 using pip install PyGobject==3.44.2 worked. Since 3.47.0 PyGobject is using meson-python which breaks installation at the moment. Further info: https://gitlab.gnome.org/GNOME/pygobject/-/blob/master/NEWS

PS: Your idea to automate the installation using shell_commands is genius! Did it right away.

fraintt commented 7 months ago

Thank you @linusgke it worked.

For the automation: I have a media player using gstreamer, and I am checking with an automation after hass start if the entity is defined with:

{{ states.media_player.tts.state is not defined }}

If "true" the shell commands (apk, and then pip) are triggered with a 2-3 minute delay inbetween each other.

A have not implemented an auto-hass restart after these commands for the media_player entity to be loaded properly.

Tsjoecha commented 7 months ago

I was also trying to automate this, but my nuc is too slow, and thus the installation is interrupted after 60 seconds. I'll have to look for another way to automate this.

Tsjoecha commented 4 months ago

I resolved it slightly different :

fi

fraintt commented 3 months ago

IΒ΄m a noob at programming, and I wanted to use some of our new AI toys to try to implement a permanent fix or propose a PR to close this, but IΒ΄m not that kind of a noob to understand that it only gave my garbage.

Fixing an official integration with a custom made script provided by the community <3

issue-triage-workflows[bot] commented 7 hours ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.