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
73.38k stars 30.64k forks source link

Xiaomi-Aqara Gateway via Integration page can't be found because of lack of option "host" in new integration GUI #37661

Closed MaximumSU closed 4 years ago

MaximumSU commented 4 years ago

The problem

Trying to add my old Xiaomi Aqara Gateway with the new GUI integration page - not working.

Environment

dev false
docker false
hassio false
installation_type Home Assistant Core
os_name Linux
os_version 4.19.66-v7+
python_version 3.7.3
timezone Europe/Moscow
virtualenv true

Problem-relevant configuration.yaml

Traceback/Error logs

OSError: [Errno 99] Cannot assign requested address

Additional information

Multicasts (used by discovery) not working well in my network, so, gateway can't be finded. Old yaml configuration had the option "host" to set the ip of gateway directly. I used that option and my Gateway had work without problem. Now i can't add it back because that option (host) is not exists in new integration, so, it is not possible to add Gateway anymore.

meichthys commented 4 years ago

Same here. I use VLANS and have issues with multicast working across vlans.

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

Hey there @danielhiversen, @syssi, mind taking a look at this issue as its been labeled with an integration (xiaomi_aqara) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

ekt- commented 4 years ago

Same here. Multicast never worked for me, but setting the xiaomi gateway ip in the host setting fixed it. Worked for two years. Still broken in 0.112.4

meichthys commented 4 years ago

For now I've reverted to 0.111.4 since i rely on this integration a lot. In case anyone else reverts to 0.111.4, you may need to also remove your homeassistant_v2.db and reboot homeassistant. I think this is needed because v0.112.0 restructured the database which broke backward compatibility.

MaximumSU commented 4 years ago

@meichthys As the workaround, you may get the component from 0.111.4 and put it in your "custom_components" folder. I use it like this - It works.

meichthys commented 4 years ago

I just downgraded to 111.4 for now. Thanks for the heads up though 👍

ekt- commented 4 years ago

0.111.4 version as a "custom_components" did the trick. thanks @MaximumSU for the idea

meichthys commented 4 years ago

@MaximumSU I just tried your suggestion to use the 0.111.4 component as a custom_component in 0.112.4 without success. Is there anything extra you had to do?

MaximumSU commented 4 years ago

@meichthys You do something wrong. It must work. Are you copied the folder "xiaomi_aqara" from "where_your_homeassistant_installed/lib/python3.7/site-packages/homeassistant/components/ " (not dig inside folder, just the folder with all content) to the folder "/home/homeassistant/.homeassistant/custom_components/" and then restarted HASS?

ekt- commented 4 years ago

@meichthys be sure you are like this image

also be sure you have restored the old config section in the configuration.yaml, you know

xiaomi_aqara:
  gateways:
   - mac: F0B429CBFE14
   blah blah
meichthys commented 4 years ago

@MaximumSU are you running HA in a virtual env? I don't have that same source folder structure but I did copy the 0.111.4 xiaomi_aqara integration from github into my custom_comlonents directory as @ekt- shows.

MaximumSU commented 4 years ago

@meichthys

are you running HA in a virtual env?

Yes.

meichthys commented 4 years ago

@MaximumSU ok I'm running hassos so it's a different directory structure.

piit79 commented 4 years ago

@starkillerOG While I appreciate your hard work and generally understand the push to move away from YAML to config flows, it's really annoying when the new config flows lack feature parity with the most important YAML use cases. In this particular case it's the inability to configure the integration manually by entering the gateway IP address/MAC address/token. When such feature parity doesn't exist it doesn't make sense to remove the YAML configuration - it's a sure way to annoy the users. Especially when the troubles with the discovery have been well known.

In my case I'm not quite sure what's happening - I can see the multicast packets on the VLAN interface using tcpdump, both the outgoing whois one to 224.0.0.50:4321 and the incoming heartbeat ones from :4321 -> 224.0.0.50:9898, but the discovery still fails. I have a nftables firewall in place but I have the allowed UDP packets to port 9898, which was the solution to the gateway disconnecting after a set amount of time previously (2 hours or something).

I'm pretty sure it's something in my networking setup, but until I figure it out, it would be great to be able to configure the gateway manually, especially when it has a fixed IP address and even a local hostname, so there's no need for discovery.

starkillerOG commented 4 years ago

