Lagute LW-12 Wifi LED control#13307
Lagute LW-12 Wifi LED control#13307MartinHjelmare merged 26 commits intohome-assistant:devfrom jaypikay:lw12wifi
Conversation
There was a problem hiding this comment.
redefinition of unused 'DOMAIN' from line 36
There was a problem hiding this comment.
Platforms belong to a domain. lw12wifi belongs to light.
OttoWinter
left a comment
There was a problem hiding this comment.
I don't understand why we should have configuration options like effect, brightness or rgb. The user can manually specify those in service calls.
There was a problem hiding this comment.
The indentation makes this quite hard to read, could you maybe consider indenting the vol.All blocks?
There was a problem hiding this comment.
Please do the following instead for None checks (I'm assuming this is checking for None):
if self._effect is None:
return None
return self._effect.replace('_', ' ').title()It's just so much easier to understand.
There was a problem hiding this comment.
This seems like a debugging statement for development and not for later use. The service calls will be logged anyway from the core.
There was a problem hiding this comment.
PEP8 recommends doing None checks with is not None:
if self._effect is not None:There was a problem hiding this comment.
This is a blocking method and it does I/O. It should therefore not be in an async context. Consider renaming the method to (especially when using time.sleep(0.25); it would block the entire core)
def turn_on(self, **kwargs):The same applies for turn_off
|
To answer the question why we should have configuration options like |
|
What I was trying to say is that I don't understand why we should provide these options at all. I mean if we don't know the state at startup, why should the configuration know for us what these brightness, color, ... values will be at startup? This platform can't ask the device for states, ok. But then I would just assume the platform would initialize the light as off. |
There was a problem hiding this comment.
The docstring should be:
"""Return True if unable to access real state of the entity."""as from the entity definition.
There was a problem hiding this comment.
I think you would need another time.sleep(0.25) after this (and a couple of other places). Also I think halding kwargs with both rgb color and brightness can be handled a bit smarter. currently you're first sending the old brightness and then the new brightness from kwargs.
There was a problem hiding this comment.
Another time.sleep(.25) is not needed here, if we call normal turn_on without the brightness setting, the light will "forget" the brightness and set the new color. The platform would still list the brightness as defined by either the default setting defined in the configuration or by previous turn_on calls with brightness as argument.
|
All settings but I developed the platform using my experience with the hardware in mind and what would be nice to have. But I am happy to help by fixing my code. Using service calls is possible and is at the moment the only way to set the transistion speed when using effects. I had hoped for a slider like brightness. |
There was a problem hiding this comment.
As a heads-up, we've just merged a big refactoring to how light platforms implement colors. You'll need to rebase on the latest dev. Platforms are now going to receive turn_on reqeusts with a hue/sat color, and need to report their current color in hue/sat.
Some examples of how to convert to/from RGB if that's the preferred platform interface are here:
There was a problem hiding this comment.
Thanks you this information. I will update the code to match the new requirements.
|
Sorry for bumping, but do I need to improve something to get it merged in a future release, or simply wait? |
There was a problem hiding this comment.
Move that to setup_platform and pass it down to LW12WiFi(). This way you don't need host and port.
There was a problem hiding this comment.
Please use the same style for listing the features as other platform do.
There was a problem hiding this comment.
I did as in components/light/{group.py,mqtt_json.py,zha.py,zwave.py,} and other, sorry but I don't understand why this is not good for my solution but for others?
There was a problem hiding this comment.
This style with using mutable features with |= is usually only done when there are "dynamic" supported features. For example, light.mqtt_json only enables color when it's defined in the configuration. For these static integrations like lw12wifi, it's usually cleaner to define the supported features in a global constant like this:
There was a problem hiding this comment.
rgb_color is not used by the light component base. This property can be removed.
There was a problem hiding this comment.
It probably doesn't matter too much, but you could implement RGB color here as it's done in the light base:
vol.All(vol.ExactSequence((cv.byte, cv.byte, cv.byte)),
vol.Coerce(tuple)),There was a problem hiding this comment.
Could this parameter be renamed to transition_length or transition_speed or default_transition_length? I think just transition is not too descriptive.
There was a problem hiding this comment.
If it's an unknown effect, shouldn't we just raise HomeAssistantError. I'm not a huge fan of failing silently.
There was a problem hiding this comment.
So when using this, every time there's a turn_on call the transition length will be set for all future turn_on calls?
I think the transition length from the service call should just refer to a single request.
There was a problem hiding this comment.
Otto is correct. We should not store the transition speed as an instance variable.
There was a problem hiding this comment.
Users should not pass in RGB, TRANSITION. Please remove these config values.
There was a problem hiding this comment.
If you want to restore the previous known state after a restart, use helpers/restore_state.py (but do that in a new PR)
There was a problem hiding this comment.
This is not being referenced in the config (and neither should it). Please remove.
There was a problem hiding this comment.
Possible to validate here that the connection has been established successfully?
There was a problem hiding this comment.
Unfortunatly not, it is an UDP connection, and the controller will never answerer to sent messages.
There was a problem hiding this comment.
Unfortunatly it is an UDP connection and the device does not send answers back.
There was a problem hiding this comment.
Please add the property should_poll and have it return False
There was a problem hiding this comment.
Might not be needed if #14229 gets merged before this PR.
…rt in LW12Wifi class.
Description:
New platform added to support the Lagute LW-12 WiFi LED Controller. The controller is stateless and communicates via UDP. To handle the controller itself the python module python-lw12 is required and automatically installed by the
REQUIREMENTS.The platform supports 29 effects, brightness, rgb color and transition speed settings.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5264
Example entry for
configuration.yaml:Checklist:
tox.If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable.requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices: