Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIFX: assume default features for unknown products #8553

Merged
merged 1 commit into from
Jul 20, 2017

Conversation

amelchio
Copy link
Contributor

@amelchio amelchio commented Jul 19, 2017

Description:

This makes the detection work for prototypes as well.

Reported in aiolifx/aiolifx#21 by @cmsimike

Checklist:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@mention-bot
Copy link

@amelchio, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @balloob and @shmuelzon to be potential reviewers.

@amelchio amelchio added this to the 0.49.1 milestone Jul 19, 2017
@amelchio amelchio changed the title LIFX: assume default features for unknown products [WIP] LIFX: assume default features for unknown products Jul 19, 2017
@amelchio
Copy link
Contributor Author

If you want to help test this, copy this file on top of your lifx.py

@mihalski I added some logging to that version, are you able to install it?

@mihalski
Copy link

I put that lifx.py in my custom_components directory and restarted, but I can't see any particular differences in the logging results.

@amelchio
Copy link
Contributor Author

Try giving it a different name like lifxtest.py (and adjust the platform name in the configuration) to make sure the new one is used.

@mihalski
Copy link

While custom_components should override the builtin ones this seems to be another problem.. I've renamed to lightest.py and set the platform to lightest and it's not loading.

I could have sworn I had done exactly this before in the past. Will need to look at this tomorrow as it's nearing midnight..

@amelchio
Copy link
Contributor Author

amelchio commented Jul 19, 2017

Ah, probably it should go into custom_components/light ?

Edit: confirmed, but then you need to copy services.yaml as well

@amelchio
Copy link
Contributor Author

@cmsimike I am unable to reproduce this problem. Can you try my fixed version and tell me what it logs? Also, is this a permanent issue or does it only happen sometimes?

@cmsimike
Copy link
Contributor

@amelchio Permanent issue. I will look into running this version locally and get back to you asap.

@cmsimike
Copy link
Contributor

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 392, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/usr/lib/python3.5/asyncio/coroutines.py", line 206, in coro
    res = func(*args, **kw)
  File "/home/mike/.homeassistant/custom_components/light/lifxtest.py", line 138, in async_setup_platform
    lifx_manager = LIFXManager(hass, async_add_devices)
  File "/home/mike/.homeassistant/custom_components/light/lifxtest.py", line 230, in __init__
    path.join(path.dirname(__file__), 'services.yaml'))
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config.py", line 267, in load_yaml_config_file
    getattr(err, 'filename', err)))
homeassistant.exceptions.HomeAssistantError: Config file not found: /home/mike/.homeassistant/custom_components/light/services.yaml
^C (homeassistant) mike@tehass:~/.homeassistant/custom_components/light $

Not sure what services.yaml is. I can't seem to load the component without it.

@cmsimike
Copy link
Contributor

Ok I copied the file from the hass dir into my custom_components and got hass started. My light is picked back up!!! I am getting this warning in the logs, however:

WARNING:custom_components.light.lifxtest:'office': unknown type 14

@amelchio
Copy link
Contributor Author

@cmsimike Hmmm, product id 14 is not listed in the official LIFX product map. I wonder how you got such a version but that does explain why things didn't work before.

Thanks for testing!

@cmsimike
Copy link
Contributor

@amelchio I'm sure lifx sent it to me by mistake. Thank YOU for your quick fix on this.

@mihalski
Copy link

mihalski commented Jul 19, 2017

OK. Just read that this has been solved.. So will follow the same process.

@amelchio
Copy link
Contributor Author

@mihalski Right, you can copy this one.

@mihalski
Copy link

For the record, I currently have 21 lifx lights on my network.. Two of which have EXTREMELY unstable wifi (despite having an excellent signal) and MANY of which have no problems with wifi but plenty of problems with availability.