This is related to https://github.com/home-assistant/core/issues/37306#issuecomment-657131761 See that issue, I already made PR to fix that issue which will also fix this. Currently waiting on the release of the PyXiaomiGateway lib on PyPi, there still is some travis build issue....

piit79 commented 4 years ago

@starkillerOG Thanks for the response. I hope my comment didn't come across as too harsh - I was just very frustrated that an integration that worked without any issues suddenly stopped working completely.

Do you have any plans to reintroduce full manual configuration like it was possible in YAML? I don't think the fix in PyXiaomiGateway will help in my case, I'm not actually getting any exceptions or other errors in the log. It must be something in my networking setup but for the love of Pete I can't figure it out.

My setup just for reference: x86_64 home router with Ubuntu (PCEngines apu2c4) <--> 802.1q VLAN trunk <--> Managed PoE GbE switch <--> VLAN trunk <--> OpenWRT Wi-Fi AP (TP-Link Archer C6) <--> Separate Wi-Fi SSID to Xiaomi Aqara Gateway I'm using nftables firewall on the router and networking is managed by systemd-networkd.

Until then I had to resort to copying xiaomi_aqara component from 0.111.4 to custom_components and also copying config_flow.py and const.py from 0.112.4 to the old component to get it working with YAML again.

meichthys commented 4 years ago

@piit79 I have a very similar setup as you (using vlans/separate wifi ssid) and I'm also trying to use the 0.111.4 component without any luck, but i haven't tried copying the config_flow.py and const.py back to the old component from 0.112.4

Do you know why that would be needed?

piit79 commented 4 years ago

@meichthys Glad to hear I'm not the only one ;-) Are you seeing any errors in your logs regarding the discovery? Because I'm not, the packets just never seem to arrive. I see the whois discovery packet from HA, but it's apparently never received by the gateway, because it doesn't respond with iam. I can only see the heartbeat packets from the gateway.

The reason I copied the config_flow.py (and const.py, its dependency) is because I was unable to get rid of the following error:

ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration xiaomi_aqara: No module named 'custom_components.xiaomi_aqara.config_flow'

Due to this the component would never finish initializing:

WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: xiaomi_aqara

For some reason, even with the old component version, HA was still trying to set up the config flow. I tried reverting the changes in other files related to config flows made in the same commit, but with no luck. I'm just glad I made it work even in this very hacky way, it would be a pain to be without the doorbell chime (and to a lesser extent, a night light).

meichthys commented 4 years ago

I am seeing some 'unable to discover' messages in my log and I didn't see the two errors you listed. Those errors seem like they would only exist if you were still using the 0.112.4 integration since the integration before 0.112.4 didn't have a config flow, but I'm no expert either. Just trying to get my home usable again since most of my sensors are aqara sensors!

piit79 commented 4 years ago

@meichthys That's what I thought, too, but apparently the config flow functionality must have been activated somewhere outside the xiaomi_aqara component... Then again, I didn't see others report these errors I was getting.

I feel your pain. I'm sure glad I moved all my Aqara sensors to zigbee2mqtt a long time ago...

meichthys commented 4 years ago

I tried moving my aqara sensors to ZHA but they seemed to go offline because the aqara sensors did not conform to the signs spec perfectly so some Sylvania bulbs I had were interfering and kicking them offline. What signee hub do you use? I'm using the hubz-1

piit79 commented 4 years ago

@meichthys I haven't tried ZHA yet, it seems to be the "new" Zigbee integration that is more user-friendly as it's configured from the UI. I'm using zigbee2mqtt which is much more mature and has great support for lots of devices. New devices are added constantly. It requires running an addon but I've been very happy with it.

I'm using the zzh! Zigbee stick from Tindie with the TI CC2652R chip. Unfortunately z2m doesn't support HUSBZB-1 (yet?).

MisterWil commented 4 years ago

Any updates on this? I also depend on being able to manually specify the hub's IP address during setup and have also had to restore the old component as a custom component after upgrading.

meichthys commented 4 years ago

@MisterWil This will be fixed in HA version 0.113.2 which should be released soon.

starkillerOG commented 4 years ago

actually will not be part of 0.113.2, see the status of this PR to check for updates: https://github.com/home-assistant/core/pull/37469 as soon as that gets merged it will be fixed in the next release. It is ready to be merged tho, so schould be in a couple of days.

meichthys commented 4 years ago

I was a little too optimistic about the v0.113.2 release!