Multi-Room Support for Greenwave Reality#11364
Conversation
| doc = greenwave.grab_xml(host, token) | ||
| add_devices(GreenwaveLight(device, host, token) for device in doc) | ||
| for room in doc: | ||
| add_devices(GreenwaveLight(device, host, token) for device in room['device']) |
There was a problem hiding this comment.
line too long (85 > 79 characters)
|
Looking at the existing code, it looks like the update logic is not optimal. Am I right assuming that every light will hit the XML API on its update, retrieving all information? I.e., the API will always be called multiple times? I think it would be way better to cache that XML document together with a time stamp somewhere (in I'm not saying that this PR shouldn't be merged without this improvement, I'm just saying that if you feel up to the task… 😉 |
|
@tinloaf Yes, your assumption is correct. This is modeled after the android app, but I do have plans to create an update function that updates all bulbs on one XML call. Hopefully in the next update. |
|
Bump? I was hoping this would make it into the .61 release |
| self._state = int(device['state']) | ||
| self._brightness = greenwave.hass_brightness(device) | ||
| self._online = greenwave.check_online(device) | ||
| self._name = device['name'] |
There was a problem hiding this comment.
That is a realy bad runtime. Make a data object like this: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/yweather.py#L174-L190
On this data object you can map it to a usefuly data format and access without loop.
Your code actual:
- Hit the device with 10x bulbs it call the gateway 10x times
- Loop over 1000x
|
@dfiel an inefficient platform is frowned upon because it can slow down all of Home Assistant. What an Android app does is actually irrelevant in this regard. However, this PR does not introduce the inefficiency but it rather fixes an error (that is even being reported now). So how about we merge this PR if @dfiel promises that the next PR will be to implement the shared state object? |
|
Already working on it :) |
Shared State Object added, and implemented new function of greenwavereality to abstract complex runtimes.
|
@pvizeli Does this solve the issue? I believe it does. |
|
Yes |
|
Please fix lint and we can merge it |
|
@pvizeli Lint issues fixed |
* upstream/master: (465 commits) Update pyhomematic to 0.1.38 (home-assistant#11936) Implement Alexa temperature sensors (home-assistant#11930) Fixed rfxtrx binary_sensor KeyError on missing optional device_class (home-assistant#11925) Allow setting climate devices to AUTO mode via Google Assistant (home-assistant#11923) fixes home-assistant#11848 (home-assistant#11915) Add "write" service to system_log (home-assistant#11901) Update frontend to 20180126.0 Version 0.62 Allow separate command and state OIDs and payloads in SNMP switch (home-assistant#11075) Add ERC20 tokens to etherscan.io sensor (home-assistant#11916) Report scripts and groups as scenes to Alexa (home-assistant#11900) Minor fix to configuration validation and related log line. (home-assistant#11898) Multi-Room Support for Greenwave Reality (home-assistant#11364) Added Xeoma camera platform (home-assistant#11619) Improve foscam library exception support (home-assistant#11701) Iota wallet (home-assistant#11398) New venstar climate component (home-assistant#11639) Update python-wink version and multiple wink fixes/updates. (home-assistant#11833) Use API to discover Hue if no bridges specified (home-assistant#11909) Clarify emulated hue warning (home-assistant#11910) ...
Description:
Added support for gateways with multiple rooms already set up. No longer errors when more than 1 room is defined.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#4005
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.