Closed bdraco closed 2 years ago
@bdraco We should be aware of the #109. The IP can also be a DNS name. Especially in the HASS config flow if I enter a DNS name of a bulb manually.
I would suggest something like:
def _resolve_dnsname(self, dns_or_ip: str):
"""Returns a IP in case of a DNS was given."""
try:
return socket.gethostbyname(dns_or_ip)
except socket.gaierror:
raise WizLightConnectionError("DNS name can not be resloved.")
@bdraco We should be aware of the #109. The IP can also be a DNS name. Especially in the HASS config flow if I enter a DNS name of a bulb manually.
Usually we don't want to accept dns names since if dns is having issues the device can't be setup. As soon as discovery sees the bulb it will update it to an ip address via
https://github.com/home-assistant/core/blob/dev/homeassistant/components/wiz/config_flow.py#L61
This takes care of the case where the bulb's dhcp reservation changes.
def _resolve_dnsname(self, dns_or_ip: str): """Returns a IP in case of a DNS was given.""" try: return socket.gethostbyname(dns_or_ip) except socket.gaierror: raise WizLightConnectionError("DNS name can not be resloved.")
If we do want to do allow a hostname, we need to use loop.getaddrinfo()
since it is async safe.
@bdraco We should be aware of the #109. The IP can also be a DNS name. Especially in the HASS config flow if I enter a DNS name of a bulb manually.
Usually we don't want to accept dns names since if dns is having issues the device can't be setup. As soon as discovery sees the bulb it will update it to an ip address via
https://github.com/home-assistant/core/blob/dev/homeassistant/components/wiz/config_flow.py#L61
This takes care of the case where the bulb's dhcp reservation changes.
def _resolve_dnsname(self, dns_or_ip: str): """Returns a IP in case of a DNS was given.""" try: return socket.gethostbyname(dns_or_ip) except socket.gaierror: raise WizLightConnectionError("DNS name can not be resloved.")
If we do want to do allow a hostname, we need to use
loop.getaddrinfo()
since it is async safe.
Ok, that makes more sense in general. I'll make the documentation clear that the library (natively) only supports IPs as input for the wizlight class.
The HASS strings should be updated to "IP" because the "IP/Host" can be misleading for the user.
The HASS strings should be updated to "IP" because the "IP/Host" can be misleading for the user.
Yeah, I that makes more sense. There is probably no point in resolving it for them since they can leave it blank and do discovery anyways. We should change the string though and reject anything thats not an Ip
This is looking really efficient now. The debug logging is taking far more time than the actual protocol ops
Yes, that looks really great!
For the changes in the ConfiFlow and the IP-Address input validation, I'll open a new PR to the core.
The offline case looks a lot better as well with sendto
being the bulk of the time. We can't improve that though since its low level
Improves performance when bulb is offline
Fixes python 3.8 typing compat
Fixes race condition during shutdown
Fixes memory leak in discovery
Fixes slow tests
Adds test runs to the CI
No longer respond to
syncPilot
messages since the bulb keeps sending them anyways and all it does is generate additional network congestionfixes #107, fixes #106, fixes #105