grimmpp / home-assistant-eltako

Integration for Eltako 14 series in Home Assistant
MIT License
33 stars 7 forks source link

Can't create gateway after update #18

Closed JSchmid6 closed 8 months ago

JSchmid6 commented 9 months ago

First, thanks a lot for your work. I am trying to get rid of good old fhem at the moment, and your integration is a lagre and important jigsaw piece for that. But today I run into a problem, where I need your help, I think. I installed version 1.2.1 today. After Update and change the configuration, i was not able to get it to run. I alway got no base_id. I tried to fix this several times. Thats when I recognised a discrepancies in your config. - Your config has device first and then base id and in your docu its vice versa. Fact is, none of both worked for me. After several attempts to fix this, I deleted the config and tried to reintegrate your component. There I got a 500 Internal Error and a log, that looks like that: 2023-12-14 21:29:16.051 WARNING (MainThread) [py.warnings] /usr/local/lib/python3.11/site-packages/bs4/builder/init.py:545: XMLParsedAsHTMLWarning: It looks like you're parsing an XML document using an HTML parser. If this really is an HTML document (maybe it's XHTML?), you can ignore or filter this warning. If it's XML, you should know that using an XML parser will be more reliable. To parse this document as XML, make sure you have the lxml package installed, and pass the keyword argument features="xml" into the BeautifulSoup constructor. warnings.warn(

