nielstron / ha_bayernluefter

Custom component for the Bayernluefter
Apache License 2.0
8 stars 4 forks source link

Unterstützung für mehrere Bayernlüfter #5

Closed Fasanenpark closed 2 years ago

Fasanenpark commented 2 years ago

Ich habe 3 Bayernlüfter mit unterschiedlichen IPs im Einsatz. Über Ihre tolle Erweiterung war es mir möglich einen Bayernlüfter in mein Home Assistant aufzunehmen. Das funktioniert soweit super. Allerdings kann ich keinen weiteren Lüfter in das System anbinden, da mit der Erweiterung nur eine IP verknüpft werden kann. Gibt es seitens Home assistant Möglichkeiten die Erweiterung mehrmals einzubinden oder kann die Erweiterung mit einem Namen und einer IP in der Konfig erweitert werden? Dann würde auch die Warnung verschwinden, dass keine eindeutige ID vorhanden ist verschwinden.

nielstron commented 2 years ago

I cant try this myself but did you just try to set up multiple components and assigning them unique names? If so could you please share your configuration?

nielstron commented 2 years ago

In particular please try

bayernluefter:
   name: luefter1
   resource: IP1
   scan_interval: 30

bayernluefter:
   name: luefter2
   resource: IP2
   scan_interval: 30

I don't know why this should not work but maybe the error message will help.

dieterxy commented 2 years ago

Thanks for your response. I tried as you proposed above and got the following error message when checking the config:

Konfiguration fehlerhaft! Invalid config for [bayernluefter]: [name] is an invalid option for [bayernluefter]. Check: bayernluefter->bayernluefter->name. (See /config/configuration.yaml, line 18).

dieterxy commented 2 years ago

If I enter multiple "bayernluefter" entries in the configuration.yaml (without the name attribute) only the last one counts, so at the end I always have exact one bayernluefter. I also can't rename the entities of this bayernluefter, because that leads to the errormessage: This entity ("sensor.bayernluefter") does not have a unique ID, therefore its settings cannot be managed from the UI.

nielstron commented 2 years ago

I pushed an update that allows adding optional names per entry. Please try again if you can now have different entities.

dieterxy commented 2 years ago

I updated the Bayernluefter Integration and rebooted. Then I added the names in the configuration.yaml and started again: bayernluefter: name: Bl_Bad resource: http://192.168.178.44/ scan_interval: 60 # Optional scan interval in seconds

bayernluefter: name: BL_Kueche resource: http://192.168.178.46/ scan_interval: 60 # Optional scan interval in seconds

Results:

I then removed the "name: BL_Bad" entry from the first Bayernluefter entry in the configuration.yaml to activate the old entry again. Result:

I would like to delete all Bayernluefter entries and start the test fresh, but I found no way to delete this entities. Do you have a hint how I can delete these entities?

dieterxy commented 2 years ago

FYI: Within the update I got the following message: Update from version c7c16e7 -> f5989ab For me the version numbers are unusual but no problem, the system knows on its own which version the newer one is. I only want to ensure that you are aware of it.

nielstron commented 2 years ago

I would like to delete all Bayernluefter entries and start the test fresh, but I found no way to delete this entities. Do you have a hint how I can delete these entities?

This seems to be some HomeAssistant magic, I fear I can not help you there. I tried to look this up but didn't find anything about it. I would have assumed a proper reboot solves the issue.

Within the update I got the following message: Update from version https://github.com/nielstron/ha_bayernluefter/commit/c7c16e7b9bcfccc7128803657c631645d43cbfb1 -> https://github.com/nielstron/ha_bayernluefter/commit/f5989abfe9836ab2ab84ea6a13be8ae3b3ffaf75

This is expected behaviour.

nielstron commented 2 years ago

I have pushed a version that should allow you to set up BLNET configurations as a list of configs. Please try your previous config again (I am curious if it works). Otherwise try a syntax like this:

bayernluefter:
    - name: Bl_Bad
      resource: http://192.168.178.44/
      scan_interval: 60 # Optional scan interval in seconds
   -  name: BL_Kueche
      resource: http://192.168.178.46/
      scan_interval: 60 # Optional scan interval in seconds
Fasanenpark commented 2 years ago

I got the following error message: The system cannot restart because the configuration is not valid: Invalid config for [bayernluefter]: expected a dictionary for dictionary value @ data['bayernluefter']. Got [OrderedDict([('name', 'Bl_Keller'), ('resource', 'http://192.168.50.29'), ('scan_interval', 60)]), OrderedDict([('name', 'BL_Schlafen'), ('resource', 'http://192.168.50.30'), ('scan_interval', 60)])]. (See /config/configuration.yaml, line 61).

My configuration:

bayernluefter:
    - name: Bl_Keller
      resource: http://192.168.50.29
      scan_interval: 60 # Optional scan interval in seconds
    - name: BL_Schlafen
      resource: http://192.168.50.30
      scan_interval: 60 # Optional scan interval in seconds

The old configuration still works:

bayernluefter:
    resource: http://192.168.50.29
    scan_interval: 30 # Optional scan interval in seconds

but only one device.

nielstron commented 2 years ago

@Fasanenpark Did you update the component to the latest version? Please check in HACS for updates

dieterxy commented 2 years ago

I updated to the new 6d75a1f version and restartet:

