dmamontov / hass-ledfx

LedFx for Home Assistant
https://community.home-assistant.io/t/ledfx-deep-integration-component/366750
Apache License 2.0
44 stars 6 forks source link

Does not connect to the Led F X addon and the switches have no feedback #1

Closed DivanX10 closed 2 years ago

DivanX10 commented 2 years ago

OS: Home Assistant OS 7.0 Core: 2021.12.2 Supervisor: 2021.12.2 Led FX addon: ledfx Current version: 7d13080


Thank you for your integration, but there are problems with it

1) It is not possible to connect to the Led FX addon 2) The buttons have no feedback (I decided this in my own way and the answer is below)


About the Led FX addon

This integration can easily connect to the Led FX server that runs on Windows \ Ubuntu Server 20.04 LTS, but it cannot connect to the LedFX addon on Home Assistant and, accordingly, I cannot control the scenes. I created issues here


About switches

I can choose scenes through lighting, but in the integration there are also switches for turning on scenes and they just turn on any scene and do not show the real status. I made switches for myself that show the real status of the selected scene. Can you add feedback to your integration to turn scenes on and off?

Here I have described everything in detail what and how I did it. This works if Led FX is on Windows \ Ubuntu Server 20.04 LTS,

In the case of Windows \ Ubuntu Server 20.04 LTS, all this works fine, I attach videos \ screenshots and the code itself for the feedback switches

Screenshots ![image](https://user-images.githubusercontent.com/64090632/146368285-b320e5f7-fa00-4402-ad99-19e3add8cae5.png) ![image](https://user-images.githubusercontent.com/64090632/146368776-8e027151-a78d-4569-9799-34ee268ad734.png) ![image](https://user-images.githubusercontent.com/64090632/146368848-32b0913f-a340-4394-9794-6df86539f88b.png) ![image](https://user-images.githubusercontent.com/64090632/146369585-88f96eef-9a80-4e90-83bc-b956443ea30f.png)
Switches - code ``` switch: - platform: command_line switches: ledfx_scene_visualiser_blade_power: friendly_name: "LedFX Visualiser BladePower" command_timeout : 10 icon_template: mdi:music command_on: curl -L -X PUT 'http://192.168.5.27:8888/api/scenes' --data-raw '{"id":"blade-power","action":"activate"}' command_off: curl -L -X PUT 'http://192.168.5.27:8888/api/scenes' --data-raw '{"id":"music-off","action":"activate"}' command_state: curl -X GET 'http://192.168.5.27:8888/api/devices' | grep 'blade_power(Reactive)' - platform: command_line switches: ledfx_scene_visualiser_bands: friendly_name: "LedFX Visualiser Bands" command_timeout : 10 icon_template: mdi:music command_on: curl -L -X PUT 'http://192.168.5.27:8888/api/scenes' --data-raw '{"id":"bands","action":"activate"}' command_off: curl -L -X PUT 'http://192.168.5.27:8888/api/scenes' --data-raw '{"id":"music-off","action":"activate"}' command_state: curl -X GET 'http://192.168.5.27:8888/api/devices' | grep 'bands(Reactive)' - platform: command_line switches: ledfx_scene_visualiser_energy: friendly_name: "LedFX Visualiser Energy" command_timeout : 10 icon_template: mdi:music command_on: curl -L -X PUT 'http://192.168.5.27:8888/api/scenes' --data-raw '{"id":"energy","action":"activate"}' command_off: curl -L -X PUT 'http://192.168.5.27:8888/api/scenes' --data-raw '{"id":"music-off","action":"activate"}' command_state: curl -X GET 'http://192.168.5.27:8888/api/devices' | grep 'energy(Reactive)' ```

https://user-images.githubusercontent.com/64090632/146373859-88c43d17-6113-46da-8f5f-736e67d4f134.mp4

dmamontov commented 2 years ago

I have not tested it with the add-on. mk don't use it. the feedback is fine and is configurable with a timeout, as you can see from the readme. I can only suspect that it does not work in the addon, but send a log for that? + which version of ledfx are you using ?, only one is currently supported. if there are no messages in the log, enable the debug mode and send it too. And making separate requests for each switch is not good, I have a very bad effect on the system and the ledfx instance itself.

dmamontov commented 2 years ago

0.10.7 is only supported. update. if it does not work, you need logs.

DivanX10 commented 2 years ago

Do I understand correctly that the debug log needs to be included in the config? If true, then I will collect and send the logs, but I can't pull the logs out of the Led FX itself.

Here I can't copy the logs ![image](https://user-images.githubusercontent.com/64090632/146379036-6e7acfcf-b2e6-4f0f-8043-e072ebc8b806.png)
logger:
  default: fatal
  logs:
    homeassistant.components.ledfx: debug
dmamontov commented 2 years ago

Do I understand correctly that the debug log needs to be included in the config? If true, then I will collect and send the logs, but I can't pull the logs out of the Led FX itself.

from ledfx it is not necessary, it is necessary from home assistant.

dmamontov commented 2 years ago

I have an assumption that there is no return due to the fact that an error occurs. Perhaps it is related to the version.

DivanX10 commented 2 years ago
Led FX Integration Log ``` Logger: custom_components.ledfx.config_flow Source: custom_components/ledfx/config_flow.py:71 Integration: LedFx (documentation, issues) First occurred: 16:32:14 (3 occurrences) Last logged: 16:32:31 Error setting up LedFx API: LedFxConnectionError() ``` ``` 2021-12-16 16:43:32 WARNING (MainThread) [homeassistant.helpers.frame] Detected integration that called async_timeout.timeout with loop keyword argument. The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2. Please report issue to the custom component author for ledfx using this method at custom_components/ledfx/core/ledfx.py, line 40: with async_timeout.timeout(self.timeout, loop = self._loop): 2021-12-16 16:43:32 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/ledfx/config_flow.py", line 52, in async_step_auth await client.info() File "/config/custom_components/ledfx/core/ledfx.py", line 125, in info return await self.get("info", False) File "/config/custom_components/ledfx/core/ledfx.py", line 45, in get data = json.loads(await response.read()) File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2021-12-16 16:43:35 ERROR (MainThread) [custom_components.ledfx.config_flow] Error setting up LedFx API: LedFxConnectionError() 2021-12-16 16:43:44 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/ledfx/config_flow.py", line 52, in async_step_auth await client.info() File "/config/custom_components/ledfx/core/ledfx.py", line 125, in info return await self.get("info", False) File "/config/custom_components/ledfx/core/ledfx.py", line 45, in get data = json.loads(await response.read()) File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2021-12-16 16:43:48 ERROR (MainThread) [custom_components.ledfx.config_flow] Error setting up LedFx API: LedFxConnectionError() ```
Log from the LedFX addon ``` [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] 00-banner.sh: executing... ----------------------------------------------------------- Add-on: ledfx A network based LED effect controller with support for advanced real-time audio effects! ----------------------------------------------------------- Add-on version: 7d13080 You are running the latest version of this add-on. System: Home Assistant OS 7.0 (amd64 / qemux86-64) Home Assistant Core: 2021.12.2 Home Assistant Supervisor: 2021.12.2 ----------------------------------------------------------- Please, share the above information when looking for help or support in, e.g., GitHub, forums or the Discord chat. ----------------------------------------------------------- [cont-init.d] 00-banner.sh: exited 0. [cont-init.d] 01-log-level.sh: executing... [cont-init.d] 01-log-level.sh: exited 0. [cont-init.d] ledfx.sh: executing... [cont-init.d] ledfx.sh: exited 0. [cont-init.d] nginx.sh: executing... [cont-init.d] nginx.sh: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done. [14:50:53] INFO: Starting ledfx... [14:50:54] INFO: Starting NGinx... [WARNING ] ledfx.__main__ : Offline Mode Enabled - Please check for updates regularly. ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_card_id returned error: No such file or directory ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name ALSA lib conf.c:5111:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5599:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM dmix Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock ```

Would you be able to install the LedFX addon in your Home Assistant and connect to it through your LedFX integration? This will make it easier for you to localize the problem.

In the Led FX addon, Led FX v0.10.7 is installed, your integration works fine with Led FX v 0.10.5 if the Led FX v 0.10.5 server is on Windows \Ubuntu Server 20.04 LTS. Problem with access to the Led FX addon

The Led FX addon is here

Add a repository to the addon store

https://github.com/hassio-addons
dmamontov commented 2 years ago

try updating ledfx. I see from the text that the wrong json has arrived

DivanX10 commented 2 years ago

Specify whether to update the Led FX addon or the integration itself? If we are talking about the LedFX addon, then the addon is fresh. There, as I understand it, the integration simply does not have access to the internal address 127.0.0.1:8888, since the web interface works on a different address and a different port and it turns out that your LedFX integration physically cannot connect to 127.0.0.1:8888

image

That's why I suggest you install the LedFX addon yourself and personally check everything yourself and if it works for you, then write what and how you did it

DivanX10 commented 2 years ago

I found the problem. The problem turns out to be in the settings of the addon itself. It remains to understand how to fix it and who will fix it

When a bridge is specified in the addon, the Led FX integration cannot connect to the addon image

When the host is specified in the addon, the Led FX integration can connect to the addon image image image

dmamontov commented 2 years ago

translator have you tried to register not 127.0.0.1:8888 but 192.168.1.86:5333?

DivanX10 commented 2 years ago

Recorded on video, I think it will be clear

https://user-images.githubusercontent.com/64090632/146409081-33f93d3a-2a2b-482c-bcd3-1a798aa190cb.mp4

dmamontov commented 2 years ago

magic. and it is possible to log from Hass after all attempts of different authorizations?

I'm afraid of course that this is a network problem. but it would be interesting to understand.

DivanX10 commented 2 years ago

Tell me, how is it better to write in Russian or in English? By nickname you are Russian )