2023-12-14 21:29:16.631 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, 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 80, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 147, in post return await super().post(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post result = await self._flow_mgr.async_init( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 880, in async_init flow, result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 908, in _async_init result = await self._async_handle_step(flow, flow.init_step, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 389, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 36, in async_step_user return await self.async_step_detect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 40, in async_step_detect return await self.manual_selection_routine(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 44, in async_step_manual return await self.manual_selection_routine(user_input, manual_setp=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eltako/config_flow.py", line 66, in manual_selection_routine return await self.async_step_manual(user_inp

It goes on and on. The dialog to input gateway never opens

Any suggestions?

JSchmid6 commented 9 months ago

Another thing. It would be nice of you, if you could replace the line in your serial validation function "def validate_path(path: str):" by "serial.serial_for_url(path, baudrate=57600, timeout=1)" this allows me to use a Serial over TPC Adapter. Thank you so much.

SteffenS27 commented 9 months ago

It is the same, I downgrade it for now

grimmpp commented 9 months ago

Hey guys, sorry for the inconvenience and changing the things back and forth. I've released with v1.2.2 a different way to define the gateway id. Is this working for you?

I also introduced many more tests to get rid of more low level bugs and the example config ha.yaml is also checked in unit tests now.

Regarding the serial adapter: Shall we add another gateway type for serial over TCP? What parameters would you need and which HW are you using?

SteffenS27 commented 9 months ago

Hi thanks for the answer, I made it work BUT now on every light, cover, ... it looks really confusing - the id is added on every name and also every temp-sensor is divided into 2 devices (for example target temp and temp - or humidity and temp) and also the name is not given any more. For me the old supperted version was the best - just add lights, covers, sensors - click on the usb device and ready

grimmpp commented 9 months ago

just change show_dev_id_in_dev_name in the config to False then is should remove the IDs of the names. Actually it should behave the same like before the only change you need to make is to add the gateway section in the config.

eltako:
  general_settings:
    fast_status_change: False   
    show_dev_id_in_dev_name: False
  gateway:
  - id: 1
    device_type: fgw14usb
    base_id: FF-AA-80-00
    name: FGW14-USB
    devices:
...
SteffenS27 commented 9 months ago

ok thanks - the name in the cover and lights are working but still the problem with the temp sensors exist - no name and they are divided into 2 devices - look here (in old version etherything was named and hum and temp was together): grafik grafik

grimmpp commented 9 months ago

Hello @SteffenS27,

you are right, sorry for that. Should be fixed now in v1.2.3-multiple-gateway-support

SteffenS27 commented 9 months ago

Thanks a lot - that looks great !

JSchmid6 commented 9 months ago

Hey guys, sorry for the inconvenience and changing the things back and forth. I've released with v1.2.2 a different way to define the gateway id. Is this working for you?

I also introduced many more tests to get rid of more low level bugs and the example config ha.yaml is also checked in unit tests now.

Regarding the serial adapter: Shall we add another gateway type for serial over TCP? What parameters would you need and which HW are you using?

Hey, sorry for my late answer. I'm using fgw14 + Elfin ew10 to connect the eltako bus. So the fgw14usb would be enough, I think they work equivalently. But with the new version I have the problem, that it is no longer possible to enter the path to the device manually. So, what I need to get it work again, is the ability to enter the path manual and a change in the gateway.py (line 418) would be nice. If we replace the line serial.Serial(path, baud_rate, timeout=0.1) by serial.serial_for_url(path, baud_rate, timeout=1.0), then a serial definitions like that is possible socket://:?logging=debug (compare https://pyserial.readthedocs.io/en/latest/url_handlers.html#urls). It works with your integration. I had it run as long as it was possible to enter the path manually.

There was still a problem remaining, with the light actors, but that's something I have to look for, if it runs again. (The light switches jumped back to off after 1 second).

grimmpp commented 9 months ago

Hello @JSchmid6 ,

if no usb device can be detected a text field is displayed in which you can enter the path manually. Unfortunately, I have no good idea how to switch to this views otherwise. Would that be sufficient for you? serial.serial_for_url(path, baud_rate, timeout=1.0) entered as well. would you like to have a specific device_type for your network solution? image

The changes are available under main branch directly.

JSchmid6 commented 8 months ago

I think it would be sufficient. However, if you have multiple USB devices and don't want to use one for your integration, this could pose a problem. What do you think about having an initial selection page where the customer (me, for now :-) ) can choose between auto-detection and manual input for the device? Alternatively, is it possible to add a field with a radio button for manual input? If you'd like, I can attempt to implement it, but I believe it may take some time.

grimmpp commented 8 months ago

Hey @JSchmid6,

I've tried out many things now. It turned out in HA it is not possible to offer something like an installation menu. And having manual steps and offering automated steps in parallel is not really supported. What I came up with is that you can configure the serial port in the gateway config optionally. For adding a gateway you need to push the "add"-button like before but you will see then the manually configured serial path from the config in the list in addition. I hope this should cover all the use cases.

eltako:
  general_settings:
    fast_status_change: False
    show_dev_id_in_dev_name: False
  gateway:
  - id: 0
    device_type: fam14
    base_id: FF-AA-80-00
    serial_path: my_path_to_serial
    devices:
...

Changes are added to main branch. Documentation will follow.

LutzDi commented 8 months ago

Hi @grimmpp,

I appreciate your work and help, thx a lot for your integration. Since today I was running an older version of your integration and wanted to update to the v1.2.3, including switching the config to the new syntax. But unfortunately, I don't get it working. May I request your help again on this point, because I'm running exactly in the same issue with the mentioned config entries. At the moment the system tells me things like

'id' is an invalid option for 'eltako', check: eltako->gateway->0->id.

Please let me mention first that I have my config divided into pieces. Until today I've been using the Packages solution HA and a separate config for Eltako. I tried to keep the separation but as I said it hadn't worked for me. Also moving everything to the standard configuration.yaml leads to the following error message if I test my config:

Invalid config for 'eltako' at configuration.yaml, line 33: 'general_settings' is an invalid option for 'eltako', check: eltako->general_settings Invalid config for 'eltako' at configuration.yaml, line 41: 'gateway' is an invalid option for 'eltako', check: eltako->gateway

Could you push me in the right direction what I'm doing wrong? I tried many many different setups but non of them worked. I really would like to update to the new version and config but I need some more help. If you need it, please find the last version of the config that I tested here:

eltako:
  general_settings:
    fast_status_change: false # True:
    show_dev_id_in_dev_name: false
  gateway:
  - id: 1
    device_type: fgw14usb
    base_id: FF-A1-43-80
    name: FGW14-USB
    devices:
      light:
      - id: "00-00-00-01"
        name: "Keller Flur Decke"
        eep: "M5-38-08"
        sender:
            id: "00-00-F0-01"
            eep: "A5-38-08"

      - id: "00-00-00-03"
        name: "Werkstatt Decke"
        eep: "M5-38-08"
        sender:
            id: "00-00-F0-02"
            eep: "A5-38-08"
...

Perhaps the reason is that I'm new in using HA, so I really would appreciate your help. Please let me know if you need more information from my side...

I wish you all the very best for the new year 2024, stay healthy.

Thx and cheers Lutz

LutzDi commented 8 months ago

Hi @grimmpp,

disregard it, I got it sorted out... I don't know exactly what I've done wrong during the update of the integration but I just started from scratch. I deleted the old integration and every device/entity, installed the new version from HACS, and set up a completely new configuration like I mentioned above. All Eltako configs are now in one file. And it worked. I can't tell you what the real reason was but for everybody upgrading to the new config layout I would recommend to start from the scratch, also if it's a bit of work to do.

So far so good... For me, this issue is closed for the moment. I will now try to solve the issue with the window handle I mentioned in the other issue.

Thx and cheers Lutz