The following config leads to the error message that Fasanenpark mentioned above when trying to store it. bayernluefter:

The following config can be stored without error message, but only the "BL_Kueche" entities appear. bayernluefter: name: Bl_Bad resource: http://192.168.178.44/ scan_interval: 60 # Optional scan interval in seconds name: BL_Kueche resource: http://192.168.178.46/ scan_interval: 60 # Optional scan interval in seconds

nielstron commented 2 years ago

Thanks for checking @dieterxy Please user markdown code notation when pasting your configuration so I can see the actual code. You can do it like this:

....config....

nielstron commented 2 years ago

@dieterxy @Fasanenpark Thanks for your feedback. I have pushed another fix that should fix the problem. Please try again.

dieterxy commented 2 years ago

I removed all bayernluefter entries from the configuration.yaml, updated to 67b2618 and restarted. Result: Now I find no working config with bayernluefter enties anymore. Every bayernluefter entry in the configuration.yaml leads to an endless config check.

Log: ````

Logger: aiohttp.server Source: helpers/check_config.py:182 First occurred: 13:06:52 (10 occurrences) Last logged: 13:19:44 Error handling request

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/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 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 82, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 30, in post errors = await async_check_ha_config_file(request.app["hass"]) File "/usr/src/homeassistant/homeassistant/config.py", line 929, in async_check_ha_config_file res = await check_config.async_check_ha_config_file(hass) File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 182, in async_check_ha_config_file config = config_schema(config) TypeError: 'tuple' object is not callable

```

nielstron commented 2 years ago

Thanks for checking. That was a mistake on my side. I pushed a fix

Fasanenpark commented 2 years ago

I still get the following error Massage on the newest Version.

The system cannot restart because the configuration is not valid: Invalid config for [bayernluefter]: expected a dictionary for dictionary value @ data['bayernluefter']. Got [OrderedDict([('name', 'BL-Keller'), ('resource', 'http://192.168.50.29/'), ('scan_interval', 60)]), OrderedDict([('name', 'BLSchlafen'), ('resource', 'http://192.168.50.30/'), ('scan_intervall', 60)])]. (See /config/configuration.yaml, line 59).

My config:

bayernluefter:
    - name: Bl_Keller
      resource: http://192.168.50.29
      scan_interval: 60 # Optional scan interval in seconds
    - name: BL_Schlafen
      resource: http://192.168.50.30
      scan_interval: 60 # Optional scan interval in seconds

You can also check IT by yourself, even you have only one device. Just configure a second device in the config. The errors come through the syntax and semantic check of home assistant.

Fasanenpark commented 2 years ago

i am not a developper but there is a new config mechanism to handle config entries (see https://developers.home-assistant.io/docs/config_entries_config_flow_handler ) there is also a note (blue box, https://developers.home-assistant.io/docs/configuration_yaml_index ) in the documentation that the config via yaml is not the preferred way.

dieterxy commented 2 years ago

I get the same error message as Fasanenpark when try to verify the configuration. When I remove the '-' in front of 'name' the configuration check is fine, but only the last bayernluefter is created. Same effect when I create 2 bayernluefter: sections.

Fasanenpark commented 2 years ago

On my home assistant version (Raspberry Pi version latest major version) to remove - in front of name does not work. Also to create 2 bayernluefter sections does not work. I can create one device bayernluefter with this configuration:

bayernluefter:
      name: Bl_Keller
      resource: http://192.168.50.29
      scan_interval: 60 # Optional scan interval in seconds
nielstron commented 2 years ago

You can also check IT by yourself, even you have only one device. Just configure a second device in the config. The errors come through the syntax and semantic check of home assistant.

Yes I need to find some time and set up home assistant again. I am currently not using it which makes developing a bit cumbersome.

i am not a developper but there is a new config mechanism to handle config entries (see https://developers.home-assistant.io/docs/config_entries_config_flow_handler ) there is also a note (blue box, https://developers.home-assistant.io/docs/configuration_yaml_index ) in the documentation that the config via yaml is not the preferred way.

I am fully aware of this but have no intention to implement it due to above mentioned non-home-assistant usage.

nielstron commented 2 years ago

The issue should be fixed by #7

Fasanenpark commented 2 years ago

The configuration is now accepted by home assistant. Unfortunately only the last configured device gets data from sensors. All other devices do not get any sensor data. Status is unknown.

dieterxy commented 2 years ago

Same in my environment. The entities of all devices exist, but only the entities of the last Bayernluefter are updated. All others have status unknown.

nielstron commented 2 years ago

Thanks for the notification @dieterxy , @Fasanenpark , please check if this is resolved with the most recent commit!

dieterxy commented 2 years ago

Thanks Niels. Looks really good. I have 4 bayernluefter and all are being updated now. Great.

As always :-) here an idea for improvement: Do you know how to also enable your custom card for multiple bayernluefter without copying it and changing the entity attributes? Nevertheless, it's also fine for me now, thanks again. Dieter

nielstron commented 2 years ago

Great! As for the cards, no I don't have a particular idea but I would suggest moving this into a seperate issue for future inspiration.

Fasanenpark commented 2 years ago

Thanks very much Niels. Works now also fine in my system with three bayernluefter. I also have some Ideas for enhancements for the custom card to set fan speed etc. I will play around a little. If I have an example I will share it.