Text in English Because the local address is inside the docker and the bridge is turned on there, and we knock on it from the external network, where we are not allowed, and when we take the container outside and say, they say, you need to work not with the bridge, but in the same network, then the server will be available. I think that the question will need to be addressed to the author of the addon to fix it Why does the Home Assistant container work on the host so that we can connect to it, and the Led FX container decided to close from the outside, which leads to such problems ![image](https://user-images.githubusercontent.com/64090632/146410883-0ef9a6f6-4aea-4385-8aef-063e96a9da58.png) And it's still okay, the saddest thing is that OS Home Assistant does not like when there is a Portainer and it was removed from the addon, because the problem is known and the author has nothing left to remove the portainer addon from the addon. If we install it ourselves, we will get this error https://www.home-assistant.io/more-info/unsupported/software ![image](https://user-images.githubusercontent.com/64090632/146411240-02bbe2f3-7aa3-402b-b133-3bd30f59d1cc.png)
Текст на русском (Text in Russian) Потому что локальный адрес находится внутри докера и там включен мост, а мы стучимся к нему из внешней сети, куда нас и не пускают, а когда контейнер выводим наружу и говорим, мол, тебе надо работать не с мостом, а в одной сети, то тогда сервер будет доступен. Думаю, что вопрос надо будет адресовать автору аддона, чтобы это исправил Почему контейнер Home Assistant и работает на хосту, чтобы мы могли к нему подключаться, а контейнер LedFX решил закрыться от внешки, что и приводит к таким проблемам ![image](https://user-images.githubusercontent.com/64090632/146410883-0ef9a6f6-4aea-4385-8aef-063e96a9da58.png) И это еще ладно, самое печальное то, что OS Home Assistant не нравится, когда стоит Portainer и его убрали из аддона, потому что проблема известная и автору ничего не осталось, как убрать аддон портейнер из аддона. Если мы его ставим сами, то получим вот такую ошибку https://www.home-assistant.io/more-info/unsupported/software ![image](https://user-images.githubusercontent.com/64090632/146411240-02bbe2f3-7aa3-402b-b133-3bd30f59d1cc.png)
dmamontov commented 2 years ago

I looked at the addon now and you are right, you really need to edit the addon (

DivanX10 commented 2 years ago

OK, then I went to the author of the Led FX addon)

spiro-c commented 2 years ago

the problem is not the addon is not running on host network but that ledfx is running behind revers proxy and force you to login if you like to access the addon backend

Tell me, how is it better to write in Russian or in English? By nickname you are Russian )

Text in English Текст на русском (Text in Russian)

DivanX10 commented 2 years ago

@dmamontov

could you take this into account and refine your integration so that you can connect to the Led FX addon? My control has started working. Read here

DivanX10 commented 2 years ago

The question is removed. Closing the topic. In the latest version of the Led FX addon, you can now turn off authorization and thanks to this, you can now use LedFX integration.

In the settings of the Led FX addon, add the line leave_front_door_open: true

certfile: fullchain.pem
keyfile: privkey.pem
ssl: false
leave_front_door_open: true

In the Led FX integration settings, we specify

IP adress: localhost
Port: 5333

image

image