2017-07-20 08:12:50 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.39 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.79 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.69 register NEW
2017-07-20 08:12:51 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.78 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.66 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.40 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.72 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.33 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.85 register NEW
2017-07-20 08:12:52 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.73 register NEW
2017-07-20 08:12:53 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.141 register NEW
2017-07-20 08:12:53 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.68 register NEW
2017-07-20 08:12:53 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.31 register NEW
2017-07-20 08:12:53 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.32 register NEW
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.39 (Office Ceiling Light) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.66 (Family Room Ceiling Light) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.79 (Dining Area Ceiling Light 2) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.78 (Dining Area Ceiling Light 1) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.33 (Master Bedroom Desk Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.68 (Living Room Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.85 (Master Bedroom Jola Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.69 (TV Area Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.141 (Downlight 2) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.73 (Formal Area Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.72 (Spare Bedroom Stan Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.40 (Bedroom Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.31 (Study Desk Lamp) register READY
2017-07-20 08:12:55 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.32 (Office Lamp) register READY
2017-07-20 08:13:10 ERROR (MainThread) [custom_components.light.lifxtest] No product ID
2017-07-20 08:13:10 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 (None) register READY
2017-07-20 08:13:10 ERROR (MainThread) [custom_components.light.lifxtest] No product ID
2017-07-20 08:13:10 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 (None) register READY
2017-07-20 08:13:10 ERROR (MainThread) [custom_components.light.lifxtest] No product ID
2017-07-20 08:13:10 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 (None) register READY
2017-07-20 08:13:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 419, in state_attributes
    value = getattr(self, prop)
  File "/config/custom_components/light/lifxtest.py", line 434, in brightness
    brightness = convert_16_to_8(self.device.color[2])
TypeError: 'NoneType' object is not subscriptable
2017-07-20 08:13:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 419, in state_attributes
    value = getattr(self, prop)
  File "/config/custom_components/light/lifxtest.py", line 434, in brightness
    brightness = convert_16_to_8(self.device.color[2])
TypeError: 'NoneType' object is not subscriptable
2017-07-20 08:13:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 419, in state_attributes
    value = getattr(self, prop)
  File "/config/custom_components/light/lifxtest.py", line 434, in brightness
    brightness = convert_16_to_8(self.device.color[2])
TypeError: 'NoneType' object is not subscriptable
2017-07-20 08:13:10 ERROR (MainThread) [custom_components.light.lifxtest] No product ID
2017-07-20 08:13:10 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 (None) register READY
2017-07-20 08:13:10 ERROR (MainThread) [custom_components.light.lifxtest] No product ID
2017-07-20 08:13:10 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 (None) register READY
2017-07-20 08:13:10 ERROR (MainThread) [custom_components.light.lifxtest] No product ID
2017-07-20 08:13:10 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.1 (None) register READY
2017-07-20 08:13:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 419, in state_attributes
    value = getattr(self, prop)
  File "/config/custom_components/light/lifxtest.py", line 434, in brightness
    brightness = convert_16_to_8(self.device.color[2])
TypeError: 'NoneType' object is not subscriptable
2017-07-20 08:13:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 419, in state_attributes
    value = getattr(self, prop)
  File "/config/custom_components/light/lifxtest.py", line 434, in brightness
    brightness = convert_16_to_8(self.device.color[2])
TypeError: 'NoneType' object is not subscriptable
2017-07-20 08:13:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 381, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 238, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 419, in state_attributes
    value = getattr(self, prop)
  File "/config/custom_components/light/lifxtest.py", line 434, in brightness
    brightness = convert_16_to_8(self.device.color[2])
TypeError: 'NoneType' object is not subscriptable
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.39 (Office Ceiling Light) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.66 (Family Room Ceiling Light) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.79 (Dining Area Ceiling Light 2) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.78 (Dining Area Ceiling Light 1) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.33 (Master Bedroom Desk Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.68 (Living Room Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.85 (Master Bedroom Jola Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.69 (TV Area Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.141 (Downlight 2) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.73 (Formal Area Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.72 (Spare Bedroom Stan Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.40 (Bedroom Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.31 (Study Desk Lamp) async_update
2017-07-20 08:13:46 DEBUG (MainThread) [custom_components.light.lifxtest] 192.168.1.32 (Office Lamp) async_update

I think that covers just about everything in the log file. I've also attached an image of what this looks like from the point of view of my wifi router. Lights go out of and into AJ mode randomly it seems.
screen shot 2017-07-20 08 21 18 am

@amelchio
Copy link
Contributor Author

@mihalski Something's very wrong there. You have six bulbs with IP address 192.168.1.1 which seems more like a router address. Are you running the bulbs through a router/firewall/something that does NAT?

@mihalski
Copy link

No. Nothing like that. And as you can see, the router doesn't see them on those IP's either.

@amelchio
Copy link
Contributor Author

That's crazy. Are you able to do a tcpdump on the HA machine?

@mihalski
Copy link

Not without great difficulty.. But I'll see what I can do. I need to set up my spare RPi2 with Raspbian and then figure out how to statically build tcpdump so that I can use it from within the hassio container.
In the meantime I could do this:

root@hassio:~# docker exec homeassistant arp -a |grep d0:73:d5
? (192.168.1.73) at d0:73:d5:14:13:5c [ether] on eth0
? (192.168.1.69) at d0:73:d5:14:1a:e0 [ether] on eth0
? (192.168.1.39) at d0:73:d5:12:21:f3 [ether] on eth0
? (192.168.1.33) at d0:73:d5:12:1c:5f [ether] on eth0
? (192.168.1.78) at d0:73:d5:13:c5:71 [ether] on eth0
? (192.168.1.40) at d0:73:d5:14:14:26 [ether] on eth0
? (192.168.1.85) at d0:73:d5:13:d4:86 [ether] on eth0
? (192.168.1.31) at d0:73:d5:12:18:41 [ether] on eth0
? (192.168.1.141) at d0:73:d5:13:d1:c1 [ether] on eth0
? (192.168.1.72) at d0:73:d5:14:06:a4 [ether] on eth0
? (192.168.1.68) at d0:73:d5:14:09:22 [ether] on eth0
? (192.168.1.38) at d0:73:d5:13:e5:c3 [ether] on eth0
? (192.168.1.87) at d0:73:d5:13:c0:f9 [ether] on eth0
? (192.168.1.67) at d0:73:d5:13:e1:6e [ether] on eth0
? (192.168.1.70) at d0:73:d5:13:d0:17 [ether] on eth0
? (192.168.1.32) at d0:73:d5:14:1d:c8 [ether] on eth0
? (192.168.1.81) at d0:73:d5:13:c0:fc [ether] on eth0
? (192.168.1.79) at d0:73:d5:13:e4:97 [ether] on eth0
? (192.168.1.140) at d0:73:d5:13:c8:5d [ether] on eth0
? (192.168.1.86) at d0:73:d5:13:d4:a6 [ether] on eth0
? (192.168.1.66) at d0:73:d5:13:d1:65 [ether] on eth0

@amelchio
Copy link
Contributor Author

Never mind, that's not worth the trouble. I will try installing hassio, maybe it is playing some networking tricks?

This makes the detection work for prototypes as well.
@amelchio amelchio changed the title [WIP] LIFX: assume default features for unknown products LIFX: assume default features for unknown products Jul 19, 2017
@mihalski
Copy link

Trouble is my middle name (or so they tell me).

root@hassio:~# docker exec homeassistant /config/bin/tcpdump --version
tcpdump version 4.9.0
libpcap version 1.8.1

Is there something specific you would like me to do to help debug this?

@balloob
Copy link
Member

balloob commented Jul 20, 2017

Since the comments are no longer relevant to this PR, and the fix seems to be confirmed, I'm merging this. Please try to keep PRs on topic next time @mihalski

@balloob balloob merged commit 8a42e15 into home-assistant:dev Jul 20, 2017
@amelchio
Copy link
Contributor Author

@mihalski Well, a start would be

tcpdump 'udp port 56700 and host 192.168.1.1'

to check whether these packets are really sent.

This has turned into quite its own topic and no HA code can fix duplicate IP addresses, so I will go ahead and close this issue. Maybe we can continue the debugging discussion in Gitter?

@amelchio
Copy link
Contributor Author

@balloob Ah, you beat me. To be fair, the symptoms started out very similar and @mihalski was told it was the same issue.

balloob pushed a commit that referenced this pull request Jul 24, 2017
This makes the detection work for prototypes as well.
@balloob balloob mentioned this pull request Jul 24, 2017
dethpickle pushed a commit to dethpickle/home-assistant that referenced this pull request Aug 18, 2017
This makes the detection work for prototypes as well.
@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants